Upgrade Chalk

Chalk newly added TypeName::Never and Array; I implemented the conversion for
Never, but not Array since that expects a const argument.
This commit is contained in:
Florian Diebold 2020-05-27 21:05:21 +02:00
parent 94889b6472
commit c8a4bb1445
6 changed files with 71 additions and 86 deletions

46
Cargo.lock generated
View file

@ -111,10 +111,18 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "chalk-base"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "chalk-derive" name = "chalk-derive"
version = "0.10.1-dev" version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -125,51 +133,32 @@ dependencies = [
[[package]] [[package]]
name = "chalk-engine" name = "chalk-engine"
version = "0.10.1-dev" version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb"
dependencies = [ dependencies = [
"chalk-macros", "chalk-base",
"chalk-derive",
"chalk-ir",
"rustc-hash", "rustc-hash",
] ]
[[package]] [[package]]
name = "chalk-ir" name = "chalk-ir"
version = "0.10.1-dev" version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb"
dependencies = [ dependencies = [
"chalk-base",
"chalk-derive", "chalk-derive",
"chalk-engine",
"chalk-macros",
]
[[package]]
name = "chalk-macros"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"lazy_static",
]
[[package]]
name = "chalk-rust-ir"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-ir",
"chalk-macros",
] ]
[[package]] [[package]]
name = "chalk-solve" name = "chalk-solve"
version = "0.10.1-dev" version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb"
dependencies = [ dependencies = [
"chalk-base",
"chalk-derive", "chalk-derive",
"chalk-engine", "chalk-engine",
"chalk-ir", "chalk-ir",
"chalk-macros",
"chalk-rust-ir",
"ena", "ena",
"itertools", "itertools",
"petgraph", "petgraph",
@ -1036,7 +1025,6 @@ version = "0.1.0"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"chalk-ir", "chalk-ir",
"chalk-rust-ir",
"chalk-solve", "chalk-solve",
"ena", "ena",
"insta", "insta",

View file

@ -22,8 +22,6 @@ opt-level = 0
opt-level = 0 opt-level = 0
[profile.release.package.chalk-derive] [profile.release.package.chalk-derive]
opt-level = 0 opt-level = 0
[profile.release.package.chalk-macros]
opt-level = 0
[profile.release.package.salsa-macros] [profile.release.package.salsa-macros]
opt-level = 0 opt-level = 0
[profile.release.package.xtask] [profile.release.package.xtask]

View file

@ -27,9 +27,8 @@ test_utils = { path = "../test_utils" }
scoped-tls = "1" scoped-tls = "1"
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "eaab84b394007d1bed15f5470409a6ea02900a96" } chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "5a3b871ca17529ab5aa5787594fabad1634936cb" }
chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "eaab84b394007d1bed15f5470409a6ea02900a96" } chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "5a3b871ca17529ab5aa5787594fabad1634936cb" }
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "eaab84b394007d1bed15f5470409a6ea02900a96" }
[dev-dependencies] [dev-dependencies]
insta = "0.16.0" insta = "0.16.0"

View file

