From ee190388ab9068167f665bec39edd4546336ee3d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 16 Nov 2019 13:21:51 +0100 Subject: Upgrade Chalk again --- crates/ra_hir/src/db.rs | 17 ++++++++++++----- crates/ra_hir/src/ty/traits.rs | 9 ++++++--- crates/ra_hir/src/ty/traits/chalk.rs | 32 ++++++++++++++++---------------- 3 files changed, 34 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 d9fad0ae2..d75d71d66 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -125,31 +125,38 @@ pub trait HirDatabase: DefDatabase + AstDatabase { fn intern_assoc_ty_value(&self, assoc_ty_value: AssocTyValue) -> ids::AssocTyValueId; #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] - fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc; + fn associated_ty_data( + &self, + id: chalk_ir::TypeId, + ) -> Arc>; #[salsa::invoke(crate::ty::traits::chalk::trait_datum_query)] fn trait_datum( &self, krate: Crate, trait_id: chalk_ir::TraitId, - ) -> Arc; + ) -> Arc>; #[salsa::invoke(crate::ty::traits::chalk::struct_datum_query)] fn struct_datum( &self, krate: Crate, struct_id: chalk_ir::StructId, - ) -> Arc; + ) -> Arc>; #[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)] - fn impl_datum(&self, krate: Crate, impl_id: chalk_ir::ImplId) -> Arc; + fn impl_datum( + &self, + krate: Crate, + impl_id: chalk_ir::ImplId, + ) -> Arc>; #[salsa::invoke(crate::ty::traits::chalk::associated_ty_value_query)] fn associated_ty_value( &self, krate: Crate, id: chalk_rust_ir::AssociatedTyValueId, - ) -> Arc; + ) -> Arc>; #[salsa::invoke(crate::ty::traits::trait_solve_query)] fn trait_solve( diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 99dbab99e..45f725438 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs @@ -17,7 +17,7 @@ pub(crate) mod chalk; #[derive(Debug, Clone)] pub struct TraitSolver { krate: Crate, - inner: Arc>, + inner: Arc>>, } /// We need eq for salsa @@ -34,7 +34,7 @@ impl TraitSolver { &self, db: &impl HirDatabase, goal: &chalk_ir::UCanonical>>, - ) -> Option { + ) -> Option> { let context = ChalkContext { db, krate: self.krate }; debug!("solve goal: {:?}", goal); let mut solver = match self.inner.lock() { @@ -196,7 +196,10 @@ pub(crate) fn trait_solve_query( solution.map(|solution| solution_from_chalk(db, solution)) } -fn solution_from_chalk(db: &impl HirDatabase, solution: chalk_solve::Solution) -> Solution { +fn solution_from_chalk( + db: &impl HirDatabase, + solution: chalk_solve::Solution, +) -> Solution { let convert_subst = |subst: chalk_ir::Canonical>| { let value = subst .value diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 81a378bac..9bf93981a 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs @@ -418,20 +418,20 @@ fn convert_where_clauses( result } -impl<'a, DB> chalk_solve::RustIrDatabase for ChalkContext<'a, DB> +impl<'a, DB> chalk_solve::RustIrDatabase for ChalkContext<'a, DB> where DB: HirDatabase, { - fn associated_ty_data(&self, id: TypeId) -> Arc { + fn associated_ty_data(&self, id: TypeId) -> Arc> { self.db.associated_ty_data(id) } - fn trait_datum(&self, trait_id: chalk_ir::TraitId) -> Arc { + fn trait_datum(&self, trait_id: chalk_ir::TraitId) -> Arc> { self.db.trait_datum(self.krate, trait_id) } - fn struct_datum(&self, struct_id: chalk_ir::StructId) -> Arc { + fn struct_datum(&self, struct_id: chalk_ir::StructId) -> Arc> { self.db.struct_datum(self.krate, struct_id) } - fn impl_datum(&self, impl_id: ImplId) -> Arc { + fn impl_datum(&self, impl_id: ImplId) -> Arc> { self.db.impl_datum(self.krate, impl_id) } fn impls_for_trait( @@ -484,7 +484,7 @@ where fn associated_ty_value( &self, id: chalk_rust_ir::AssociatedTyValueId, - ) -> Arc { + ) -> Arc> { self.db.associated_ty_value(self.krate, id) } fn custom_clauses(&self) -> Vec> { @@ -502,7 +502,7 @@ where pub(crate) fn associated_ty_data_query( db: &impl HirDatabase, id: TypeId, -) -> Arc { +) -> Arc> { debug!("associated_ty_data {:?}", id); let type_alias: TypeAlias = from_chalk(db, id); let trait_ = match type_alias.container(db) { @@ -528,7 +528,7 @@ pub(crate) fn trait_datum_query( db: &impl HirDatabase, krate: Crate, trait_id: chalk_ir::TraitId, -) -> Arc { +) -> Arc> { debug!("trait_datum {:?}", trait_id); if trait_id == UNKNOWN_TRAIT { let trait_datum_bound = chalk_rust_ir::TraitDatumBound { where_clauses: Vec::new() }; @@ -585,7 +585,7 @@ pub(crate) fn struct_datum_query( db: &impl HirDatabase, krate: Crate, struct_id: chalk_ir::StructId, -) -> Arc { +) -> Arc> { debug!("struct_datum {:?}", struct_id); let type_ctor: TypeCtor = from_chalk(db, struct_id); debug!("struct {:?} = {:?}", struct_id, type_ctor); @@ -617,7 +617,7 @@ pub(crate) fn impl_datum_query( db: &impl HirDatabase, krate: Crate, impl_id: ImplId, -) -> Arc { +) -> Arc> { let _p = ra_prof::profile("impl_datum"); debug!("impl_datum {:?}", impl_id); let impl_: Impl = from_chalk(db, impl_id); @@ -633,7 +633,7 @@ fn impl_block_datum( krate: Crate, impl_id: ImplId, impl_block: ImplBlock, -) -> Option> { +) -> Option>> { let generic_params = impl_block.generic_params(db); let bound_vars = Substs::bound_vars(&generic_params); let trait_ref = impl_block.target_trait_ref(db)?.subst(&bound_vars); @@ -684,7 +684,7 @@ fn impl_block_datum( Some(Arc::new(impl_datum)) } -fn invalid_impl_datum() -> Arc { +fn invalid_impl_datum() -> Arc> { let trait_ref = chalk_ir::TraitRef { trait_id: UNKNOWN_TRAIT, parameters: vec![chalk_ir::TyData::BoundVar(0).cast().intern().cast()], @@ -703,7 +703,7 @@ fn closure_fn_trait_impl_datum( db: &impl HirDatabase, krate: Crate, data: super::ClosureFnTraitImplData, -) -> Option> { +) -> Option>> { // for some closure |X, Y| -> Z: // impl Fn<(T, U)> for closure V> { Output = V } @@ -760,7 +760,7 @@ pub(crate) fn associated_ty_value_query( db: &impl HirDatabase, krate: Crate, id: chalk_rust_ir::AssociatedTyValueId, -) -> Arc { +) -> Arc> { let data: AssocTyValue = from_chalk(db, id); match data { AssocTyValue::TypeAlias(type_alias) => { @@ -776,7 +776,7 @@ fn type_alias_associated_ty_value( db: &impl HirDatabase, _krate: Crate, type_alias: TypeAlias, -) -> Arc { +) -> Arc> { let impl_block = type_alias.impl_block(db).expect("assoc ty value should be in impl"); let impl_id = Impl::ImplBlock(impl_block).to_chalk(db); let trait_ = impl_block @@ -802,7 +802,7 @@ fn closure_fn_trait_output_assoc_ty_value( db: &impl HirDatabase, krate: Crate, data: super::ClosureFnTraitImplData, -) -> Arc { +) -> Arc> { let impl_id = Impl::ClosureFnTraitImpl(data.clone()).to_chalk(db); let num_args: u16 = match &data.def.body(db)[data.expr] { -- cgit v1.2.3