mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Handle associated type shorthand (T::Item
)
This is only allowed for generic parameters (including `Self` in traits), and special care needs to be taken to not run into cycles while resolving it, because we use the where clauses of the generic parameter to find candidates for the trait containing the associated type, but the where clauses may themselves contain instances of short-hand associated types. In some cases this is even fine, e.g. we might have `T: Trait<U::Item>, U: Iterator`. If there is a cycle, we'll currently panic, which isn't great, but better than overflowing the stack...
This commit is contained in:
parent
468e1d14c1
commit
18bf278c25
7 changed files with 538 additions and 392 deletions
|
@ -344,6 +344,13 @@ impl Resolver {
|
|||
})
|
||||
.flat_map(|params| params.where_predicates.iter())
|
||||
}
|
||||
|
||||
pub(crate) fn generic_def(&self) -> Option<crate::generics::GenericDef> {
|
||||
self.scopes.iter().find_map(|scope| match scope {
|
||||
Scope::GenericParams(params) => Some(params.def),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Resolver {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue