aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/Cargo.toml6
-rw-r--r--crates/ra_hir/src/db.rs8
-rw-r--r--crates/ra_hir/src/ty.rs2
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs2
-rw-r--r--crates/ra_hir/src/ty/infer.rs63
-rw-r--r--crates/ra_hir/src/ty/lower.rs7
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs6
-rw-r--r--crates/ra_hir/src/ty/traits.rs16
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs24
-rw-r--r--crates/ra_ide_api/src/change.rs2
10 files changed, 55 insertions, 81 deletions
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index de2c2dbec..833956ce8 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -21,9 +21,9 @@ tt = { path = "../ra_tt", package = "ra_tt" }
21test_utils = { path = "../test_utils" } 21test_utils = { path = "../test_utils" }
22ra_prof = { path = "../ra_prof" } 22ra_prof = { path = "../ra_prof" }
23 23
24chalk-solve = { git = "https://github.com/flodiebold/chalk.git", branch = "fuel" } 24chalk-solve = { git = "https://github.com/rust-lang/chalk.git" }
25chalk-rust-ir = { git = "https://github.com/flodiebold/chalk.git", branch = "fuel" } 25chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git" }
26chalk-ir = { git = "https://github.com/flodiebold/chalk.git", branch = "fuel" } 26chalk-ir = { git = "https://github.com/rust-lang/chalk.git" }
27lalrpop-intern = "0.15.1" 27lalrpop-intern = "0.15.1"
28 28
29[dev-dependencies] 29[dev-dependencies]
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index b0c027631..040c782e6 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -189,9 +189,9 @@ pub trait HirDatabase: DefDatabase + AstDatabase {
189 /// because Chalk does its own internal caching, the solver is wrapped in a 189 /// because Chalk does its own internal caching, the solver is wrapped in a
190 /// Mutex and the query is marked volatile, to make sure the cached state is 190 /// Mutex and the query is marked volatile, to make sure the cached state is
191 /// thrown away when input facts change. 191 /// thrown away when input facts change.
192 #[salsa::invoke(crate::ty::traits::solver_query)] 192 #[salsa::invoke(crate::ty::traits::trait_solver_query)]
193 #[salsa::volatile] 193 #[salsa::volatile]
194 fn solver(&self, krate: Crate) -> Arc<Mutex<crate::ty::traits::Solver>>; 194 fn trait_solver(&self, krate: Crate) -> Arc<Mutex<crate::ty::traits::Solver>>;
195 195
196 #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] 196 #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)]
197 fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; 197 fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>;
@@ -213,8 +213,8 @@ pub trait HirDatabase: DefDatabase + AstDatabase {
213 #[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)] 213 #[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)]
214 fn impl_datum(&self, krate: Crate, impl_id: chalk_ir::ImplId) -> Arc<chalk_rust_ir::ImplDatum>; 214 fn impl_datum(&self, krate: Crate, impl_id: chalk_ir::ImplId) -> Arc<chalk_rust_ir::ImplDatum>;
215 215
216 #[salsa::invoke(crate::ty::traits::solve_query)] 216 #[salsa::invoke(crate::ty::traits::trait_solve_query)]
217 fn solve( 217 fn trait_solve(
218 &self, 218 &self,
219 krate: Crate, 219 krate: Crate,
220 goal: crate::ty::Canonical<crate::ty::InEnvironment<crate::ty::Obligation>>, 220 goal: crate::ty::Canonical<crate::ty::InEnvironment<crate::ty::Obligation>>,
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 9accffcbc..4cf714f5d 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -26,7 +26,7 @@ pub(crate) use lower::{
26 callable_item_sig, generic_defaults_query, generic_predicates_query, type_for_def, 26 callable_item_sig, generic_defaults_query, generic_predicates_query, type_for_def,
27 type_for_field, TypableDef, 27 type_for_field, TypableDef,
28}; 28};
29pub(crate) use traits::{Environment, InEnvironment, Obligation, ProjectionPredicate}; 29pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
30 30
31/// A type constructor or type name: this might be something like the primitive 31/// A type constructor or type name: this might be something like the primitive
32/// type `bool`, a struct like `Vec`, or things like function pointers or 32/// type `bool`, a struct like `Vec`, or things like function pointers or
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs
index c26513871..2535d4ae7 100644
--- a/crates/ra_hir/src/ty/autoderef.rs
+++ b/crates/ra_hir/src/ty/autoderef.rs
@@ -68,7 +68,7 @@ fn deref_by_trait(
68 68
69 let canonical = super::Canonical { num_vars: 1 + ty.num_vars, value: in_env }; 69 let canonical = super::Canonical { num_vars: 1 + ty.num_vars, value: in_env };
70 70
71 let solution = db.solve(krate, canonical)?; 71 let solution = db.trait_solve(krate, canonical)?;
72 72
73 match &solution { 73 match &solution {
74 Solution::Unique(vars) => { 74 Solution::Unique(vars) => {
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 5ad4f73ec..0e030576d 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -29,8 +29,8 @@ use test_utils::tested_by;
29use super::{ 29use super::{
30 autoderef, lower, method_resolution, op, primitive, 30 autoderef, lower, method_resolution, op, primitive,
31 traits::{Guidance, Obligation, ProjectionPredicate, Solution}, 31 traits::{Guidance, Obligation, ProjectionPredicate, Solution},
32 ApplicationTy, CallableDef, Environment, InEnvironment, ProjectionTy, Substs, TraitRef, Ty, 32 ApplicationTy, CallableDef, InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef,
33 TypableDef, TypeCtor, 33 Ty, TypableDef, TypeCtor,
34}; 34};
35use crate::{ 35use crate::{
36 adt::VariantDef, 36 adt::VariantDef,
@@ -107,7 +107,7 @@ impl Default for BindingMode {
107} 107}
108 108
109/// The result of type inference: A mapping from expressions and patterns to types. 109/// The result of type inference: A mapping from expressions and patterns to types.
110#[derive(Clone, PartialEq, Eq, Debug)] 110#[derive(Clone, PartialEq, Eq, Debug, Default)]
111pub struct InferenceResult { 111pub struct InferenceResult {
112 /// For each method call expr, records the function it resolves to. 112 /// For each method call expr, records the function it resolves to.
113 method_resolutions: FxHashMap<ExprId, Function>, 113 method_resolutions: FxHashMap<ExprId, Function>,
@@ -170,15 +170,9 @@ struct InferenceContext<'a, D: HirDatabase> {
170 body: Arc<Body>, 170 body: Arc<Body>,
171 resolver: Resolver, 171 resolver: Resolver,
172 var_unification_table: InPlaceUnificationTable<TypeVarId>, 172 var_unification_table: InPlaceUnificationTable<TypeVarId>,
173 trait_env: Arc<Environment>, 173 trait_env: Arc<TraitEnvironment>,
174 obligations: Vec<Obligation>, 174 obligations: Vec<Obligation>,
175 method_resolutions: FxHashMap<ExprId, Function>, 175 result: InferenceResult,
176 field_resolutions: FxHashMap<ExprId, StructField>,
177 variant_resolutions: FxHashMap<ExprId, VariantDef>,
178 assoc_resolutions: FxHashMap<ExprOrPatId, ImplItem>,
179 type_of_expr: ArenaMap<ExprId, Ty>,
180 type_of_pat: ArenaMap<PatId, Ty>,
181 diagnostics: Vec<InferenceDiagnostic>,
182 /// The return type of the function being inferred. 176 /// The return type of the function being inferred.
183 return_ty: Ty, 177 return_ty: Ty,
184} 178}
@@ -186,13 +180,7 @@ struct InferenceContext<'a, D: HirDatabase> {
186impl<'a, D: HirDatabase> InferenceContext<'a, D> { 180impl<'a, D: HirDatabase> InferenceContext<'a, D> {
187 fn new(db: &'a D, body: Arc<Body>, resolver: Resolver) -> Self { 181 fn new(db: &'a D, body: Arc<Body>, resolver: Resolver) -> Self {
188 InferenceContext { 182 InferenceContext {
189 method_resolutions: FxHashMap::default(), 183 result: InferenceResult::default(),
190 field_resolutions: FxHashMap::default(),
191 variant_resolutions: FxHashMap::default(),
192 assoc_resolutions: FxHashMap::default(),
193 type_of_expr: ArenaMap::default(),
194 type_of_pat: ArenaMap::default(),
195 diagnostics: Vec::default(),
196 var_unification_table: InPlaceUnificationTable::new(), 184 var_unification_table: InPlaceUnificationTable::new(),
197 obligations: Vec::default(), 185 obligations: Vec::default(),
198 return_ty: Ty::Unknown, // set in collect_fn_signature 186 return_ty: Ty::Unknown, // set in collect_fn_signature
@@ -205,50 +193,45 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
205 193
206 fn resolve_all(mut self) -> InferenceResult { 194 fn resolve_all(mut self) -> InferenceResult {
207 // FIXME resolve obligations as well (use Guidance if necessary) 195 // FIXME resolve obligations as well (use Guidance if necessary)
196 let mut result = mem::replace(&mut self.result, InferenceResult::default());
208 let mut tv_stack = Vec::new(); 197 let mut tv_stack = Vec::new();
209 let mut expr_types = mem::replace(&mut self.type_of_expr, ArenaMap::default()); 198 for ty in result.type_of_expr.values_mut() {
210 for ty in expr_types.values_mut() {
211 let resolved = self.resolve_ty_completely(&mut tv_stack, mem::replace(ty, Ty::Unknown)); 199 let resolved = self.resolve_ty_completely(&mut tv_stack, mem::replace(ty, Ty::Unknown));
212 *ty = resolved; 200 *ty = resolved;
213 } 201 }
214 let mut pat_types = mem::replace(&mut self.type_of_pat, ArenaMap::default()); 202 for ty in result.type_of_pat.values_mut() {
215 for ty in pat_types.values_mut() {
216 let resolved = self.resolve_ty_completely(&mut tv_stack, mem::replace(ty, Ty::Unknown)); 203 let resolved = self.resolve_ty_completely(&mut tv_stack, mem::replace(ty, Ty::Unknown));
217 *ty = resolved; 204 *ty = resolved;
218 } 205 }
219 InferenceResult { 206 result
220 method_resolutions: self.method_resolutions,
221 field_resolutions: self.field_resolutions,
222 variant_resolutions: self.variant_resolutions,
223 assoc_resolutions: self.assoc_resolutions,
224 type_of_expr: expr_types,
225 type_of_pat: pat_types,
226 diagnostics: self.diagnostics,
227 }
228 } 207 }
229 208
230 fn write_expr_ty(&mut self, expr: ExprId, ty: Ty) { 209 fn write_expr_ty(&mut self, expr: ExprId, ty: Ty) {
231 self.type_of_expr.insert(expr, ty); 210 self.result.type_of_expr.insert(expr, ty);
232 } 211 }
233 212
234 fn write_method_resolution(&mut self, expr: ExprId, func: Function) { 213 fn write_method_resolution(&mut self, expr: ExprId, func: Function) {
235 self.method_resolutions.insert(expr, func); 214 self.result.method_resolutions.insert(expr, func);
236 } 215 }
237 216
238 fn write_field_resolution(&mut self, expr: ExprId, field: StructField) { 217 fn write_field_resolution(&mut self, expr: ExprId, field: StructField) {
239 self.field_resolutions.insert(expr, field); 218 self.result.field_resolutions.insert(expr, field);
240 } 219 }
241 220
242 fn write_variant_resolution(&mut self, expr: ExprId, variant: VariantDef) { 221 fn write_variant_resolution(&mut self, expr: ExprId, variant: VariantDef) {
243 self.variant_resolutions.insert(expr, variant); 222 self.result.variant_resolutions.insert(expr, variant);
244 } 223 }
245 224
246 fn write_assoc_resolution(&mut self, id: ExprOrPatId, item: ImplItem) { 225 fn write_assoc_resolution(&mut self, id: ExprOrPatId, item: ImplItem) {
247 self.assoc_resolutions.insert(id, item); 226 self.result.assoc_resolutions.insert(id, item);
248 } 227 }
249 228
250 fn write_pat_ty(&mut self, pat: PatId, ty: Ty) { 229 fn write_pat_ty(&mut self, pat: PatId, ty: Ty) {
251 self.type_of_pat.insert(pat, ty); 230 self.result.type_of_pat.insert(pat, ty);
231 }
232
233 fn push_diagnostic(&mut self, diagnostic: InferenceDiagnostic) {
234 self.result.diagnostics.push(diagnostic);
252 } 235 }
253 236
254 fn make_ty(&mut self, type_ref: &TypeRef) -> Ty { 237 fn make_ty(&mut self, type_ref: &TypeRef) -> Ty {
@@ -345,7 +328,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
345 let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone()); 328 let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone());
346 let canonicalized = self.canonicalizer().canonicalize_obligation(in_env); 329 let canonicalized = self.canonicalizer().canonicalize_obligation(in_env);
347 let solution = 330 let solution =
348 self.db.solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); 331 self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone());
349 332
350 match solution { 333 match solution {
351 Some(Solution::Unique(substs)) => { 334 Some(Solution::Unique(substs)) => {
@@ -565,7 +548,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
565 Some(ty) 548 Some(ty)
566 } 549 }
567 Resolution::LocalBinding(pat) => { 550 Resolution::LocalBinding(pat) => {
568 let ty = self.type_of_pat.get(pat)?.clone(); 551 let ty = self.result.type_of_pat.get(pat)?.clone();
569 let ty = self.resolve_ty_as_possible(&mut vec![], ty); 552 let ty = self.resolve_ty_as_possible(&mut vec![], ty);
570 Some(ty) 553 Some(ty)
571 } 554 }
@@ -1090,7 +1073,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1090 .and_then(|it| match it.field(self.db, &field.name) { 1073 .and_then(|it| match it.field(self.db, &field.name) {
1091 Some(field) => Some(field), 1074 Some(field) => Some(field),
1092 None => { 1075 None => {
1093 self.diagnostics.push(InferenceDiagnostic::NoSuchField { 1076 self.push_diagnostic(InferenceDiagnostic::NoSuchField {
1094 expr: tgt_expr, 1077 expr: tgt_expr,
1095 field: field_idx, 1078 field: field_idx,
1096 }); 1079 });
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index ca47d6e96..894ba0695 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -317,7 +317,10 @@ pub(crate) fn type_for_field(db: &impl HirDatabase, field: StructField) -> Ty {
317 Ty::from_hir(db, &resolver, type_ref) 317 Ty::from_hir(db, &resolver, type_ref)
318} 318}
319 319
320pub(crate) fn trait_env(db: &impl HirDatabase, resolver: &Resolver) -> Arc<super::Environment> { 320pub(crate) fn trait_env(
321 db: &impl HirDatabase,
322 resolver: &Resolver,
323) -> Arc<super::TraitEnvironment> {
321 let predicates = resolver 324 let predicates = resolver
322 .where_predicates_in_scope() 325 .where_predicates_in_scope()
323 .map(|pred| { 326 .map(|pred| {
@@ -326,7 +329,7 @@ pub(crate) fn trait_env(db: &impl HirDatabase, resolver: &Resolver) -> Arc<super
326 }) 329 })
327 .collect::<Vec<_>>(); 330 .collect::<Vec<_>>();
328 331
329 Arc::new(super::Environment { predicates }) 332 Arc::new(super::TraitEnvironment { predicates })
330} 333}
331 334
332/// Resolve the where clause(s) of an item with generics. 335/// Resolve the where clause(s) of an item with generics.
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index 353820436..d421bf9ef 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -7,7 +7,7 @@ use std::sync::Arc;
7use arrayvec::ArrayVec; 7use arrayvec::ArrayVec;
8use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9 9
10use super::{autoderef, lower, Canonical, Environment, InEnvironment, TraitRef}; 10use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef};
11use crate::{ 11use crate::{
12 generics::HasGenericParams, 12 generics::HasGenericParams,
13 impl_block::{ImplBlock, ImplId, ImplItem}, 13 impl_block::{ImplBlock, ImplId, ImplItem},
@@ -214,7 +214,7 @@ fn iterate_trait_method_candidates<T>(
214 if name.map_or(true, |name| data.name() == name) && data.has_self_param() { 214 if name.map_or(true, |name| data.name() == name) && data.has_self_param() {
215 if !known_implemented { 215 if !known_implemented {
216 let goal = generic_implements_goal(db, env.clone(), t, ty.clone()); 216 let goal = generic_implements_goal(db, env.clone(), t, ty.clone());
217 if db.solve(krate, goal).is_none() { 217 if db.trait_solve(krate, goal).is_none() {
218 continue 'traits; 218 continue 'traits;
219 } 219 }
220 } 220 }
@@ -283,7 +283,7 @@ impl Ty {
283/// for all other parameters, to query Chalk with it. 283/// for all other parameters, to query Chalk with it.
284fn generic_implements_goal( 284fn generic_implements_goal(
285 db: &impl HirDatabase, 285 db: &impl HirDatabase,
286 env: Arc<Environment>, 286 env: Arc<TraitEnvironment>,
287 trait_: Trait, 287 trait_: Trait,
288 self_ty: Canonical<Ty>, 288 self_ty: Canonical<Ty>,
289) -> Canonical<InEnvironment<super::Obligation>> { 289) -> Canonical<InEnvironment<super::Obligation>> {
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs
index 2817c9e71..0769e6e17 100644
--- a/crates/ra_hir/src/ty/traits.rs
+++ b/crates/ra_hir/src/ty/traits.rs
@@ -27,7 +27,7 @@ struct ChalkContext<'a, DB> {
27 krate: Crate, 27 krate: Crate,
28} 28}
29 29
30pub(crate) fn solver_query(_db: &impl HirDatabase, _krate: Crate) -> Arc<Mutex<Solver>> { 30pub(crate) fn trait_solver_query(_db: &impl HirDatabase, _krate: Crate) -> Arc<Mutex<Solver>> {
31 // krate parameter is just so we cache a unique solver per crate 31 // krate parameter is just so we cache a unique solver per crate
32 let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE }; 32 let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE };
33 debug!("Creating new solver for crate {:?}", _krate); 33 debug!("Creating new solver for crate {:?}", _krate);
@@ -60,9 +60,9 @@ fn solve(
60 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal>>, 60 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal>>,
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.solver(krate); 63 let solver = db.trait_solver(krate);
64 debug!("solve goal: {:?}", goal); 64 debug!("solve goal: {:?}", goal);
65 let solution = solver.lock().solve_with_fuel(&context, goal, Some(1000)); 65 let solution = solver.lock().solve(&context, goal);
66 debug!("solve({:?}) => {:?}", goal, solution); 66 debug!("solve({:?}) => {:?}", goal, solution);
67 solution 67 solution
68} 68}
@@ -73,19 +73,19 @@ fn solve(
73/// ``` 73/// ```
74/// we assume that `T: Default`. 74/// we assume that `T: Default`.
75#[derive(Clone, Debug, PartialEq, Eq, Hash)] 75#[derive(Clone, Debug, PartialEq, Eq, Hash)]
76pub struct Environment { 76pub struct TraitEnvironment {
77 pub predicates: Vec<GenericPredicate>, 77 pub predicates: Vec<GenericPredicate>,
78} 78}
79 79
80/// Something (usually a goal), along with an environment. 80/// Something (usually a goal), along with an environment.
81#[derive(Clone, Debug, PartialEq, Eq, Hash)] 81#[derive(Clone, Debug, PartialEq, Eq, Hash)]
82pub struct InEnvironment<T> { 82pub struct InEnvironment<T> {
83 pub environment: Arc<Environment>, 83 pub environment: Arc<TraitEnvironment>,
84 pub value: T, 84 pub value: T,
85} 85}
86 86
87impl<T> InEnvironment<T> { 87impl<T> InEnvironment<T> {
88 pub fn new(environment: Arc<Environment>, value: T) -> InEnvironment<T> { 88 pub fn new(environment: Arc<TraitEnvironment>, value: T) -> InEnvironment<T> {
89 InEnvironment { environment, value } 89 InEnvironment { environment, value }
90 } 90 }
91} 91}
@@ -117,12 +117,12 @@ pub struct ProjectionPredicate {
117} 117}
118 118
119/// Solve a trait goal using Chalk. 119/// Solve a trait goal using Chalk.
120pub(crate) fn solve_query( 120pub(crate) fn trait_solve_query(
121 db: &impl HirDatabase, 121 db: &impl HirDatabase,
122 krate: Crate, 122 krate: Crate,
123 trait_ref: Canonical<InEnvironment<Obligation>>, 123 trait_ref: Canonical<InEnvironment<Obligation>>,
124) -> Option<Solution> { 124) -> Option<Solution> {
125 let _p = profile("solve_query"); 125 let _p = profile("trait_solve_query");
126 let canonical = trait_ref.to_chalk(db).cast(); 126 let canonical = trait_ref.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?)
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 2df4dd13f..9e7ae0724 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -266,7 +266,7 @@ where
266 } 266 }
267} 267}
268 268
269impl ToChalk for Arc<super::Environment> { 269impl ToChalk for Arc<super::TraitEnvironment> {
270 type Chalk = Arc<chalk_ir::Environment>; 270 type Chalk = Arc<chalk_ir::Environment>;
271 271
272 fn to_chalk(self, db: &impl HirDatabase) -> Arc<chalk_ir::Environment> { 272 fn to_chalk(self, db: &impl HirDatabase) -> Arc<chalk_ir::Environment> {
@@ -276,11 +276,6 @@ impl ToChalk for Arc<super::Environment> {
276 // for env, we just ignore errors 276 // for env, we just ignore errors
277 continue; 277 continue;
278 } 278 }
279 if let GenericPredicate::Implemented(trait_ref) = pred {
280 if blacklisted_trait(db, trait_ref.trait_) {
281 continue;
282 }
283 }
284 clauses.push(pred.clone().to_chalk(db).cast()); 279 clauses.push(pred.clone().to_chalk(db).cast());
285 } 280 }
286 chalk_ir::Environment::new().add_clauses(clauses) 281 chalk_ir::Environment::new().add_clauses(clauses)
@@ -289,7 +284,7 @@ impl ToChalk for Arc<super::Environment> {
289 fn from_chalk( 284 fn from_chalk(
290 _db: &impl HirDatabase, 285 _db: &impl HirDatabase,
291 _env: Arc<chalk_ir::Environment>, 286 _env: Arc<chalk_ir::Environment>,
292 ) -> Arc<super::Environment> { 287 ) -> Arc<super::TraitEnvironment> {
293 unimplemented!() 288 unimplemented!()
294 } 289 }
295} 290}
@@ -322,10 +317,10 @@ fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T> {
322 } 317 }
323} 318}
324 319
325fn blacklisted_trait(db: &impl HirDatabase, trait_: Trait) -> bool { 320fn is_non_enumerable_trait(db: &impl HirDatabase, trait_: Trait) -> bool {
326 let name = trait_.name(db).unwrap_or_else(crate::Name::missing).to_string(); 321 let name = trait_.name(db).unwrap_or_else(crate::Name::missing).to_string();
327 match &*name { 322 match &*name {
328 "Send" | "Sync" | "Sized" | "Fn" | "FnMut" | "FnOnce" => true, 323 "Sized" => true,
329 _ => false, 324 _ => false,
330 } 325 }
331} 326}
@@ -343,11 +338,6 @@ fn convert_where_clauses(
343 // anyway), otherwise Chalk can easily get into slow situations 338 // anyway), otherwise Chalk can easily get into slow situations
344 return vec![pred.clone().subst(substs).to_chalk(db)]; 339 return vec![pred.clone().subst(substs).to_chalk(db)];
345 } 340 }
346 if let GenericPredicate::Implemented(trait_ref) = pred {
347 if blacklisted_trait(db, trait_ref.trait_) {
348 continue;
349 }
350 }
351 result.push(pred.clone().subst(substs).to_chalk(db)); 341 result.push(pred.clone().subst(substs).to_chalk(db));
352 } 342 }
353 result 343 result
@@ -375,10 +365,6 @@ where
375 return Vec::new(); 365 return Vec::new();
376 } 366 }
377 let trait_: Trait = from_chalk(self.db, trait_id); 367 let trait_: Trait = from_chalk(self.db, trait_id);
378 let blacklisted = blacklisted_trait(self.db, trait_);
379 if blacklisted {
380 return Vec::new();
381 }
382 let result: Vec<_> = self 368 let result: Vec<_> = self
383 .db 369 .db
384 .impls_for_trait(self.krate, trait_) 370 .impls_for_trait(self.krate, trait_)
@@ -460,6 +446,7 @@ pub(crate) fn trait_datum_query(
460 associated_ty_ids: Vec::new(), 446 associated_ty_ids: Vec::new(),
461 where_clauses: Vec::new(), 447 where_clauses: Vec::new(),
462 flags: chalk_rust_ir::TraitFlags { 448 flags: chalk_rust_ir::TraitFlags {
449 non_enumerable: false,
463 auto: false, 450 auto: false,
464 marker: false, 451 marker: false,
465 upstream: true, 452 upstream: true,
@@ -476,6 +463,7 @@ pub(crate) fn trait_datum_query(
476 let flags = chalk_rust_ir::TraitFlags { 463 let flags = chalk_rust_ir::TraitFlags {
477 auto: trait_.is_auto(db), 464 auto: trait_.is_auto(db),
478 upstream: trait_.module(db).krate(db) != Some(krate), 465 upstream: trait_.module(db).krate(db) != Some(krate),
466 non_enumerable: is_non_enumerable_trait(db, trait_),
479 // FIXME set these flags correctly 467 // FIXME set these flags correctly
480 marker: false, 468 marker: false,
481 fundamental: false, 469 fundamental: false,
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs
index 1ba818197..147d2b21d 100644
--- a/crates/ra_ide_api/src/change.rs
+++ b/crates/ra_ide_api/src/change.rs
@@ -302,7 +302,7 @@ impl RootDatabase {
302 hir::db::TraitDatumQuery 302 hir::db::TraitDatumQuery
303 hir::db::StructDatumQuery 303 hir::db::StructDatumQuery
304 hir::db::ImplDatumQuery 304 hir::db::ImplDatumQuery
305 hir::db::SolveQuery 305 hir::db::TraitSolveQuery
306 ]; 306 ];
307 acc.sort_by_key(|it| std::cmp::Reverse(it.1)); 307 acc.sort_by_key(|it| std::cmp::Reverse(it.1));
308 acc 308 acc