From 18bf278c258f44ed68f67f84993f20f7c27c63d0 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 22 Sep 2019 20:01:12 +0200 Subject: 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: Iterator`. If there is a cycle, we'll currently panic, which isn't great, but better than overflowing the stack... --- crates/ra_hir/src/db.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/ra_hir/src/db.rs') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index f7f124904..05259dcbb 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -164,6 +164,13 @@ pub trait HirDatabase: DefDatabase + AstDatabase { #[salsa::invoke(crate::ty::callable_item_sig)] fn callable_item_signature(&self, def: CallableDef) -> FnSig; + #[salsa::invoke(crate::ty::generic_predicates_for_param_query)] + fn generic_predicates_for_param( + &self, + def: GenericDef, + param_idx: u32, + ) -> Arc<[GenericPredicate]>; + #[salsa::invoke(crate::ty::generic_predicates_query)] fn generic_predicates(&self, def: GenericDef) -> Arc<[GenericPredicate]>; -- cgit v1.2.3