Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Chalk to 0.21 #75173

Merged
merged 5 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 52 additions & 9 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ dependencies = [

[[package]]
name = "chalk-derive"
version = "0.14.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d463e01905d607e181de72e8608721d3269f29176c9a14ce037011316ae7131d"
checksum = "c1df0dbb57d74b4acd20f20fa66ab2acd09776b79eaeb9d8f947b2f3e01c40bf"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -439,40 +439,42 @@ dependencies = [

[[package]]
name = "chalk-engine"
version = "0.14.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaf428f5398d36284f79690cf988762b7c091249f50a6c11db613a46c057000"
checksum = "fb7c65a13f32f02aba8f1d9a37f206af615f77ac564624b81a4c593c6c1735b9"
dependencies = [
"chalk-derive",
"chalk-ir",
"chalk-solve",
"rustc-hash",
"tracing",
]

[[package]]
name = "chalk-ir"
version = "0.14.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3fdc1e9f68498ffe80f4a23b0b95f1ca6fb21d5a4c9b0c085fab3ca712bdbe"
checksum = "44361a25dbdb1dc428f56ad7a3c21ba9ca12f3225c26a47919ff6fcb10a583d4"
dependencies = [
"chalk-derive",
"lazy_static",
]

[[package]]
name = "chalk-solve"
version = "0.14.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9fd4102807b7ebe8fb034fa0f488c5656e1966d3261b558b81a08d519cdb29"
checksum = "a886da37a0dc457057d86f78f026f7a09c6d8088aa13f4f4127fdb8dc80119a3"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-ir",
"ena",
"itertools 0.9.0",
"petgraph",
"rustc-hash",
"tracing",
"tracing-subscriber",
"tracing-tree",
]

[[package]]
Expand Down Expand Up @@ -4038,6 +4040,7 @@ dependencies = [
name = "rustc_traits"
version = "0.0.0"
dependencies = [
"chalk-engine",
"chalk-ir",
"chalk-solve",
"rustc_ast",
Expand Down Expand Up @@ -4996,21 +4999,61 @@ dependencies = [
"lazy_static",
]

[[package]]
name = "tracing-log"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]

[[package]]
name = "tracing-serde"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6ccba2f8f16e0ed268fc765d9b7ff22e965e7185d32f8f1ec8294fe17d86e79"
dependencies = [
"serde",
"tracing-core",
]

[[package]]
name = "tracing-subscriber"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abd165311cc4d7a555ad11cc77a37756df836182db0d81aac908c8184c584f40"
dependencies = [
"ansi_term 0.12.1",
"chrono",
"lazy_static",
"matchers",
"parking_lot 0.11.0",
"regex",
"serde",
"serde_json",
"sharded-slab",
"smallvec 1.4.2",
"thread_local",
"tracing-core",
"tracing-log",
"tracing-serde",
]

[[package]]
name = "tracing-tree"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1a3dc4774db3a6b2d66a4f8d8de670e874ec3ed55615860c994927419b32c5f"
dependencies = [
"ansi_term 0.12.1",
"atty",
"chrono",
"termcolor",
"tracing",
"tracing-subscriber",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
byteorder = { version = "1.3" }
chalk-ir = "0.14.0"
chalk-ir = "0.21.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
measureme = "0.7.1"
rustc_session = { path = "../rustc_session" }
53 changes: 51 additions & 2 deletions compiler/rustc_middle/src/traits/chalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
type DefId = DefId;
type InternedAdtId = &'tcx AdtDef;
type Identifier = ();
Expand Down Expand Up @@ -108,8 +109,42 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
application_ty: &chalk_ir::ApplicationTy<Self>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
match application_ty.name {
chalk_ir::TypeName::Ref(mutbl) => {
let data = application_ty.substitution.interned();
match (&**data[0].interned(), &**data[1].interned()) {
(
chalk_ir::GenericArgData::Lifetime(lifetime),
chalk_ir::GenericArgData::Ty(ty),
) => Some(match mutbl {
chalk_ir::Mutability::Not => write!(fmt, "(&{:?} {:?})", lifetime, ty),
chalk_ir::Mutability::Mut => write!(fmt, "(&{:?} mut {:?})", lifetime, ty),
}),
_ => unreachable!(),
}
}
chalk_ir::TypeName::Array => {
let data = application_ty.substitution.interned();
match (&**data[0].interned(), &**data[1].interned()) {
(chalk_ir::GenericArgData::Ty(ty), chalk_ir::GenericArgData::Const(len)) => {
Some(write!(fmt, "[{:?}; {:?}]", ty, len))
}
_ => unreachable!(),
}
}
chalk_ir::TypeName::Slice => {
let data = application_ty.substitution.interned();
let ty = match &**data[0].interned() {
chalk_ir::GenericArgData::Ty(t) => t,
_ => unreachable!(),
};
Some(write!(fmt, "[{:?}]", ty))
}
_ => {
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
}
}
}

fn debug_substitution(
Expand Down Expand Up @@ -321,6 +356,20 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
canonical_var_kinds
}

fn intern_constraints<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>, E>>,
) -> Result<Self::InternedConstraints, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}

fn constraints_data<'a>(
&self,
constraints: &'a Self::InternedConstraints,
) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
constraints
}
}

impl<'tcx> chalk_ir::interner::HasInterner for RustInterner<'tcx> {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
chalk-ir = "0.14.0"
chalk-solve = "0.14.0"
chalk-ir = "0.21.0"
chalk-solve = "0.21.0"
chalk-engine = "0.21.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc_infer = { path = "../rustc_infer" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
Loading