aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/lower.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-03-31 19:02:16 +0100
committerFlorian Diebold <[email protected]>2019-04-14 10:28:53 +0100
commita1ed53a4f183b5826162eb9e998207b92be9c57f (patch)
tree7c139a7dc38483188653c6d40583cddac9d23192 /crates/ra_hir/src/ty/lower.rs
parent413c87f155ab6b389b1cc122b5739716acccb476 (diff)
More trait infrastructure
- make it possible to get parent trait from method - add 'obligation' machinery for checking that a type implements a trait (and inferring facts about type variables from that) - handle type parameters of traits (to a certain degree) - improve the hacky implements check to cover enough cases to exercise the handling of traits with type parameters - basic canonicalization (will probably also be done by Chalk)
Diffstat (limited to 'crates/ra_hir/src/ty/lower.rs')
-rw-r--r--crates/ra_hir/src/ty/lower.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index 4523b3954..ccacb5e73 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -206,6 +206,7 @@ impl TraitRef {
206 db: &impl HirDatabase, 206 db: &impl HirDatabase,
207 resolver: &Resolver, 207 resolver: &Resolver,
208 type_ref: &TypeRef, 208 type_ref: &TypeRef,
209 explicit_self_ty: Option<Ty>,
209 ) -> Option<Self> { 210 ) -> Option<Self> {
210 let path = match type_ref { 211 let path = match type_ref {
211 TypeRef::Path(path) => path, 212 TypeRef::Path(path) => path,
@@ -215,7 +216,13 @@ impl TraitRef {
215 Resolution::Def(ModuleDef::Trait(tr)) => tr, 216 Resolution::Def(ModuleDef::Trait(tr)) => tr,
216 _ => return None, 217 _ => return None,
217 }; 218 };
218 let substs = Self::substs_from_path(db, resolver, path, resolved); 219 let mut substs = Self::substs_from_path(db, resolver, path, resolved);
220 if let Some(self_ty) = explicit_self_ty {
221 // FIXME this could be nicer
222 let mut substs_vec = substs.0.to_vec();
223 substs_vec[0] = self_ty;
224 substs.0 = substs_vec.into();
225 }
219 Some(TraitRef { trait_: resolved, substs }) 226 Some(TraitRef { trait_: resolved, substs })
220 } 227 }
221 228