diff options
Diffstat (limited to 'crates/ra_hir_ty/src/lower.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 5138019c7..88d962b47 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -30,6 +30,7 @@ use crate::{ | |||
30 | Binders, FnSig, GenericPredicate, PolyFnSig, ProjectionPredicate, ProjectionTy, Substs, | 30 | Binders, FnSig, GenericPredicate, PolyFnSig, ProjectionPredicate, ProjectionTy, Substs, |
31 | TraitEnvironment, TraitRef, Ty, TypeCtor, | 31 | TraitEnvironment, TraitRef, Ty, TypeCtor, |
32 | }; | 32 | }; |
33 | use hir_expand::name::Name; | ||
33 | 34 | ||
34 | #[derive(Debug)] | 35 | #[derive(Debug)] |
35 | pub struct TyLoweringContext<'a, DB: HirDatabase> { | 36 | pub struct TyLoweringContext<'a, DB: HirDatabase> { |
@@ -69,6 +70,10 @@ pub enum ImplTraitLoweringMode { | |||
69 | /// i.e. for arguments of the function we're currently checking, and return | 70 | /// i.e. for arguments of the function we're currently checking, and return |
70 | /// types of functions we're calling. | 71 | /// types of functions we're calling. |
71 | Opaque, | 72 | Opaque, |
73 | /// `impl Trait` gets lowered into a type variable. Used for argument | ||
74 | /// position impl Trait currently, since it allows us to support that | ||
75 | /// without Chalk. | ||
76 | Param, | ||
72 | /// `impl Trait` gets lowered into a variable that can unify with some | 77 | /// `impl Trait` gets lowered into a variable that can unify with some |
73 | /// type. This is used in places where values flow 'in', i.e. for arguments | 78 | /// type. This is used in places where values flow 'in', i.e. for arguments |
74 | /// of functions we're calling, and the return type of the function we're | 79 | /// of functions we're calling, and the return type of the function we're |
@@ -137,6 +142,11 @@ impl Ty { | |||
137 | .collect(); | 142 | .collect(); |
138 | Ty::Opaque(predicates) | 143 | Ty::Opaque(predicates) |
139 | } | 144 | } |
145 | ImplTraitLoweringMode::Param => { | ||
146 | let idx = ctx.impl_trait_counter.get(); | ||
147 | ctx.impl_trait_counter.set(idx + 1); | ||
148 | Ty::Param { idx: idx as u32, name: Name::missing() } | ||
149 | } | ||
140 | ImplTraitLoweringMode::Variable => { | 150 | ImplTraitLoweringMode::Variable => { |
141 | let idx = ctx.impl_trait_counter.get(); | 151 | let idx = ctx.impl_trait_counter.get(); |
142 | ctx.impl_trait_counter.set(idx + 1); | 152 | ctx.impl_trait_counter.set(idx + 1); |