mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
Emit an error when RTN is used in an incorrect place
We miss one place: associated type bindings aka. `impl Trait<Type(..): Send>`, but we also miss it for Fn-style parenthesizes error so I left it out for now.
This commit is contained in:
parent
eaa0a39831
commit
5076ef7d9b
4 changed files with 80 additions and 2 deletions
|
|
@ -607,8 +607,14 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
|
|||
) -> Substitution {
|
||||
let prohibit_parens = match def {
|
||||
GenericDefId::TraitId(trait_) => {
|
||||
let trait_data = self.ctx.db.trait_data(trait_);
|
||||
!trait_data.flags.contains(TraitFlags::RUSTC_PAREN_SUGAR)
|
||||
// RTN is prohibited anyways if we got here.
|
||||
let is_rtn =
|
||||
self.current_or_prev_segment.args_and_bindings.is_some_and(|generics| {
|
||||
generics.parenthesized == GenericArgsParentheses::ReturnTypeNotation
|
||||
});
|
||||
let is_fn_trait =
|
||||
!self.ctx.db.trait_data(trait_).flags.contains(TraitFlags::RUSTC_PAREN_SUGAR);
|
||||
is_rtn || is_fn_trait
|
||||
}
|
||||
_ => true,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue