Upgrade Chalk again

This commit is contained in:
Florian Diebold 2019-11-16 13:21:51 +01:00
parent 351c29d859
commit ee190388ab
5 changed files with 65 additions and 54 deletions

55
Cargo.lock generated
View file

@ -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)" = "<none>"
"checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "<none>"
"checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "<none>"
"checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "<none>"
"checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "<none>"
"checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=102eba3659fc26a2451ed845f9ca4ceb8f79c22d)" = "<none>"
"checksum chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "<none>"
"checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "<none>"
"checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "<none>"
"checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "<none>"
"checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "<none>"
"checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=a88cad7f0a69e05ba8f40b74c58a1c229c1b2478)" = "<none>"
"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"

View file

@ -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]

View file

@ -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<chalk_rust_ir::AssociatedTyDatum>;
fn associated_ty_data(
&self,
id: chalk_ir::TypeId,
) -> Arc<chalk_rust_ir::AssociatedTyDatum<chalk_ir::family::ChalkIr>>;
#[salsa::invoke(crate::ty::traits::chalk::trait_datum_query)]
fn trait_datum(
&self,
krate: Crate,
trait_id: chalk_ir::TraitId,
) -> Arc<chalk_rust_ir::TraitDatum>;
) -> Arc<chalk_rust_ir::TraitDatum<chalk_ir::family::ChalkIr>>;
#[salsa::invoke(crate::ty::traits::chalk::struct_datum_query)]
fn struct_datum(
&self,
krate: Crate,
struct_id: chalk_ir::StructId,
) -> Arc<chalk_rust_ir::StructDatum>;
) -> Arc<chalk_rust_ir::StructDatum<chalk_ir::family::ChalkIr>>;
#[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)]
fn impl_datum(&self, krate: Crate, impl_id: chalk_ir::ImplId) -> Arc<chalk_rust_ir::ImplDatum>;
fn impl_datum(
&self,
krate: Crate,
impl_id: chalk_ir::ImplId,
) -> Arc<chalk_rust_ir::ImplDatum<chalk_ir::family::ChalkIr>>;
#[salsa::invoke(crate::ty::traits::chalk::associated_ty_value_query)]
fn associated_ty_value(
&self,
krate: Crate,
id: chalk_rust_ir::AssociatedTyValueId,
) -> Arc<chalk_rust_ir::AssociatedTyValue>;
) -> Arc<chalk_rust_ir::AssociatedTyValue<chalk_ir::family::ChalkIr>>;
#[salsa::invoke(crate::ty::traits::trait_solve_query)]
fn trait_solve(

View file

@ -17,7 +17,7 @@ pub(crate) mod chalk;
#[derive(Debug, Clone)]
pub struct TraitSolver {
krate: Crate,
inner: Arc<Mutex<chalk_solve::Solver>>,
inner: Arc<Mutex<chalk_solve::Solver<ChalkIr>>>,
}
/// We need eq for salsa
@ -34,7 +34,7 @@ impl TraitSolver {
&self,
db: &impl HirDatabase,
goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<ChalkIr>>>,
) -> Option<chalk_solve::Solution> {
) -> Option<chalk_solve::Solution<ChalkIr>> {
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<ChalkIr>,
) -> Solution {
let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<ChalkIr>>| {
let value = subst
.value

View file

@ -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<ChalkIr> for ChalkContext<'a, DB>
where
DB: HirDatabase,
{
fn associated_ty_data(&self, id: TypeId) -> Arc<AssociatedTyDatum> {
fn associated_ty_data(&self, id: TypeId) -> Arc<AssociatedTyDatum<ChalkIr>> {
self.db.associated_ty_data(id)
}
fn trait_datum(&self, trait_id: chalk_ir::TraitId) -> Arc<TraitDatum> {
fn trait_datum(&self, trait_id: chalk_ir::TraitId) -> Arc<TraitDatum<ChalkIr>> {
self.db.trait_datum(self.krate, trait_id)
}
fn struct_datum(&self, struct_id: chalk_ir::StructId) -> Arc<StructDatum> {
fn struct_datum(&self, struct_id: chalk_ir::StructId) -> Arc<StructDatum<ChalkIr>> {
self.db.struct_datum(self.krate, struct_id)
}
fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> {
fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum<ChalkIr>> {
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<AssociatedTyValue> {
) -> Arc<AssociatedTyValue<ChalkIr>> {
self.db.associated_ty_value(self.krate, id)
}
fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<ChalkIr>> {
@ -502,7 +502,7 @@ where
pub(crate) fn associated_ty_data_query(
db: &impl HirDatabase,
id: TypeId,
) -> Arc<AssociatedTyDatum> {
) -> Arc<AssociatedTyDatum<ChalkIr>> {
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<TraitDatum> {
) -> Arc<TraitDatum<ChalkIr>> {
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<StructDatum> {
) -> Arc<StructDatum<ChalkIr>> {
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<ImplDatum> {
) -> Arc<ImplDatum<ChalkIr>> {
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<Arc<ImplDatum>> {
) -> Option<Arc<ImplDatum<ChalkIr>>> {
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<ImplDatum> {
fn invalid_impl_datum() -> Arc<ImplDatum<ChalkIr>> {
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<Arc<ImplDatum>> {
) -> Option<Arc<ImplDatum<ChalkIr>>> {
// for some closure |X, Y| -> Z:
// impl<T, U, V> Fn<(T, U)> for closure<fn(T, U) -> 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<chalk_rust_ir::AssociatedTyValue> {
) -> Arc<chalk_rust_ir::AssociatedTyValue<ChalkIr>> {
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<AssociatedTyValue> {
) -> Arc<AssociatedTyValue<ChalkIr>> {
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<AssociatedTyValue> {
) -> Arc<AssociatedTyValue<ChalkIr>> {
let impl_id = Impl::ClosureFnTraitImpl(data.clone()).to_chalk(db);
let num_args: u16 = match &data.def.body(db)[data.expr] {