diff --git a/Cargo.lock b/Cargo.lock index 88fb66a56d..16fbe75020 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,7 +123,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chalk-derive" version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d#102eba3659fc26a2451ed845f9ca4ceb8f79c22d" +source = "git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478#a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -133,9 +133,9 @@ dependencies = [ [[package]] name = "chalk-engine" version = "0.9.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d#102eba3659fc26a2451ed845f9ca4ceb8f79c22d" +source = "git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478#a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" dependencies = [ - "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", + "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "stacker 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -143,18 +143,18 @@ dependencies = [ [[package]] name = "chalk-ir" version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d#102eba3659fc26a2451ed845f9ca4ceb8f79c22d" +source = "git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478#a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" dependencies = [ - "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", + "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "chalk-macros" version = "0.1.1" -source = "git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d#102eba3659fc26a2451ed845f9ca4ceb8f79c22d" +source = "git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478#a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -162,23 +162,24 @@ dependencies = [ [[package]] name = "chalk-rust-ir" version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d#102eba3659fc26a2451ed845f9ca4ceb8f79c22d" +source = "git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478#a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" dependencies = [ - "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", + "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", ] [[package]] name = "chalk-solve" version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d#102eba3659fc26a2451ed845f9ca4ceb8f79c22d" +source = "git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478#a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" dependencies = [ - "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", + "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,9 +1017,9 @@ name = "ra_hir" version = "0.1.0" dependencies = [ "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", - "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)", + "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", + "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)", "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1873,12 +1874,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d" "checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "" -"checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "" -"checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "" -"checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "" -"checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "" -"checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "" +"checksum chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "" +"checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "" +"checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "" +"checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "" +"checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "" +"checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 57b7da1a89..20f6e3649b 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -23,9 +23,9 @@ hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } test_utils = { path = "../test_utils" } ra_prof = { path = "../ra_prof" } -chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "102eba3659fc26a2451ed845f9ca4ceb8f79c22d" } -chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "102eba3659fc26a2451ed845f9ca4ceb8f79c22d" } -chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "102eba3659fc26a2451ed845f9ca4ceb8f79c22d" } +chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" } +chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" } +chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "a88cad7f0a69e05ba8f40b74c58a1c229c1b2478" } lalrpop-intern = "0.15.1" [dev-dependencies] diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index d9fad0ae2b..d75d71d665 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 99dbab99ea..45f7254380 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 81a378bac7..9bf93981a0 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] {