aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/resolve.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-22 23:01:38 +0100
committerGitHub <[email protected]>2019-09-22 23:01:38 +0100
commitc2d9cca4e42ad052cf8a37ba3f6d9eacae07cbea (patch)
tree9f800613bde5ef6b80ab6a637990a6be69995dd4 /crates/ra_hir/src/resolve.rs
parentefcbca95595d31bb4c2c6782530d5a7a64a4191f (diff)
parentbc905d202c613a831f7c1abb846b612900a9b43a (diff)
Merge #1895
1895: Handle associated type shorthand (`T::Item`) (Second attempt) r=flodiebold a=flodiebold 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... Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r--crates/ra_hir/src/resolve.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index 254d1a964..39f8e1d8a 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -344,6 +344,13 @@ impl Resolver {
344 }) 344 })
345 .flat_map(|params| params.where_predicates.iter()) 345 .flat_map(|params| params.where_predicates.iter())
346 } 346 }
347
348 pub(crate) fn generic_def(&self) -> Option<crate::generics::GenericDef> {
349 self.scopes.iter().find_map(|scope| match scope {
350 Scope::GenericParams(params) => Some(params.def),
351 _ => None,
352 })
353 }
347} 354}
348 355
349impl Resolver { 356impl Resolver {