diff options
Diffstat (limited to 'crates/hir_ty/src/traits.rs')
-rw-r--r-- | crates/hir_ty/src/traits.rs | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 7d87741b8..1cda72d22 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs | |||
@@ -12,7 +12,7 @@ use crate::{ | |||
12 | Solution, TraitRefExt, Ty, TyKind, WhereClause, | 12 | Solution, TraitRefExt, Ty, TyKind, WhereClause, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | use self::chalk::{from_chalk, Interner, ToChalk}; | 15 | use self::chalk::Interner; |
16 | 16 | ||
17 | pub(crate) mod chalk; | 17 | pub(crate) mod chalk; |
18 | 18 | ||
@@ -81,6 +81,7 @@ pub(crate) fn trait_solve_query( | |||
81 | db.trait_data(it.hir_trait_id()).name.to_string() | 81 | db.trait_data(it.hir_trait_id()).name.to_string() |
82 | } | 82 | } |
83 | DomainGoal::Holds(WhereClause::AliasEq(_)) => "alias_eq".to_string(), | 83 | DomainGoal::Holds(WhereClause::AliasEq(_)) => "alias_eq".to_string(), |
84 | _ => "??".to_string(), | ||
84 | }); | 85 | }); |
85 | log::info!("trait_solve_query({})", goal.value.goal.display(db)); | 86 | log::info!("trait_solve_query({})", goal.value.goal.display(db)); |
86 | 87 | ||
@@ -95,13 +96,12 @@ pub(crate) fn trait_solve_query( | |||
95 | } | 96 | } |
96 | } | 97 | } |
97 | 98 | ||
98 | let canonical = goal.to_chalk(db).cast(&Interner); | 99 | let canonical = goal.cast(&Interner); |
99 | 100 | ||
100 | // We currently don't deal with universes (I think / hope they're not yet | 101 | // We currently don't deal with universes (I think / hope they're not yet |
101 | // relevant for our use cases?) | 102 | // relevant for our use cases?) |
102 | let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; | 103 | let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; |
103 | let solution = solve(db, krate, &u_canonical); | 104 | solve(db, krate, &u_canonical) |
104 | solution.map(|solution| solution_from_chalk(db, solution)) | ||
105 | } | 105 | } |
106 | 106 | ||
107 | fn solve( | 107 | fn solve( |
@@ -169,26 +169,6 @@ fn is_chalk_print() -> bool { | |||
169 | std::env::var("CHALK_PRINT").is_ok() | 169 | std::env::var("CHALK_PRINT").is_ok() |
170 | } | 170 | } |
171 | 171 | ||
172 | fn solution_from_chalk( | ||
173 | db: &dyn HirDatabase, | ||
174 | solution: chalk_solve::Solution<Interner>, | ||
175 | ) -> Solution { | ||
176 | match solution { | ||
177 | chalk_solve::Solution::Unique(constr_subst) => { | ||
178 | Solution::Unique(from_chalk(db, constr_subst)) | ||
179 | } | ||
180 | chalk_solve::Solution::Ambig(chalk_solve::Guidance::Definite(subst)) => { | ||
181 | Solution::Ambig(Guidance::Definite(from_chalk(db, subst))) | ||
182 | } | ||
183 | chalk_solve::Solution::Ambig(chalk_solve::Guidance::Suggested(subst)) => { | ||
184 | Solution::Ambig(Guidance::Suggested(from_chalk(db, subst))) | ||
185 | } | ||
186 | chalk_solve::Solution::Ambig(chalk_solve::Guidance::Unknown) => { | ||
187 | Solution::Ambig(Guidance::Unknown) | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | |||
192 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | 172 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
193 | pub enum FnTrait { | 173 | pub enum FnTrait { |
194 | FnOnce, | 174 | FnOnce, |