4568: Update Chalk r=matklad a=flodiebold

As always, this just makes compilation work, we don't use the newly available
functionality yet.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
This commit is contained in:
bors[bot] 2020-05-22 15:08:19 +00:00 committed by GitHub
commit 0fb7134915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 94 additions and 80 deletions

41
Cargo.lock generated
View File

@ -114,7 +114,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "chalk-derive"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"proc-macro2",
"quote",
@ -125,7 +125,7 @@ dependencies = [
[[package]]
name = "chalk-engine"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"chalk-macros",
"rustc-hash",
@ -134,7 +134,7 @@ dependencies = [
[[package]]
name = "chalk-ir"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"chalk-derive",
"chalk-engine",
@ -144,7 +144,7 @@ dependencies = [
[[package]]
name = "chalk-macros"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"lazy_static",
]
@ -152,7 +152,7 @@ dependencies = [
[[package]]
name = "chalk-rust-ir"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"chalk-derive",
"chalk-engine",
@ -163,14 +163,14 @@ dependencies = [
[[package]]
name = "chalk-solve"
version = "0.10.1-dev"
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-ir",
"chalk-macros",
"chalk-rust-ir",
"ena 0.13.1",
"ena",
"itertools",
"petgraph",
"rustc-hash",
@ -307,15 +307,6 @@ version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
[[package]]
name = "ena"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36"
dependencies = [
"log",
]
[[package]]
name = "ena"
version = "0.14.0"
@ -354,9 +345,9 @@ dependencies = [
[[package]]
name = "fixedbitset"
version = "0.1.9"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "fnv"
@ -813,12 +804,6 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
[[package]]
name = "ordermap"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
[[package]]
name = "parking_lot"
version = "0.10.2"
@ -873,12 +858,12 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "petgraph"
version = "0.4.13"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
checksum = "29c127eea4a29ec6c85d153c59dc1213f33ec74cead30fe4730aecc88cc1fd92"
dependencies = [
"fixedbitset",
"ordermap",
"indexmap",
]
[[package]]
@ -1053,7 +1038,7 @@ dependencies = [
"chalk-ir",
"chalk-rust-ir",
"chalk-solve",
"ena 0.14.0",
"ena",
"insta",
"itertools",
"log",

View File

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

View File

@ -4,7 +4,7 @@
use log::debug;
use chalk_ir::{
cast::Cast, fold::shift::Shift, interner::HasInterner, Goal, GoalData, Parameter,
cast::Cast, fold::shift::Shift, interner::HasInterner, GenericArg, Goal, GoalData,
PlaceholderIndex, TypeName, UniverseIndex,
};
@ -26,24 +26,24 @@
pub struct Interner;
impl chalk_ir::interner::Interner for Interner {
type InternedType = Box<chalk_ir::TyData<Self>>;
type InternedType = Box<chalk_ir::TyData<Self>>; // FIXME use Arc?
type InternedLifetime = chalk_ir::LifetimeData<Self>;
type InternedParameter = chalk_ir::ParameterData<Self>;
type InternedConst = Arc<chalk_ir::ConstData<Self>>;
type InternedConcreteConst = ();
type InternedGenericArg = chalk_ir::GenericArgData<Self>;
type InternedGoal = Arc<GoalData<Self>>;
type InternedGoals = Vec<Goal<Self>>;
type InternedSubstitution = Vec<Parameter<Self>>;
type InternedSubstitution = Vec<GenericArg<Self>>;
type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>;
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
type InternedParameterKinds = Vec<chalk_ir::ParameterKind<()>>;
type InternedCanonicalVarKinds = Vec<chalk_ir::ParameterKind<UniverseIndex>>;
type Identifier = TypeAliasId;
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
type DefId = InternId;
type InternedAdtId = InternId;
type Identifier = TypeAliasId;
fn debug_struct_id(
type_kind_id: StructId,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
fn debug_adt_id(type_kind_id: StructId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt)))
}
@ -94,11 +94,11 @@ fn debug_lifetime(
tls::with_current_program(|prog| Some(prog?.debug_lifetime(lifetime, fmt)))
}
fn debug_parameter(
parameter: &Parameter<Interner>,
fn debug_generic_arg(
parameter: &GenericArg<Interner>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
tls::with_current_program(|prog| Some(prog?.debug_parameter(parameter, fmt)))
tls::with_current_program(|prog| Some(prog?.debug_generic_arg(parameter, fmt)))
}
fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
@ -164,17 +164,32 @@ fn lifetime_data<'a>(
lifetime
}
fn intern_parameter(
fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Arc<chalk_ir::ConstData<Self>> {
Arc::new(constant)
}
fn const_data<'a>(
&self,
parameter: chalk_ir::ParameterData<Self>,
) -> chalk_ir::ParameterData<Self> {
constant: &'a Arc<chalk_ir::ConstData<Self>>,
) -> &'a chalk_ir::ConstData<Self> {
constant
}
fn const_eq(&self, _ty: &Box<chalk_ir::TyData<Self>>, _c1: &(), _c2: &()) -> bool {
true
}
fn intern_generic_arg(
&self,
parameter: chalk_ir::GenericArgData<Self>,
) -> chalk_ir::GenericArgData<Self> {
parameter
}
fn parameter_data<'a>(
fn generic_arg_data<'a>(
&self,
parameter: &'a chalk_ir::ParameterData<Self>,
) -> &'a chalk_ir::ParameterData<Self> {
parameter: &'a chalk_ir::GenericArgData<Self>,
) -> &'a chalk_ir::GenericArgData<Self> {
parameter
}
@ -199,15 +214,15 @@ fn goals_data<'a>(&self, goals: &'a Vec<Goal<Interner>>) -> &'a [Goal<Interner>]
fn intern_substitution<E>(
&self,
data: impl IntoIterator<Item = Result<Parameter<Self>, E>>,
) -> Result<Vec<Parameter<Self>>, E> {
data: impl IntoIterator<Item = Result<GenericArg<Self>, E>>,
) -> Result<Vec<GenericArg<Self>>, E> {
data.into_iter().collect()
}
fn substitution_data<'a>(
&self,
substitution: &'a Vec<Parameter<Self>>,
) -> &'a [Parameter<Self>] {
substitution: &'a Vec<GenericArg<Self>>,
) -> &'a [GenericArg<Self>] {
substitution
}
@ -253,23 +268,23 @@ fn quantified_where_clauses_data<'a>(
clauses
}
fn intern_parameter_kinds<E>(
fn intern_generic_arg_kinds<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<()>, E>>,
) -> Result<Self::InternedParameterKinds, E> {
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
) -> Result<Self::InternedVariableKinds, E> {
data.into_iter().collect()
}
fn parameter_kinds_data<'a>(
fn variable_kinds_data<'a>(
&self,
parameter_kinds: &'a Self::InternedParameterKinds,
) -> &'a [chalk_ir::ParameterKind<()>] {
parameter_kinds: &'a Self::InternedVariableKinds,
) -> &'a [chalk_ir::VariableKind<Self>] {
&parameter_kinds
}
fn intern_canonical_var_kinds<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<UniverseIndex>, E>>,
data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
) -> Result<Self::InternedCanonicalVarKinds, E> {
data.into_iter().collect()
}
@ -277,7 +292,7 @@ fn intern_canonical_var_kinds<E>(
fn canonical_var_kinds_data<'a>(
&self,
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
) -> &'a [chalk_ir::ParameterKind<UniverseIndex>] {
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
&canonical_var_kinds
}
}
@ -290,8 +305,8 @@ impl chalk_ir::interner::HasInterner for Interner {
pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>;
pub type TraitId = chalk_ir::TraitId<Interner>;
pub type TraitDatum = chalk_rust_ir::TraitDatum<Interner>;
pub type StructId = chalk_ir::StructId<Interner>;
pub type StructDatum = chalk_rust_ir::StructDatum<Interner>;
pub type StructId = chalk_ir::AdtId<Interner>;
pub type StructDatum = chalk_rust_ir::AdtDatum<Interner>;
pub type ImplId = chalk_ir::ImplId<Interner>;
pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>;
pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>;
@ -453,14 +468,14 @@ fn to_chalk(self, db: &dyn HirDatabase) -> TypeName<Interner> {
_ => {
// other TypeCtors get interned and turned into a chalk StructId
let struct_id = db.intern_type_ctor(self).into();
TypeName::Struct(struct_id)
TypeName::Adt(struct_id)
}
}
}
fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor {
match type_name {
TypeName::Struct(struct_id) => db.lookup_intern_type_ctor(struct_id.into()),
TypeName::Adt(struct_id) => db.lookup_intern_type_ctor(struct_id.into()),
TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)),
TypeName::OpaqueType(_) => unreachable!(),
@ -471,6 +486,8 @@ fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor {
TypeName::Ref(_) => unreachable!(),
TypeName::Str => unreachable!(),
TypeName::FnDef(_) => unreachable!(),
TypeName::Error => {
// this should not be reached, since we don't represent TypeName::Error with TypeCtor
unreachable!()
@ -622,7 +639,10 @@ impl<T> ToChalk for Canonical<T>
type Chalk = chalk_ir::Canonical<T::Chalk>;
fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> {
let parameter = chalk_ir::ParameterKind::Ty(chalk_ir::UniverseIndex::ROOT);
let parameter = chalk_ir::CanonicalVarKind::new(
chalk_ir::VariableKind::Ty,
chalk_ir::UniverseIndex::ROOT,
);
let value = self.value.to_chalk(db);
chalk_ir::Canonical {
value,
@ -738,9 +758,9 @@ fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T>
T: HasInterner<Interner = Interner>,
{
chalk_ir::Binders::new(
chalk_ir::ParameterKinds::from(
chalk_ir::VariableKinds::from(
&Interner,
std::iter::repeat(chalk_ir::ParameterKind::Ty(())).take(num_vars),
std::iter::repeat(chalk_ir::VariableKind::Ty).take(num_vars),
),
value,
)
@ -819,16 +839,25 @@ fn associated_ty_data(&self, id: AssocTypeId) -> Arc<AssociatedTyDatum> {
fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> {
self.db.trait_datum(self.krate, trait_id)
}
fn struct_datum(&self, struct_id: StructId) -> Arc<StructDatum> {
fn adt_datum(&self, struct_id: StructId) -> Arc<StructDatum> {
self.db.struct_datum(self.krate, struct_id)
}
fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> {
self.db.impl_datum(self.krate, impl_id)
}
fn fn_def_datum(
&self,
_fn_def_id: chalk_ir::FnDefId<Interner>,
) -> Arc<chalk_rust_ir::FnDefDatum<Interner>> {
// We don't yet provide any FnDefs to Chalk
unimplemented!()
}
fn impls_for_trait(
&self,
trait_id: TraitId,
parameters: &[Parameter<Interner>],
parameters: &[GenericArg<Interner>],
) -> Vec<ImplId> {
debug!("impls_for_trait {:?}", trait_id);
let trait_: hir_def::TraitId = from_chalk(self.db, trait_id);
@ -1000,7 +1029,7 @@ pub(crate) fn struct_datum_query(
struct_id: StructId,
) -> Arc<StructDatum> {
debug!("struct_datum {:?}", struct_id);
let type_ctor: TypeCtor = from_chalk(db, TypeName::Struct(struct_id));
let type_ctor: TypeCtor = from_chalk(db, TypeName::Adt(struct_id));
debug!("struct {:?} = {:?}", struct_id, type_ctor);
let num_params = type_ctor.num_ty_params(db);
let upstream = type_ctor.krate(db) != Some(krate);
@ -1012,12 +1041,12 @@ pub(crate) fn struct_datum_query(
convert_where_clauses(db, generic_def, &bound_vars)
})
.unwrap_or_else(Vec::new);
let flags = chalk_rust_ir::StructFlags {
let flags = chalk_rust_ir::AdtFlags {
upstream,
// FIXME set fundamental flag correctly
fundamental: false,
};
let struct_datum_bound = chalk_rust_ir::StructDatumBound {
let struct_datum_bound = chalk_rust_ir::AdtDatumBound {
fields: Vec::new(), // FIXME add fields (only relevant for auto traits)
where_clauses,
};
@ -1153,7 +1182,7 @@ fn from(struct_id: StructId) -> Self {
impl From<crate::TypeCtorId> for StructId {
fn from(type_ctor_id: crate::TypeCtorId) -> Self {
chalk_ir::StructId(type_ctor_id.as_intern_id())
chalk_ir::AdtId(type_ctor_id.as_intern_id())
}
}

View File

@ -1,7 +1,7 @@
//! Implementation of Chalk debug helper functions using TLS.
use std::fmt;
use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName};
use chalk_ir::{AliasTy, GenericArg, Goal, Goals, Lifetime, ProgramClauseImplication, TypeName};
use itertools::Itertools;
use super::{from_chalk, Interner};
@ -18,7 +18,7 @@ pub fn debug_struct_id(
id: super::StructId,
f: &mut fmt::Formatter<'_>,
) -> Result<(), fmt::Error> {
let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Struct(id));
let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Adt(id));
match type_ctor {
TypeCtor::Bool => write!(f, "bool")?,
TypeCtor::Char => write!(f, "char")?,
@ -188,9 +188,9 @@ pub fn debug_lifetime(
write!(fmt, "{:?}", lifetime.data(&Interner))
}
pub fn debug_parameter(
pub fn debug_generic_arg(
&self,
parameter: &Parameter<Interner>,
parameter: &GenericArg<Interner>,
fmt: &mut fmt::Formatter<'_>,
) -> Result<(), fmt::Error> {
write!(fmt, "{:?}", parameter.data(&Interner).inner_debug())