diff options
author | Florian Diebold <[email protected]> | 2019-07-09 20:34:23 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-07-14 17:22:47 +0100 |
commit | 0a20770f46138909d91a1db371ed7371caf704e1 (patch) | |
tree | 91e0ce8cdaaf93abf97c08f69e99a8047f57f545 /crates/ra_hir/src | |
parent | c4e2e36e4c3cdaf5243a4d481221804e2d71bc8e (diff) |
Some renamings for clarity
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/db.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/autoderef.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 4 |
8 files changed, 27 insertions, 24 deletions
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 | }; |
29 | pub(crate) use traits::{Environment, InEnvironment, Obligation, ProjectionPredicate}; | 29 | pub(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..36189e20d 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; | |||
29 | use super::{ | 29 | use 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 | }; |
35 | use crate::{ | 35 | use crate::{ |
36 | adt::VariantDef, | 36 | adt::VariantDef, |
@@ -170,7 +170,7 @@ 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 | method_resolutions: FxHashMap<ExprId, Function>, |
176 | field_resolutions: FxHashMap<ExprId, StructField>, | 176 | field_resolutions: FxHashMap<ExprId, StructField>, |
@@ -345,7 +345,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
345 | let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone()); | 345 | let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone()); |
346 | let canonicalized = self.canonicalizer().canonicalize_obligation(in_env); | 346 | let canonicalized = self.canonicalizer().canonicalize_obligation(in_env); |
347 | let solution = | 347 | let solution = |
348 | self.db.solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); | 348 | self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); |
349 | 349 | ||
350 | match solution { | 350 | match solution { |
351 | Some(Solution::Unique(substs)) => { | 351 | Some(Solution::Unique(substs)) => { |
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 | ||
320 | pub(crate) fn trait_env(db: &impl HirDatabase, resolver: &Resolver) -> Arc<super::Environment> { | 320 | pub(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; | |||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use rustc_hash::FxHashMap; | 8 | use rustc_hash::FxHashMap; |
9 | 9 | ||
10 | use super::{autoderef, lower, Canonical, Environment, InEnvironment, TraitRef}; | 10 | use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; |
11 | use crate::{ | 11 | use 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. |
284 | fn generic_implements_goal( | 284 | fn 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..7dccd93be 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 | ||
30 | pub(crate) fn solver_query(_db: &impl HirDatabase, _krate: Crate) -> Arc<Mutex<Solver>> { | 30 | pub(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,7 +60,7 @@ 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_with_fuel(&context, goal, Some(1000)); |
66 | debug!("solve({:?}) => {:?}", goal, solution); | 66 | debug!("solve({:?}) => {:?}", goal, solution); |
@@ -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)] |
76 | pub struct Environment { | 76 | pub 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)] |
82 | pub struct InEnvironment<T> { | 82 | pub 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 | ||
87 | impl<T> InEnvironment<T> { | 87 | impl<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. |
120 | pub(crate) fn solve_query( | 120 | pub(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..1b9ae8dc1 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 | ||
269 | impl ToChalk for Arc<super::Environment> { | 269 | impl 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> { |
@@ -289,7 +289,7 @@ impl ToChalk for Arc<super::Environment> { | |||
289 | fn from_chalk( | 289 | fn from_chalk( |
290 | _db: &impl HirDatabase, | 290 | _db: &impl HirDatabase, |
291 | _env: Arc<chalk_ir::Environment>, | 291 | _env: Arc<chalk_ir::Environment>, |
292 | ) -> Arc<super::Environment> { | 292 | ) -> Arc<super::TraitEnvironment> { |
293 | unimplemented!() | 293 | unimplemented!() |
294 | } | 294 | } |
295 | } | 295 | } |