Update chalk for Ty interners

This commit is contained in:
Laurențiu Nicola 2020-03-03 00:01:16 +02:00
parent 807a56bebf
commit f60cf882a8
3 changed files with 20 additions and 17 deletions

12
Cargo.lock generated
View File

@ -129,7 +129,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "chalk-derive"
version = "0.1.0"
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1725e6bcf1881ad6c8304941e2282f33d32d1d#ea1725e6bcf1881ad6c8304941e2282f33d32d1d"
source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
dependencies = [
"proc-macro2",
"quote",
@ -139,7 +139,7 @@ dependencies = [
[[package]]
name = "chalk-engine"
version = "0.9.0"
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1725e6bcf1881ad6c8304941e2282f33d32d1d#ea1725e6bcf1881ad6c8304941e2282f33d32d1d"
source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
dependencies = [
"chalk-macros",
"rustc-hash",
@ -148,7 +148,7 @@ dependencies = [
[[package]]
name = "chalk-ir"
version = "0.1.0"
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1725e6bcf1881ad6c8304941e2282f33d32d1d#ea1725e6bcf1881ad6c8304941e2282f33d32d1d"
source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
dependencies = [
"chalk-derive",
"chalk-engine",
@ -158,7 +158,7 @@ dependencies = [
[[package]]
name = "chalk-macros"
version = "0.1.1"
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1725e6bcf1881ad6c8304941e2282f33d32d1d#ea1725e6bcf1881ad6c8304941e2282f33d32d1d"
source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
dependencies = [
"lazy_static",
]
@ -166,7 +166,7 @@ dependencies = [
[[package]]
name = "chalk-rust-ir"
version = "0.1.0"
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1725e6bcf1881ad6c8304941e2282f33d32d1d#ea1725e6bcf1881ad6c8304941e2282f33d32d1d"
source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
dependencies = [
"chalk-derive",
"chalk-engine",
@ -177,7 +177,7 @@ dependencies = [
[[package]]
name = "chalk-solve"
version = "0.1.0"
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1725e6bcf1881ad6c8304941e2282f33d32d1d#ea1725e6bcf1881ad6c8304941e2282f33d32d1d"
source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
dependencies = [
"chalk-derive",
"chalk-engine",

View File

@ -21,9 +21,9 @@ ra_prof = { path = "../ra_prof" }
ra_syntax = { path = "../ra_syntax" }
test_utils = { path = "../test_utils" }
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1725e6bcf1881ad6c8304941e2282f33d32d1d" }
chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1725e6bcf1881ad6c8304941e2282f33d32d1d" }
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1725e6bcf1881ad6c8304941e2282f33d32d1d" }
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
lalrpop-intern = "0.15.1"

View File

@ -18,7 +18,7 @@
};
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct Interner {}
pub struct Interner;
impl chalk_ir::interner::Interner for Interner {
type InternedType = Box<chalk_ir::TyData<Self>>;
@ -59,7 +59,7 @@ fn debug_alias(
None
}
fn intern_ty(ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> {
fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> {
Box::new(ty)
}
@ -145,12 +145,12 @@ fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty<Interner> {
Ty::Apply(apply_ty) => {
let name = apply_ty.ctor.to_chalk(db);
let substitution = apply_ty.parameters.to_chalk(db);
chalk_ir::ApplicationTy { name, substitution }.cast().intern()
chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner)
}
Ty::Projection(proj_ty) => {
let associated_ty_id = proj_ty.associated_ty.to_chalk(db);
let substitution = proj_ty.parameters.to_chalk(db);
chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern()
chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern(&Interner)
}
Ty::Placeholder(id) => {
let interned_id = db.intern_type_param_id(id);
@ -158,9 +158,9 @@ fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty<Interner> {
ui: UniverseIndex::ROOT,
idx: interned_id.as_intern_id().as_usize(),
}
.to_ty::<Interner>()
.to_ty::<Interner>(&Interner)
}
Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(),
Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(&Interner),
Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
Ty::Dyn(predicates) => {
let where_clauses = predicates
@ -170,12 +170,12 @@ fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty<Interner> {
.map(|p| p.to_chalk(db))
.collect();
let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) };
chalk_ir::TyData::Dyn(bounded_ty).intern()
chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner)
}
Ty::Opaque(_) | Ty::Unknown => {
let substitution = chalk_ir::Substitution::empty();
let name = TypeName::Error;
chalk_ir::ApplicationTy { name, substitution }.cast().intern()
chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner)
}
}
}
@ -612,6 +612,9 @@ fn as_struct_id(&self, id: &TypeName<Interner>) -> Option<StructId> {
_ => None,
}
}
fn interner(&self) -> &Interner {
&Interner
}
}
pub(crate) fn associated_ty_data_query(