diff options
author | Jonas Schievink <[email protected]> | 2020-04-29 23:03:36 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-04-29 23:10:30 +0100 |
commit | 3cb73da9499938e6f09736e4b6fba33474c3ce9c (patch) | |
tree | 690f793620fe3abf0583d2052979c9f3015929f9 /crates/ra_hir_ty/src | |
parent | 8c2670026a4c864a67a06bab654e203ed068f021 (diff) |
Rename to associated_type_shorthand_candidates
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 51 |
2 files changed, 28 insertions, 27 deletions
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; | |||
66 | pub use infer::{InferTy, InferenceResult}; | 66 | pub use infer::{InferTy, InferenceResult}; |
67 | pub use lower::CallableDef; | 67 | pub use lower::CallableDef; |
68 | pub use lower::{ | 68 | pub 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 | }; |
72 | pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; | 72 | pub 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 | ||
674 | pub fn associated_types<R>( | 675 | pub 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>, |