diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-12 20:43:57 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-12 20:43:57 +0100 |
commit | 2c65a059840dd2092a00e90337a8221cd832c456 (patch) | |
tree | fa1f8c46158271eb859928ed9da3eb389f861c09 /crates/ra_hir/src/ty/traits.rs | |
parent | 0cf48e48d75d267bfa38ff1319e7f7c0468fb53f (diff) | |
parent | 5af9691dc9132db61b50c4e90cdeda6fea0c5dd9 (diff) |
Merge #1677
1677: Associated types r=flodiebold a=flodiebold
This implements basic support for (fully qualified) associated type projections:
- handle fully qualified paths like `<T as Trait>::AssocType` (basically desugaring to something like `Trait<Self=T>::AssocType`)
- lower these to a new `Ty::Projection` enum variant
- also introduce `Ty::UnselectedProjection` for cases like `T::AssocType` where the trait from which the type comes isn't specified, but these aren't handled further so far
- in inference, normalize these projections using Chalk: basically, when encountering a type e.g. from a type annotation or signature, we replace these `Ty::Projection`s by type variables and add obligations to normalize the associated type
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/traits.rs')
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 0769e6e17..fde5d8a47 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -7,7 +7,7 @@ use parking_lot::Mutex; | |||
7 | use ra_prof::profile; | 7 | use ra_prof::profile; |
8 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
9 | 9 | ||
10 | use super::{Canonical, GenericPredicate, ProjectionTy, TraitRef, Ty}; | 10 | use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty}; |
11 | use crate::{db::HirDatabase, Crate, ImplBlock, Trait}; | 11 | use crate::{db::HirDatabase, Crate, ImplBlock, Trait}; |
12 | 12 | ||
13 | use self::chalk::{from_chalk, ToChalk}; | 13 | use self::chalk::{from_chalk, ToChalk}; |
@@ -61,7 +61,6 @@ fn solve( | |||
61 | ) -> Option<chalk_solve::Solution> { | 61 | ) -> Option<chalk_solve::Solution> { |
62 | let context = ChalkContext { db, krate }; | 62 | let context = ChalkContext { db, krate }; |
63 | let solver = db.trait_solver(krate); | 63 | let solver = db.trait_solver(krate); |
64 | debug!("solve goal: {:?}", goal); | ||
65 | let solution = solver.lock().solve(&context, goal); | 64 | let solution = solver.lock().solve(&context, goal); |
66 | debug!("solve({:?}) => {:?}", goal, solution); | 65 | debug!("solve({:?}) => {:?}", goal, solution); |
67 | solution | 66 | solution |
@@ -120,10 +119,11 @@ pub struct ProjectionPredicate { | |||
120 | pub(crate) fn trait_solve_query( | 119 | pub(crate) fn trait_solve_query( |
121 | db: &impl HirDatabase, | 120 | db: &impl HirDatabase, |
122 | krate: Crate, | 121 | krate: Crate, |
123 | trait_ref: Canonical<InEnvironment<Obligation>>, | 122 | goal: Canonical<InEnvironment<Obligation>>, |
124 | ) -> Option<Solution> { | 123 | ) -> Option<Solution> { |
125 | let _p = profile("trait_solve_query"); | 124 | let _p = profile("trait_solve_query"); |
126 | let canonical = trait_ref.to_chalk(db).cast(); | 125 | debug!("trait_solve_query({})", goal.value.value.display(db)); |
126 | let canonical = goal.to_chalk(db).cast(); | ||
127 | // We currently don't deal with universes (I think / hope they're not yet | 127 | // We currently don't deal with universes (I think / hope they're not yet |
128 | // relevant for our use cases?) | 128 | // relevant for our use cases?) |
129 | let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; | 129 | let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; |