aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/autoderef.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-09 08:50:18 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-09 08:50:18 +0100
commitf59cd1a4a0d6c369025a7014e838d25f91d478e4 (patch)
tree2c4b9dc868a87507ed63e9dc46530cc60f38ae64 /crates/ra_hir/src/ty/autoderef.rs
parent35f28c538a9b9f461bb4db1a78d02e9f02a3d296 (diff)
parent9afbf2dff43dee3227358f10162d4c77d192ce7a (diff)
Merge #1515
1515: Trait environment r=matklad a=flodiebold This adds the environment, i.e. the set of `where` clauses in scope, when solving trait goals. That means that e.g. in ```rust fn foo<T: SomeTrait>(t: T) {} ``` , we are able to complete methods of `SomeTrait` on the `t`. This affects the trait APIs quite a bit (since every method that needs to be able to solve for some trait needs to get this environment somehow), so I thought I'd do it rather sooner than later ;) Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/autoderef.rs')
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs
index 90c1ae630..c26513871 100644
--- a/crates/ra_hir/src/ty/autoderef.rs
+++ b/crates/ra_hir/src/ty/autoderef.rs
@@ -52,6 +52,8 @@ fn deref_by_trait(
52 52
53 // FIXME make the Canonical handling nicer 53 // FIXME make the Canonical handling nicer
54 54
55 let env = super::lower::trait_env(db, resolver);
56
55 let projection = super::traits::ProjectionPredicate { 57 let projection = super::traits::ProjectionPredicate {
56 ty: Ty::Bound(0), 58 ty: Ty::Bound(0),
57 projection_ty: super::ProjectionTy { 59 projection_ty: super::ProjectionTy {
@@ -60,9 +62,13 @@ fn deref_by_trait(
60 }, 62 },
61 }; 63 };
62 64
63 let canonical = super::Canonical { num_vars: 1 + ty.num_vars, value: projection }; 65 let obligation = super::Obligation::Projection(projection);
66
67 let in_env = super::traits::InEnvironment { value: obligation, environment: env };
68
69 let canonical = super::Canonical { num_vars: 1 + ty.num_vars, value: in_env };
64 70
65 let solution = db.normalize(krate, canonical)?; 71 let solution = db.solve(krate, canonical)?;
66 72
67 match &solution { 73 match &solution {
68 Solution::Unique(vars) => { 74 Solution::Unique(vars) => {