From 0a20770f46138909d91a1db371ed7371caf704e1 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 9 Jul 2019 21:34:23 +0200 Subject: Some renamings for clarity --- crates/ra_hir/src/db.rs | 8 ++++---- crates/ra_hir/src/ty.rs | 2 +- crates/ra_hir/src/ty/autoderef.rs | 2 +- crates/ra_hir/src/ty/infer.rs | 8 ++++---- crates/ra_hir/src/ty/lower.rs | 7 +++++-- crates/ra_hir/src/ty/method_resolution.rs | 6 +++--- crates/ra_hir/src/ty/traits.rs | 14 +++++++------- crates/ra_hir/src/ty/traits/chalk.rs | 4 ++-- 8 files changed, 27 insertions(+), 24 deletions(-) (limited to 'crates/ra_hir/src') 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 { /// because Chalk does its own internal caching, the solver is wrapped in a /// Mutex and the query is marked volatile, to make sure the cached state is /// thrown away when input facts change. - #[salsa::invoke(crate::ty::traits::solver_query)] + #[salsa::invoke(crate::ty::traits::trait_solver_query)] #[salsa::volatile] - fn solver(&self, krate: Crate) -> Arc>; + fn trait_solver(&self, krate: Crate) -> Arc>; #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc; @@ -213,8 +213,8 @@ pub trait HirDatabase: DefDatabase + AstDatabase { #[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)] fn impl_datum(&self, krate: Crate, impl_id: chalk_ir::ImplId) -> Arc; - #[salsa::invoke(crate::ty::traits::solve_query)] - fn solve( + #[salsa::invoke(crate::ty::traits::trait_solve_query)] + fn trait_solve( &self, krate: Crate, goal: crate::ty::Canonical>, 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::{ callable_item_sig, generic_defaults_query, generic_predicates_query, type_for_def, type_for_field, TypableDef, }; -pub(crate) use traits::{Environment, InEnvironment, Obligation, ProjectionPredicate}; +pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; /// A type constructor or type name: this might be something like the primitive /// 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( let canonical = super::Canonical { num_vars: 1 + ty.num_vars, value: in_env }; - let solution = db.solve(krate, canonical)?; + let solution = db.trait_solve(krate, canonical)?; match &solution { 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; use super::{ autoderef, lower, method_resolution, op, primitive, traits::{Guidance, Obligation, ProjectionPredicate, Solution}, - ApplicationTy, CallableDef, Environment, InEnvironment, ProjectionTy, Substs, TraitRef, Ty, - TypableDef, TypeCtor, + ApplicationTy, CallableDef, InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, + Ty, TypableDef, TypeCtor, }; use crate::{ adt::VariantDef, @@ -170,7 +170,7 @@ struct InferenceContext<'a, D: HirDatabase> { body: Arc, resolver: Resolver, var_unification_table: InPlaceUnificationTable, - trait_env: Arc, + trait_env: Arc, obligations: Vec, method_resolutions: FxHashMap, field_resolutions: FxHashMap, @@ -345,7 +345,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone()); let canonicalized = self.canonicalizer().canonicalize_obligation(in_env); let solution = - self.db.solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); + self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); match solution { 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 { Ty::from_hir(db, &resolver, type_ref) } -pub(crate) fn trait_env(db: &impl HirDatabase, resolver: &Resolver) -> Arc { +pub(crate) fn trait_env( + db: &impl HirDatabase, + resolver: &Resolver, +) -> Arc { let predicates = resolver .where_predicates_in_scope() .map(|pred| { @@ -326,7 +329,7 @@ pub(crate) fn trait_env(db: &impl HirDatabase, resolver: &Resolver) -> Arc>(); - Arc::new(super::Environment { predicates }) + Arc::new(super::TraitEnvironment { predicates }) } /// 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; use arrayvec::ArrayVec; use rustc_hash::FxHashMap; -use super::{autoderef, lower, Canonical, Environment, InEnvironment, TraitRef}; +use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; use crate::{ generics::HasGenericParams, impl_block::{ImplBlock, ImplId, ImplItem}, @@ -214,7 +214,7 @@ fn iterate_trait_method_candidates( if name.map_or(true, |name| data.name() == name) && data.has_self_param() { if !known_implemented { let goal = generic_implements_goal(db, env.clone(), t, ty.clone()); - if db.solve(krate, goal).is_none() { + if db.trait_solve(krate, goal).is_none() { continue 'traits; } } @@ -283,7 +283,7 @@ impl Ty { /// for all other parameters, to query Chalk with it. fn generic_implements_goal( db: &impl HirDatabase, - env: Arc, + env: Arc, trait_: Trait, self_ty: Canonical, ) -> Canonical> { 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> { krate: Crate, } -pub(crate) fn solver_query(_db: &impl HirDatabase, _krate: Crate) -> Arc> { +pub(crate) fn trait_solver_query(_db: &impl HirDatabase, _krate: Crate) -> Arc> { // krate parameter is just so we cache a unique solver per crate let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE }; debug!("Creating new solver for crate {:?}", _krate); @@ -60,7 +60,7 @@ fn solve( goal: &chalk_ir::UCanonical>, ) -> Option { let context = ChalkContext { db, krate }; - let solver = db.solver(krate); + let solver = db.trait_solver(krate); debug!("solve goal: {:?}", goal); let solution = solver.lock().solve_with_fuel(&context, goal, Some(1000)); debug!("solve({:?}) => {:?}", goal, solution); @@ -73,19 +73,19 @@ fn solve( /// ``` /// we assume that `T: Default`. #[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub struct Environment { +pub struct TraitEnvironment { pub predicates: Vec, } /// Something (usually a goal), along with an environment. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct InEnvironment { - pub environment: Arc, + pub environment: Arc, pub value: T, } impl InEnvironment { - pub fn new(environment: Arc, value: T) -> InEnvironment { + pub fn new(environment: Arc, value: T) -> InEnvironment { InEnvironment { environment, value } } } @@ -117,12 +117,12 @@ pub struct ProjectionPredicate { } /// Solve a trait goal using Chalk. -pub(crate) fn solve_query( +pub(crate) fn trait_solve_query( db: &impl HirDatabase, krate: Crate, trait_ref: Canonical>, ) -> Option { - let _p = profile("solve_query"); + let _p = profile("trait_solve_query"); let canonical = trait_ref.to_chalk(db).cast(); // We currently don't deal with universes (I think / hope they're not yet // 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 } } -impl ToChalk for Arc { +impl ToChalk for Arc { type Chalk = Arc; fn to_chalk(self, db: &impl HirDatabase) -> Arc { @@ -289,7 +289,7 @@ impl ToChalk for Arc { fn from_chalk( _db: &impl HirDatabase, _env: Arc, - ) -> Arc { + ) -> Arc { unimplemented!() } } -- cgit v1.2.3