@ -4,6 +4,7 @@ use std::sync::Arc;
use log::debug; use log::debug;
use chalk_ir::{fold::shift::Shift, GenericArg, TypeName}; use chalk_ir::{fold::shift::Shift, GenericArg, TypeName};
use chalk_solve::rust_ir::{self, WellKnownTrait};
use hir_def::{ use hir_def::{
lang_item::{lang_attr, LangItemTarget}, lang_item::{lang_attr, LangItemTarget},
@ -16,7 +17,6 @@ use crate::{
db::HirDatabase, display::HirDisplay, method_resolution::TyFingerprint, utils::generics, db::HirDatabase, display::HirDisplay, method_resolution::TyFingerprint, utils::generics,
CallableDef, DebruijnIndex, GenericPredicate, Substs, Ty, TypeCtor, CallableDef, DebruijnIndex, GenericPredicate, Substs, Ty, TypeCtor,
}; };
use chalk_rust_ir::WellKnownTrait;
use mapping::{convert_where_clauses, generic_predicate_to_inline_bound, make_binders}; use mapping::{convert_where_clauses, generic_predicate_to_inline_bound, make_binders};
pub use self::interner::*; pub use self::interner::*;
@ -55,7 +55,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
fn fn_def_datum( fn fn_def_datum(
&self, &self,
fn_def_id: chalk_ir::FnDefId<Interner>, fn_def_id: chalk_ir::FnDefId<Interner>,
) -> Arc<chalk_rust_ir::FnDefDatum<Interner>> { ) -> Arc<rust_ir::FnDefDatum<Interner>> {
self.db.fn_def_datum(self.krate, fn_def_id) self.db.fn_def_datum(self.krate, fn_def_id)
} }
@ -112,7 +112,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
} }
fn well_known_trait_id( fn well_known_trait_id(
&self, &self,
well_known_trait: chalk_rust_ir::WellKnownTrait, well_known_trait: rust_ir::WellKnownTrait,
) -> Option<chalk_ir::TraitId<Interner>> { ) -> Option<chalk_ir::TraitId<Interner>> {
let lang_attr = lang_attr_from_well_known_trait(well_known_trait); let lang_attr = lang_attr_from_well_known_trait(well_known_trait);
let lang_items = self.db.crate_lang_items(self.krate); let lang_items = self.db.crate_lang_items(self.krate);
@ -133,13 +133,13 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
fn opaque_ty_data( fn opaque_ty_data(
&self, &self,
_id: chalk_ir::OpaqueTyId<Interner>, _id: chalk_ir::OpaqueTyId<Interner>,
) -> Arc<chalk_rust_ir::OpaqueTyDatum<Interner>> { ) -> Arc<rust_ir::OpaqueTyDatum<Interner>> {
unimplemented!() unimplemented!()
} }
fn force_impl_for( fn force_impl_for(
&self, &self,
_well_known: chalk_rust_ir::WellKnownTrait, _well_known: rust_ir::WellKnownTrait,
_ty: &chalk_ir::TyData<Interner>, _ty: &chalk_ir::TyData<Interner>,
) -> Option<bool> { ) -> Option<bool> {
// this method is mostly for rustc // this method is mostly for rustc
@ -150,6 +150,10 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
// FIXME: implement actual object safety // FIXME: implement actual object safety
true true
} }
fn hidden_opaque_type(&self, _id: chalk_ir::OpaqueTyId<Interner>) -> chalk_ir::Ty<Interner> {
Ty::Unknown.to_chalk(self.db)
}
} }
pub(crate) fn program_clauses_for_chalk_env_query( pub(crate) fn program_clauses_for_chalk_env_query(
@ -188,7 +192,7 @@ pub(crate) fn associated_ty_data_query(
.collect(); .collect();
let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars); let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars);
let bound_data = chalk_rust_ir::AssociatedTyDatumBound { bounds, where_clauses }; let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses };
let datum = AssociatedTyDatum { let datum = AssociatedTyDatum {
trait_id: trait_.to_chalk(db), trait_id: trait_.to_chalk(db),
id, id,
@ -209,7 +213,7 @@ pub(crate) fn trait_datum_query(
debug!("trait {:?} = {:?}", trait_id, trait_data.name); debug!("trait {:?} = {:?}", trait_id, trait_data.name);
let generic_params = generics(db.upcast(), trait_.into()); let generic_params = generics(db.upcast(), trait_.into());
let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST);
let flags = chalk_rust_ir::TraitFlags { let flags = rust_ir::TraitFlags {
auto: trait_data.auto, auto: trait_data.auto,
upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate != krate, upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate != krate,
non_enumerable: true, non_enumerable: true,
@ -221,7 +225,7 @@ pub(crate) fn trait_datum_query(
let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars);
let associated_ty_ids = let associated_ty_ids =
trait_data.associated_types().map(|type_alias| type_alias.to_chalk(db)).collect(); trait_data.associated_types().map(|type_alias| type_alias.to_chalk(db)).collect();
let trait_datum_bound = chalk_rust_ir::TraitDatumBound { where_clauses }; let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses };
let well_known = let well_known =
lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name)); lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name));
let trait_datum = TraitDatum { let trait_datum = TraitDatum {
@ -271,12 +275,12 @@ pub(crate) fn struct_datum_query(
convert_where_clauses(db, generic_def, &bound_vars) convert_where_clauses(db, generic_def, &bound_vars)
}) })
.unwrap_or_else(Vec::new); .unwrap_or_else(Vec::new);
let flags = chalk_rust_ir::AdtFlags { let flags = rust_ir::AdtFlags {
upstream, upstream,
// FIXME set fundamental flag correctly // FIXME set fundamental flag correctly
fundamental: false, fundamental: false,
}; };
let struct_datum_bound = chalk_rust_ir::AdtDatumBound { let struct_datum_bound = rust_ir::AdtDatumBound {
fields: Vec::new(), // FIXME add fields (only relevant for auto traits) fields: Vec::new(), // FIXME add fields (only relevant for auto traits)
where_clauses, where_clauses,
}; };
@ -316,9 +320,9 @@ fn impl_def_datum(
let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST);
let trait_ = trait_ref.trait_; let trait_ = trait_ref.trait_;
let impl_type = if impl_id.lookup(db.upcast()).container.module(db.upcast()).krate == krate { let impl_type = if impl_id.lookup(db.upcast()).container.module(db.upcast()).krate == krate {
chalk_rust_ir::ImplType::Local rust_ir::ImplType::Local
} else { } else {
chalk_rust_ir::ImplType::External rust_ir::ImplType::External
}; };
let where_clauses = convert_where_clauses(db, impl_id.into(), &bound_vars); let where_clauses = convert_where_clauses(db, impl_id.into(), &bound_vars);
let negative = impl_data.is_negative; let negative = impl_data.is_negative;
@ -331,13 +335,9 @@ fn impl_def_datum(
); );
let trait_ref = trait_ref.to_chalk(db); let trait_ref = trait_ref.to_chalk(db);
let polarity = if negative { let polarity = if negative { rust_ir::Polarity::Negative } else { rust_ir::Polarity::Positive };
chalk_rust_ir::Polarity::Negative
} else {
chalk_rust_ir::Polarity::Positive
};
let impl_datum_bound = chalk_rust_ir::ImplDatumBound { trait_ref, where_clauses }; let impl_datum_bound = rust_ir::ImplDatumBound { trait_ref, where_clauses };
let trait_data = db.trait_data(trait_); let trait_data = db.trait_data(trait_);
let associated_ty_value_ids = impl_data let associated_ty_value_ids = impl_data
.items .items
@ -395,8 +395,8 @@ fn type_alias_associated_ty_value(
.associated_type_by_name(&type_alias_data.name) .associated_type_by_name(&type_alias_data.name)
.expect("assoc ty value should not exist"); // validated when building the impl data as well .expect("assoc ty value should not exist"); // validated when building the impl data as well
let ty = db.ty(type_alias.into()); let ty = db.ty(type_alias.into());
let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) }; let value_bound = rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
let value = chalk_rust_ir::AssociatedTyValue { let value = rust_ir::AssociatedTyValue {
impl_id: Impl::ImplDef(impl_id).to_chalk(db), impl_id: Impl::ImplDef(impl_id).to_chalk(db),
associated_ty_id: assoc_ty.to_chalk(db), associated_ty_id: assoc_ty.to_chalk(db),
value: make_binders(value_bound, ty.num_binders), value: make_binders(value_bound, ty.num_binders),
@ -414,7 +414,7 @@ pub(crate) fn fn_def_datum_query(
let sig = db.callable_item_signature(callable_def); let sig = db.callable_item_signature(callable_def);
let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST);
let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars); let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars);
let bound = chalk_rust_ir::FnDefDatumBound { let bound = rust_ir::FnDefDatumBound {
// Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway // Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
argument_types: sig.value.params().iter().map(|ty| ty.clone().to_chalk(db)).collect(), argument_types: sig.value.params().iter().map(|ty| ty.clone().to_chalk(db)).collect(),
return_type: sig.value.ret().clone().to_chalk(db), return_type: sig.value.ret().clone().to_chalk(db),
@ -460,14 +460,14 @@ impl From<crate::traits::GlobalImplId> for ImplId {
} }
} }
impl From<chalk_rust_ir::AssociatedTyValueId<Interner>> for crate::traits::AssocTyValueId { impl From<rust_ir::AssociatedTyValueId<Interner>> for crate::traits::AssocTyValueId {
fn from(id: chalk_rust_ir::AssociatedTyValueId<Interner>) -> Self { fn from(id: rust_ir::AssociatedTyValueId<Interner>) -> Self {
Self::from_intern_id(id.0) Self::from_intern_id(id.0)
} }
} }
impl From<crate::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId<Interner> { impl From<crate::traits::AssocTyValueId> for 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(assoc_ty_value_id.as_intern_id()) rust_ir::AssociatedTyValueId(assoc_ty_value_id.as_intern_id())
} }
} }

