diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-25 10:12:03 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-25 10:12:03 +0000 |
commit | 9f7fcc6ecd5334c5e3caa365c4a6d7bf3f37b649 (patch) | |
tree | 5dda185ddeba593b7af36f66eeb6098e4f913c05 /crates/ra_hir/src/ty/infer/expr.rs | |
parent | e00e6554ddc13be86733dc8a37a0a229931f378a (diff) | |
parent | 8c3e372835243c922b0eff7ca23f79f227991e88 (diff) |
Merge #2397
2397: Remove Resolver from autoderef r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/infer/expr.rs')
-rw-r--r-- | crates/ra_hir/src/ty/infer/expr.rs | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs index 663ff9435..194e55819 100644 --- a/crates/ra_hir/src/ty/infer/expr.rs +++ b/crates/ra_hir/src/ty/infer/expr.rs | |||
@@ -15,9 +15,9 @@ use crate::{ | |||
15 | db::HirDatabase, | 15 | db::HirDatabase, |
16 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, | 16 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, |
17 | ty::{ | 17 | ty::{ |
18 | autoderef, method_resolution, op, CallableDef, InferTy, IntTy, Mutability, Namespace, | 18 | autoderef, method_resolution, op, traits::InEnvironment, CallableDef, InferTy, IntTy, |
19 | Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, | 19 | Mutability, Namespace, Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, |
20 | Uncertain, | 20 | TypeCtor, TypeWalk, Uncertain, |
21 | }, | 21 | }, |
22 | Adt, Name, | 22 | Adt, Name, |
23 | }; | 23 | }; |
@@ -245,8 +245,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
245 | let canonicalized = self.canonicalizer().canonicalize_ty(receiver_ty); | 245 | let canonicalized = self.canonicalizer().canonicalize_ty(receiver_ty); |
246 | let ty = autoderef::autoderef( | 246 | let ty = autoderef::autoderef( |
247 | self.db, | 247 | self.db, |
248 | &self.resolver.clone(), | 248 | self.resolver.krate(), |
249 | canonicalized.value.clone(), | 249 | InEnvironment { |
250 | value: canonicalized.value.clone(), | ||
251 | environment: self.trait_env.clone(), | ||
252 | }, | ||
250 | ) | 253 | ) |
251 | .find_map(|derefed_ty| match canonicalized.decanonicalize_ty(derefed_ty.value) { | 254 | .find_map(|derefed_ty| match canonicalized.decanonicalize_ty(derefed_ty.value) { |
252 | Ty::Apply(a_ty) => match a_ty.ctor { | 255 | Ty::Apply(a_ty) => match a_ty.ctor { |
@@ -337,16 +340,25 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
337 | Expr::UnaryOp { expr, op } => { | 340 | Expr::UnaryOp { expr, op } => { |
338 | let inner_ty = self.infer_expr(*expr, &Expectation::none()); | 341 | let inner_ty = self.infer_expr(*expr, &Expectation::none()); |
339 | match op { | 342 | match op { |
340 | UnaryOp::Deref => { | 343 | UnaryOp::Deref => match self.resolver.krate() { |
341 | let canonicalized = self.canonicalizer().canonicalize_ty(inner_ty); | 344 | Some(krate) => { |
342 | if let Some(derefed_ty) = | 345 | let canonicalized = self.canonicalizer().canonicalize_ty(inner_ty); |
343 | autoderef::deref(self.db, &self.resolver, &canonicalized.value) | 346 | match autoderef::deref( |
344 | { | 347 | self.db, |
345 | canonicalized.decanonicalize_ty(derefed_ty.value) | 348 | krate, |
346 | } else { | 349 | InEnvironment { |
347 | Ty::Unknown | 350 | value: &canonicalized.value, |
351 | environment: self.trait_env.clone(), | ||
352 | }, | ||
353 | ) { | ||
354 | Some(derefed_ty) => { | ||
355 | canonicalized.decanonicalize_ty(derefed_ty.value) | ||
356 | } | ||
357 | None => Ty::Unknown, | ||
358 | } | ||
348 | } | 359 | } |
349 | } | 360 | None => Ty::Unknown, |
361 | }, | ||
350 | UnaryOp::Neg => { | 362 | UnaryOp::Neg => { |
351 | match &inner_ty { | 363 | match &inner_ty { |
352 | Ty::Apply(a_ty) => match a_ty.ctor { | 364 | Ty::Apply(a_ty) => match a_ty.ctor { |