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,31 +385,32 @@ 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 =
if name == segment.name { associated_type_shorthand_candidates(ctx.db, res, move |name, t, associated_ty| {
let substs = match ctx.type_param_mode { if name == segment.name {
TypeParamLoweringMode::Placeholder => { let substs = match ctx.type_param_mode {
// if we're lowering to placeholders, we have to put TypeParamLoweringMode::Placeholder => {
// them in now // if we're lowering to placeholders, we have to put
let s = Substs::type_params( // them in now
ctx.db, let s = Substs::type_params(
ctx.resolver ctx.db,
.generic_def() ctx.resolver.generic_def().expect(
.expect("there should be generics if there's a generic param"), "there should be generics if there's a generic param",
); ),
t.substs.clone().subst_bound_vars(&s) );
} t.substs.clone().subst_bound_vars(&s)
TypeParamLoweringMode::Variable => t.substs.clone(), }
}; TypeParamLoweringMode::Variable => t.substs.clone(),
// FIXME handle type parameters on the segment };
return Some(Ty::Projection(ProjectionTy { // FIXME handle type parameters on the segment
associated_ty, return Some(Ty::Projection(ProjectionTy {
parameters: substs, associated_ty,
})); parameters: substs,
} }));
}
None None
}); });
ty.unwrap_or(Ty::Unknown) ty.unwrap_or(Ty::Unknown)
} else { } else {
@ -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>,