aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-04-29 23:03:36 +0100
committerJonas Schievink <[email protected]>2020-04-29 23:10:30 +0100
commit3cb73da9499938e6f09736e4b6fba33474c3ce9c (patch)
tree690f793620fe3abf0583d2052979c9f3015929f9 /crates
parent8c2670026a4c864a67a06bab654e203ed068f021 (diff)
Rename to associated_type_shorthand_candidates
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/semantics.rs4
-rw-r--r--crates/ra_hir_ty/src/lib.rs4
-rw-r--r--crates/ra_hir_ty/src/lower.rs51
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::{
9 AsMacroCall, TraitId, 9 AsMacroCall, TraitId,
10}; 10};
11use hir_expand::ExpansionInfo; 11use hir_expand::ExpansionInfo;
12use hir_ty::associated_types; 12use hir_ty::associated_type_shorthand_candidates;
13use itertools::Itertools; 13use itertools::Itertools;
14use ra_db::{FileId, FileRange}; 14use ra_db::{FileId, FileRange};
15use ra_prof::profile; 15use ra_prof::profile;
@@ -78,7 +78,7 @@ impl PathResolution {
78 mut cb: impl FnMut(TypeAlias) -> Option<R>, 78 mut cb: impl FnMut(TypeAlias) -> Option<R>,
79 ) -> Option<R> { 79 ) -> Option<R> {
80 if let Some(res) = self.clone().in_type_ns() { 80 if let Some(res) = self.clone().in_type_ns() {
81 associated_types(db, res, |_, _, id| cb(id.into())) 81 associated_type_shorthand_candidates(db, res, |_, _, id| cb(id.into()))
82 } else { 82 } else {
83 None 83 None
84 } 84 }
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;
66pub use infer::{InferTy, InferenceResult}; 66pub use infer::{InferTy, InferenceResult};
67pub use lower::CallableDef; 67pub use lower::CallableDef;
68pub use lower::{ 68pub use lower::{
69 associated_types, callable_item_sig, ImplTraitLoweringMode, TyDefId, TyLoweringContext, 69 associated_type_shorthand_candidates, callable_item_sig, ImplTraitLoweringMode, TyDefId,
70 ValueTyDefId, 70 TyLoweringContext, ValueTyDefId,
71}; 71};
72pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; 72pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
73 73
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 {
385 segment: PathSegment<'_>, 385 segment: PathSegment<'_>,
386 ) -> Ty { 386 ) -> Ty {
387 if let Some(res) = res { 387 if let Some(res) = res {
388 let ty = associated_types(ctx.db, res, move |name, t, associated_ty| { 388 let ty =
389 if name == segment.name { 389 associated_type_shorthand_candidates(ctx.db, res, move |name, t, associated_ty| {
390 let substs = match ctx.type_param_mode { 390 if name == segment.name {
391 TypeParamLoweringMode::Placeholder => { 391 let substs = match ctx.type_param_mode {
392 // if we're lowering to placeholders, we have to put 392 TypeParamLoweringMode::Placeholder => {
393 // them in now 393 // if we're lowering to placeholders, we have to put
394 let s = Substs::type_params( 394 // them in now
395 ctx.db, 395 let s = Substs::type_params(
396 ctx.resolver 396 ctx.db,
397 .generic_def() 397 ctx.resolver.generic_def().expect(
398 .expect("there should be generics if there's a generic param"), 398 "there should be generics if there's a generic param",
399 ); 399 ),
400 t.substs.clone().subst_bound_vars(&s) 400 );
401 } 401 t.substs.clone().subst_bound_vars(&s)
402 TypeParamLoweringMode::Variable => t.substs.clone(), 402 }
403 }; 403 TypeParamLoweringMode::Variable => t.substs.clone(),
404 // FIXME handle type parameters on the segment 404 };
405 return Some(Ty::Projection(ProjectionTy { 405 // FIXME handle type parameters on the segment
406 associated_ty, 406 return Some(Ty::Projection(ProjectionTy {
407 parameters: substs, 407 associated_ty,
408 })); 408 parameters: substs,
409 } 409 }));
410 }
410 411
411 None 412 None
412 }); 413 });
413 414
414 ty.unwrap_or(Ty::Unknown) 415 ty.unwrap_or(Ty::Unknown)
415 } else { 416 } else {
@@ -671,7 +672,7 @@ pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDef) -> PolyFnSig {
671 } 672 }
672} 673}
673 674
674pub fn associated_types<R>( 675pub fn associated_type_shorthand_candidates<R>(
675 db: &dyn HirDatabase, 676 db: &dyn HirDatabase,
676 res: TypeNs, 677 res: TypeNs,
677 mut cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option<R>, 678 mut cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option<R>,