From 3cb73da9499938e6f09736e4b6fba33474c3ce9c Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 30 Apr 2020 00:03:36 +0200 Subject: Rename to associated_type_shorthand_candidates --- crates/ra_hir/src/semantics.rs | 4 ++-- crates/ra_hir_ty/src/lib.rs | 4 ++-- crates/ra_hir_ty/src/lower.rs | 51 +++++++++++++++++++++--------------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 687f83f60..e6a7aaee0 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -9,7 +9,7 @@ use hir_def::{ AsMacroCall, TraitId, }; use hir_expand::ExpansionInfo; -use hir_ty::associated_types; +use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; use ra_db::{FileId, FileRange}; use ra_prof::profile; @@ -78,7 +78,7 @@ impl PathResolution { mut cb: impl FnMut(TypeAlias) -> Option, ) -> Option { if let Some(res) = self.clone().in_type_ns() { - associated_types(db, res, |_, _, id| cb(id.into())) + associated_type_shorthand_candidates(db, res, |_, _, id| cb(id.into())) } else { None } diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 341a18683..a6f56c661 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -66,8 +66,8 @@ pub use autoderef::autoderef; pub use infer::{InferTy, InferenceResult}; pub use lower::CallableDef; pub use lower::{ - associated_types, callable_item_sig, ImplTraitLoweringMode, TyDefId, TyLoweringContext, - ValueTyDefId, + associated_type_shorthand_candidates, callable_item_sig, ImplTraitLoweringMode, TyDefId, + TyLoweringContext, ValueTyDefId, }; pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 67e5c1ccd..9ad6dbe07 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -385,31 +385,32 @@ impl Ty { segment: PathSegment<'_>, ) -> Ty { if let Some(res) = res { - let ty = associated_types(ctx.db, res, move |name, t, associated_ty| { - if name == segment.name { - let substs = match ctx.type_param_mode { - TypeParamLoweringMode::Placeholder => { - // if we're lowering to placeholders, we have to put - // them in now - let s = Substs::type_params( - ctx.db, - ctx.resolver - .generic_def() - .expect("there should be generics if there's a generic param"), - ); - t.substs.clone().subst_bound_vars(&s) - } - TypeParamLoweringMode::Variable => t.substs.clone(), - }; - // FIXME handle type parameters on the segment - return Some(Ty::Projection(ProjectionTy { - associated_ty, - parameters: substs, - })); - } + let ty = + associated_type_shorthand_candidates(ctx.db, res, move |name, t, associated_ty| { + if name == segment.name { + let substs = match ctx.type_param_mode { + TypeParamLoweringMode::Placeholder => { + // if we're lowering to placeholders, we have to put + // them in now + let s = Substs::type_params( + ctx.db, + ctx.resolver.generic_def().expect( + "there should be generics if there's a generic param", + ), + ); + t.substs.clone().subst_bound_vars(&s) + } + TypeParamLoweringMode::Variable => t.substs.clone(), + }; + // FIXME handle type parameters on the segment + return Some(Ty::Projection(ProjectionTy { + associated_ty, + parameters: substs, + })); + } - None - }); + None + }); ty.unwrap_or(Ty::Unknown) } else { @@ -671,7 +672,7 @@ pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDef) -> PolyFnSig { } } -pub fn associated_types( +pub fn associated_type_shorthand_candidates( db: &dyn HirDatabase, res: TypeNs, mut cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option, -- cgit v1.2.3