Rename to associated_type_shorthand_candidates

This commit is contained in:
Jonas Schievink 2020-04-30 00:03:36 +02:00
parent 8c2670026a
commit 3cb73da949
3 changed files with 30 additions and 29 deletions

View file

@ -9,7 +9,7 @@ use hir_def::{
AsMacroCall, TraitId, AsMacroCall, TraitId,
}; };
use hir_expand::ExpansionInfo; use hir_expand::ExpansionInfo;
use hir_ty::associated_types; use hir_ty::associated_type_shorthand_candidates;
use itertools::Itertools; use itertools::Itertools;
use ra_db::{FileId, FileRange}; use ra_db::{FileId, FileRange};
use ra_prof::profile; use ra_prof::profile;
@ -78,7 +78,7 @@ impl PathResolution {
mut cb: impl FnMut(TypeAlias) -> Option<R>, mut cb: impl FnMut(TypeAlias) -> Option<R>,
) -> Option<R> { ) -> Option<R> {
if let Some(res) = self.clone().in_type_ns() { 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 { } else {
None None
} }

View file

@ -66,8 +66,8 @@ pub use autoderef::autoderef;
pub use infer::{InferTy, InferenceResult}; pub use infer::{InferTy, InferenceResult};
pub use lower::CallableDef; pub use lower::CallableDef;
pub use lower::{ pub use lower::{
associated_types, callable_item_sig, ImplTraitLoweringMode, TyDefId, TyLoweringContext, associated_type_shorthand_candidates, callable_item_sig, ImplTraitLoweringMode, TyDefId,
ValueTyDefId, TyLoweringContext, ValueTyDefId,
}; };
pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};

View file

@ -385,7 +385,8 @@ impl Ty {
segment: PathSegment<'_>, segment: PathSegment<'_>,
) -> Ty { ) -> Ty {
if let Some(res) = res { if let Some(res) = res {
let ty = associated_types(ctx.db, res, move |name, t, associated_ty| { let ty =
associated_type_shorthand_candidates(ctx.db, res, move |name, t, associated_ty| {
if name == segment.name { if name == segment.name {
let substs = match ctx.type_param_mode { let substs = match ctx.type_param_mode {
TypeParamLoweringMode::Placeholder => { TypeParamLoweringMode::Placeholder => {
@ -393,9 +394,9 @@ impl Ty {
// them in now // them in now
let s = Substs::type_params( let s = Substs::type_params(
ctx.db, ctx.db,
ctx.resolver ctx.resolver.generic_def().expect(
.generic_def() "there should be generics if there's a generic param",
.expect("there should be generics if there's a generic param"), ),
); );
t.substs.clone().subst_bound_vars(&s) t.substs.clone().subst_bound_vars(&s)
} }
@ -671,7 +672,7 @@ pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDef) -> PolyFnSig {
} }
} }
pub fn associated_types<R>( pub fn associated_type_shorthand_candidates<R>(
db: &dyn HirDatabase, db: &dyn HirDatabase,
res: TypeNs, res: TypeNs,
mut cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option<R>, mut cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option<R>,