View file

@ -11,17 +11,17 @@ use std::{fmt, sync::Arc};
pub struct Interner; pub struct Interner;
pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>; pub type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>;
pub type TraitId = chalk_ir::TraitId<Interner>; pub type TraitId = chalk_ir::TraitId<Interner>;
pub type TraitDatum = chalk_rust_ir::TraitDatum<Interner>; pub type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>;
pub type AdtId = chalk_ir::AdtId<Interner>; pub type AdtId = chalk_ir::AdtId<Interner>;
pub type StructDatum = chalk_rust_ir::AdtDatum<Interner>; pub type StructDatum = chalk_solve::rust_ir::AdtDatum<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_solve::rust_ir::ImplDatum<Interner>;
pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>; pub type AssociatedTyValueId = chalk_solve::rust_ir::AssociatedTyValueId<Interner>;
pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>; pub type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Interner>;
pub type FnDefId = chalk_ir::FnDefId<Interner>; pub type FnDefId = chalk_ir::FnDefId<Interner>;
pub type FnDefDatum = chalk_rust_ir::FnDefDatum<Interner>; pub type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>;
impl chalk_ir::interner::Interner for Interner { impl chalk_ir::interner::Interner for Interner {
type InternedType = Box<chalk_ir::TyData<Self>>; // FIXME use Arc? type InternedType = Box<chalk_ir::TyData<Self>>; // FIXME use Arc?

View file

@ -7,6 +7,7 @@ use chalk_ir::{
cast::Cast, fold::shift::Shift, interner::HasInterner, PlaceholderIndex, Scalar, TypeName, cast::Cast, fold::shift::Shift, interner::HasInterner, PlaceholderIndex, Scalar, TypeName,
UniverseIndex, UniverseIndex,
}; };
use chalk_solve::rust_ir;
use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId}; use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId};
use ra_db::salsa::InternKey; use ra_db::salsa::InternKey;
@ -106,7 +107,7 @@ impl ToChalk for Ty {
}) })
} }
chalk_ir::TyData::BoundVar(idx) => Ty::Bound(idx), chalk_ir::TyData::BoundVar(idx) => Ty::Bound(idx),
chalk_ir::TyData::InferenceVar(_iv) => Ty::Unknown, chalk_ir::TyData::InferenceVar(_iv, _kind) => Ty::Unknown,
chalk_ir::TyData::Dyn(where_clauses) => { chalk_ir::TyData::Dyn(where_clauses) => {
assert_eq!(where_clauses.bounds.binders.len(&Interner), 1); assert_eq!(where_clauses.bounds.binders.len(&Interner), 1);
let predicates = where_clauses let predicates = where_clauses
@ -232,12 +233,13 @@ impl ToChalk for TypeCtor {
let id = callable_def.to_chalk(db); let id = callable_def.to_chalk(db);
TypeName::FnDef(id) TypeName::FnDef(id)
} }
TypeCtor::Never => TypeName::Never,
TypeCtor::Int(Uncertain::Unknown) TypeCtor::Int(Uncertain::Unknown)
| TypeCtor::Float(Uncertain::Unknown) | TypeCtor::Float(Uncertain::Unknown)
| TypeCtor::Adt(_) | TypeCtor::Adt(_)
| TypeCtor::Array | TypeCtor::Array
| TypeCtor::FnPtr { .. } | TypeCtor::FnPtr { .. }
| TypeCtor::Never
| TypeCtor::Closure { .. } => { | TypeCtor::Closure { .. } => {
// other TypeCtors get interned and turned into a chalk StructId // other TypeCtors get interned and turned into a chalk StructId
let struct_id = db.intern_type_ctor(self).into(); let struct_id = db.intern_type_ctor(self).into();
@ -273,13 +275,14 @@ impl ToChalk for TypeCtor {
TypeName::Slice => TypeCtor::Slice, TypeName::Slice => TypeCtor::Slice,
TypeName::Ref(mutability) => TypeCtor::Ref(from_chalk(db, mutability)), TypeName::Ref(mutability) => TypeCtor::Ref(from_chalk(db, mutability)),
TypeName::Str => TypeCtor::Str, TypeName::Str => TypeCtor::Str,
TypeName::Never => TypeCtor::Never,
TypeName::FnDef(fn_def_id) => { TypeName::FnDef(fn_def_id) => {
let callable_def = from_chalk(db, fn_def_id); let callable_def = from_chalk(db, fn_def_id);
TypeCtor::FnDef(callable_def) TypeCtor::FnDef(callable_def)
} }
TypeName::Error => { TypeName::Array | TypeName::Error => {
// this should not be reached, since we don't represent TypeName::Error with TypeCtor // this should not be reached, since we don't represent TypeName::Error with TypeCtor
unreachable!() unreachable!()
} }
@ -508,7 +511,7 @@ where
fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> {
let parameter = chalk_ir::CanonicalVarKind::new( let parameter = chalk_ir::CanonicalVarKind::new(
chalk_ir::VariableKind::Ty, chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General),
chalk_ir::UniverseIndex::ROOT, chalk_ir::UniverseIndex::ROOT,
); );
let value = self.value.to_chalk(db); let value = self.value.to_chalk(db);
@ -579,17 +582,17 @@ impl ToChalk for builtin::BuiltinImplData {
type Chalk = ImplDatum; type Chalk = ImplDatum;
fn to_chalk(self, db: &dyn HirDatabase) -> ImplDatum { fn to_chalk(self, db: &dyn HirDatabase) -> ImplDatum {
let impl_type = chalk_rust_ir::ImplType::External; let impl_type = rust_ir::ImplType::External;
let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect(); let where_clauses = self.where_clauses.into_iter().map(|w| w.to_chalk(db)).collect();
let impl_datum_bound = let impl_datum_bound =
chalk_rust_ir::ImplDatumBound { trait_ref: self.trait_ref.to_chalk(db), where_clauses }; rust_ir::ImplDatumBound { trait_ref: self.trait_ref.to_chalk(db), where_clauses };
let associated_ty_value_ids = let associated_ty_value_ids =
self.assoc_ty_values.into_iter().map(|v| v.to_chalk(db)).collect(); self.assoc_ty_values.into_iter().map(|v| v.to_chalk(db)).collect();
chalk_rust_ir::ImplDatum { rust_ir::ImplDatum {
binders: make_binders(impl_datum_bound, self.num_vars), binders: make_binders(impl_datum_bound, self.num_vars),
impl_type, impl_type,
polarity: chalk_rust_ir::Polarity::Positive, polarity: rust_ir::Polarity::Positive,
associated_ty_value_ids, associated_ty_value_ids,
} }
} }
@ -604,9 +607,9 @@ impl ToChalk for builtin::BuiltinImplAssocTyValueData {
fn to_chalk(self, db: &dyn HirDatabase) -> AssociatedTyValue { fn to_chalk(self, db: &dyn HirDatabase) -> AssociatedTyValue {
let ty = self.value.to_chalk(db); let ty = self.value.to_chalk(db);
let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty }; let value_bound = rust_ir::AssociatedTyValueBound { ty };
chalk_rust_ir::AssociatedTyValue { rust_ir::AssociatedTyValue {
associated_ty_id: self.assoc_ty_id.to_chalk(db), associated_ty_id: self.assoc_ty_id.to_chalk(db),
impl_id: self.impl_.to_chalk(db), impl_id: self.impl_.to_chalk(db),
value: make_binders(value_bound, self.num_vars), value: make_binders(value_bound, self.num_vars),
@ -628,7 +631,7 @@ where
chalk_ir::Binders::new( chalk_ir::Binders::new(
chalk_ir::VariableKinds::from( chalk_ir::VariableKinds::from(
&Interner, &Interner,
std::iter::repeat(chalk_ir::VariableKind::Ty).take(num_vars), std::iter::repeat(chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General)).take(num_vars),
), ),
value, value,
) )
@ -655,7 +658,7 @@ pub(super) fn generic_predicate_to_inline_bound(
db: &dyn HirDatabase, db: &dyn HirDatabase,
pred: &GenericPredicate, pred: &GenericPredicate,
self_ty: &Ty, self_ty: &Ty,
) -> Option<chalk_rust_ir::InlineBound<Interner>> { ) -> Option<rust_ir::InlineBound<Interner>> {
// An InlineBound is like a GenericPredicate, except the self type is left out. // An InlineBound is like a GenericPredicate, except the self type is left out.
// We don't have a special type for this, but Chalk does. // We don't have a special type for this, but Chalk does.
match pred { match pred {
@ -670,8 +673,8 @@ pub(super) fn generic_predicate_to_inline_bound(
.map(|ty| ty.clone().to_chalk(db).cast(&Interner)) .map(|ty| ty.clone().to_chalk(db).cast(&Interner))
.collect(); .collect();
let trait_bound = let trait_bound =
chalk_rust_ir::TraitBound { trait_id: trait_ref.trait_.to_chalk(db), args_no_self }; rust_ir::TraitBound { trait_id: trait_ref.trait_.to_chalk(db), args_no_self };
Some(chalk_rust_ir::InlineBound::TraitBound(trait_bound)) Some(rust_ir::InlineBound::TraitBound(trait_bound))
} }
GenericPredicate::Projection(proj) => { GenericPredicate::Projection(proj) => {
if &proj.projection_ty.parameters[0] != self_ty { if &proj.projection_ty.parameters[0] != self_ty {
@ -685,16 +688,13 @@ pub(super) fn generic_predicate_to_inline_bound(
.iter() .iter()
.map(|ty| ty.clone().to_chalk(db).cast(&Interner)) .map(|ty| ty.clone().to_chalk(db).cast(&Interner))
.collect(); .collect();
let alias_eq_bound = chalk_rust_ir::AliasEqBound { let alias_eq_bound = rust_ir::AliasEqBound {
value: proj.ty.clone().to_chalk(db), value: proj.ty.clone().to_chalk(db),
trait_bound: chalk_rust_ir::TraitBound { trait_bound: rust_ir::TraitBound { trait_id: trait_.to_chalk(db), args_no_self },
trait_id: trait_.to_chalk(db),
args_no_self,
},
associated_ty_id: proj.projection_ty.associated_ty.to_chalk(db), associated_ty_id: proj.projection_ty.associated_ty.to_chalk(db),
parameters: Vec::new(), // FIXME we don't support generic associated types yet parameters: Vec::new(), // FIXME we don't support generic associated types yet
}; };
Some(chalk_rust_ir::InlineBound::AliasEqBound(alias_eq_bound)) Some(rust_ir::InlineBound::AliasEqBound(alias_eq_bound))
} }
GenericPredicate::Error => None, GenericPredicate::Error => None,
} }