3413: Update chalk for RawId removal, Ty interners r=flodiebold a=lnicola

r? @flodiebold 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2020-03-02 22:17:59 +00:00 committed by GitHub
commit ce5684216e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 31 deletions

13
Cargo.lock generated
View file

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

View file

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

View file

@ -18,7 +18,7 @@ use crate::{
}; };
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct Interner {} pub struct Interner;
impl chalk_ir::interner::Interner for Interner { impl chalk_ir::interner::Interner for Interner {
type InternedType = Box<chalk_ir::TyData<Self>>; type InternedType = Box<chalk_ir::TyData<Self>>;
@ -27,6 +27,7 @@ impl chalk_ir::interner::Interner for Interner {
type InternedGoal = Arc<GoalData<Self>>; type InternedGoal = Arc<GoalData<Self>>;
type InternedGoals = Vec<Goal<Self>>; type InternedGoals = Vec<Goal<Self>>;
type InternedSubstitution = Vec<Parameter<Self>>; type InternedSubstitution = Vec<Parameter<Self>>;
type Identifier = lalrpop_intern::InternedString;
type DefId = InternId; type DefId = InternId;
// FIXME: implement these // FIXME: implement these
@ -58,7 +59,7 @@ impl chalk_ir::interner::Interner for Interner {
None 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) Box::new(ty)
} }
@ -121,7 +122,7 @@ pub type StructId = chalk_ir::StructId<Interner>;
pub type StructDatum = chalk_rust_ir::StructDatum<Interner>; pub type StructDatum = chalk_rust_ir::StructDatum<Interner>;
pub type ImplId = chalk_ir::ImplId<Interner>; pub type ImplId = chalk_ir::ImplId<Interner>;
pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>; pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>;
pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId; pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>;
pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>; pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>;
pub(super) trait ToChalk { pub(super) trait ToChalk {
@ -144,12 +145,12 @@ impl ToChalk for Ty {
Ty::Apply(apply_ty) => { Ty::Apply(apply_ty) => {
let name = apply_ty.ctor.to_chalk(db); let name = apply_ty.ctor.to_chalk(db);
let substitution = apply_ty.parameters.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) => { Ty::Projection(proj_ty) => {
let associated_ty_id = proj_ty.associated_ty.to_chalk(db); let associated_ty_id = proj_ty.associated_ty.to_chalk(db);
let substitution = proj_ty.parameters.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) => { Ty::Placeholder(id) => {
let interned_id = db.intern_type_param_id(id); let interned_id = db.intern_type_param_id(id);
@ -157,9 +158,9 @@ impl ToChalk for Ty {
ui: UniverseIndex::ROOT, ui: UniverseIndex::ROOT,
idx: interned_id.as_intern_id().as_usize(), 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::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
Ty::Dyn(predicates) => { Ty::Dyn(predicates) => {
let where_clauses = predicates let where_clauses = predicates
@ -169,12 +170,12 @@ impl ToChalk for Ty {
.map(|p| p.to_chalk(db)) .map(|p| p.to_chalk(db))
.collect(); .collect();
let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) }; 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 => { Ty::Opaque(_) | Ty::Unknown => {
let substitution = chalk_ir::Substitution::empty(); let substitution = chalk_ir::Substitution::empty();
let name = TypeName::Error; let name = TypeName::Error;
chalk_ir::ApplicationTy { name, substitution }.cast().intern() chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner)
} }
} }
} }
@ -611,6 +612,9 @@ where
_ => None, _ => None,
} }
} }
fn interner(&self) -> &Interner {
&Interner
}
} }
pub(crate) fn associated_ty_data_query( pub(crate) fn associated_ty_data_query(
@ -822,13 +826,6 @@ fn type_alias_associated_ty_value(
Arc::new(value) Arc::new(value)
} }
fn id_from_chalk<T: InternKey>(chalk_id: chalk_ir::RawId) -> T {
T::from_intern_id(InternId::from(chalk_id.index))
}
fn id_to_chalk<T: InternKey>(salsa_id: T) -> chalk_ir::RawId {
chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() }
}
impl From<StructId> for crate::TypeCtorId { impl From<StructId> for crate::TypeCtorId {
fn from(struct_id: StructId) -> Self { fn from(struct_id: StructId) -> Self {
InternKey::from_intern_id(struct_id.0) InternKey::from_intern_id(struct_id.0)
@ -853,14 +850,14 @@ impl From<crate::traits::GlobalImplId> for ImplId {
} }
} }
impl From<chalk_rust_ir::AssociatedTyValueId> for crate::traits::AssocTyValueId { impl From<chalk_rust_ir::AssociatedTyValueId<Interner>> for crate::traits::AssocTyValueId {
fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { fn from(id: chalk_rust_ir::AssociatedTyValueId<Interner>) -> Self {
id_from_chalk(id.0) Self::from_intern_id(id.0)
} }
} }
impl From<crate::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId { impl From<crate::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId<Interner> {
fn from(assoc_ty_value_id: crate::traits::AssocTyValueId) -> Self { fn from(assoc_ty_value_id: crate::traits::AssocTyValueId) -> Self {
chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id)) chalk_rust_ir::AssociatedTyValueId(assoc_ty_value_id.as_intern_id())
} }
} }