diff options
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/coerce.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 16 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 7 |
3 files changed, 13 insertions, 16 deletions
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 07eb96573..9c62932b1 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -142,7 +142,7 @@ impl<'a> InferenceContext<'a> { | |||
142 | .build(); | 142 | .build(); |
143 | let trait_ref = | 143 | let trait_ref = |
144 | TraitRef { trait_id: to_chalk_trait_id(coerce_unsized_trait), substitution: substs }; | 144 | TraitRef { trait_id: to_chalk_trait_id(coerce_unsized_trait), substitution: substs }; |
145 | let goal = InEnvironment::new(self.trait_env.clone(), trait_ref.cast(&Interner)); | 145 | let goal = InEnvironment::new(self.trait_env.env.clone(), trait_ref.cast(&Interner)); |
146 | 146 | ||
147 | let canonicalizer = self.canonicalizer(); | 147 | let canonicalizer = self.canonicalizer(); |
148 | let canonicalized = canonicalizer.canonicalize_obligation(goal); | 148 | let canonicalized = canonicalizer.canonicalize_obligation(goal); |
@@ -170,8 +170,8 @@ impl<'a> InferenceContext<'a> { | |||
170 | self.db, | 170 | self.db, |
171 | self.resolver.krate(), | 171 | self.resolver.krate(), |
172 | InEnvironment { | 172 | InEnvironment { |
173 | value: canonicalized.value.clone(), | 173 | goal: canonicalized.value.clone(), |
174 | environment: self.trait_env.clone(), | 174 | environment: self.trait_env.env.clone(), |
175 | }, | 175 | }, |
176 | ) { | 176 | ) { |
177 | let derefed_ty = canonicalized.decanonicalize_ty(derefed_ty.value); | 177 | let derefed_ty = canonicalized.decanonicalize_ty(derefed_ty.value); |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 17849d552..4e2a432ed 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -90,12 +90,12 @@ impl<'a> InferenceContext<'a> { | |||
90 | let substs = | 90 | let substs = |
91 | Substitution::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); | 91 | Substitution::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); |
92 | 92 | ||
93 | let trait_env = Arc::clone(&self.trait_env); | 93 | let trait_env = self.trait_env.env.clone(); |
94 | let implements_fn_trait: DomainGoal = | 94 | let implements_fn_trait: DomainGoal = |
95 | TraitRef { trait_id: to_chalk_trait_id(fn_once_trait), substitution: substs.clone() } | 95 | TraitRef { trait_id: to_chalk_trait_id(fn_once_trait), substitution: substs.clone() } |
96 | .cast(&Interner); | 96 | .cast(&Interner); |
97 | let goal = self.canonicalizer().canonicalize_obligation(InEnvironment { | 97 | let goal = self.canonicalizer().canonicalize_obligation(InEnvironment { |
98 | value: implements_fn_trait.clone(), | 98 | goal: implements_fn_trait.clone(), |
99 | environment: trait_env, | 99 | environment: trait_env, |
100 | }); | 100 | }); |
101 | if self.db.trait_solve(krate, goal.value).is_some() { | 101 | if self.db.trait_solve(krate, goal.value).is_some() { |
@@ -299,8 +299,8 @@ impl<'a> InferenceContext<'a> { | |||
299 | self.db, | 299 | self.db, |
300 | self.resolver.krate(), | 300 | self.resolver.krate(), |
301 | InEnvironment { | 301 | InEnvironment { |
302 | value: canonicalized.value.clone(), | 302 | goal: canonicalized.value.clone(), |
303 | environment: self.trait_env.clone(), | 303 | environment: self.trait_env.env.clone(), |
304 | }, | 304 | }, |
305 | ); | 305 | ); |
306 | let (param_tys, ret_ty): (Vec<Ty>, Ty) = derefs | 306 | let (param_tys, ret_ty): (Vec<Ty>, Ty) = derefs |
@@ -438,8 +438,8 @@ impl<'a> InferenceContext<'a> { | |||
438 | self.db, | 438 | self.db, |
439 | self.resolver.krate(), | 439 | self.resolver.krate(), |
440 | InEnvironment { | 440 | InEnvironment { |
441 | value: canonicalized.value.clone(), | 441 | goal: canonicalized.value.clone(), |
442 | environment: self.trait_env.clone(), | 442 | environment: self.trait_env.env.clone(), |
443 | }, | 443 | }, |
444 | ) | 444 | ) |
445 | .find_map(|derefed_ty| { | 445 | .find_map(|derefed_ty| { |
@@ -538,8 +538,8 @@ impl<'a> InferenceContext<'a> { | |||
538 | self.db, | 538 | self.db, |
539 | krate, | 539 | krate, |
540 | InEnvironment { | 540 | InEnvironment { |
541 | value: &canonicalized.value, | 541 | goal: &canonicalized.value, |
542 | environment: self.trait_env.clone(), | 542 | environment: self.trait_env.env.clone(), |
543 | }, | 543 | }, |
544 | ) { | 544 | ) { |
545 | Some(derefed_ty) => { | 545 | Some(derefed_ty) => { |
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 7595b46cf..75250a369 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -98,15 +98,12 @@ impl<'a, 'b> Canonicalizer<'a, 'b> { | |||
98 | mut self, | 98 | mut self, |
99 | obligation: InEnvironment<DomainGoal>, | 99 | obligation: InEnvironment<DomainGoal>, |
100 | ) -> Canonicalized<InEnvironment<DomainGoal>> { | 100 | ) -> Canonicalized<InEnvironment<DomainGoal>> { |
101 | let result = match obligation.value { | 101 | let result = match obligation.goal { |
102 | DomainGoal::Holds(wc) => { | 102 | DomainGoal::Holds(wc) => { |
103 | DomainGoal::Holds(self.do_canonicalize(wc, DebruijnIndex::INNERMOST)) | 103 | DomainGoal::Holds(self.do_canonicalize(wc, DebruijnIndex::INNERMOST)) |
104 | } | 104 | } |
105 | }; | 105 | }; |
106 | self.into_canonicalized(InEnvironment { | 106 | self.into_canonicalized(InEnvironment { goal: result, environment: obligation.environment }) |
107 | value: result, | ||
108 | environment: obligation.environment, | ||
109 | }) | ||
110 | } | 107 | } |
111 | } | 108 | } |
112 | 109 | ||