Skip to content

Commit c336478

Browse files
committed
Auto merge of #75173 - jackh726:chalk-0.21, r=nikomatsakis
Upgrade Chalk to 0.21 Two commits here. First commit actually does the upgrade. Second commit has some changes to make more tests in compare-mode=chalk pass. The `PlaceholdersCollector` and `RegionsSubstitutor` bits are bit a hacky, but only insomuch as `ParamsSubstitutor` is. These won't be needed eventually. r? @nikomatsakis
2 parents 70c5f6e + 0aa2153 commit c336478

File tree

11 files changed

+726
-510
lines changed

11 files changed

+726
-510
lines changed

Cargo.lock

+52-9
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ dependencies = [
427427

428428
[[package]]
429429
name = "chalk-derive"
430-
version = "0.14.0"
430+
version = "0.21.0"
431431
source = "registry+https://github.com/rust-lang/crates.io-index"
432-
checksum = "d463e01905d607e181de72e8608721d3269f29176c9a14ce037011316ae7131d"
432+
checksum = "c1df0dbb57d74b4acd20f20fa66ab2acd09776b79eaeb9d8f947b2f3e01c40bf"
433433
dependencies = [
434434
"proc-macro2",
435435
"quote",
@@ -439,40 +439,42 @@ dependencies = [
439439

440440
[[package]]
441441
name = "chalk-engine"
442-
version = "0.14.0"
442+
version = "0.21.0"
443443
source = "registry+https://github.com/rust-lang/crates.io-index"
444-
checksum = "efaf428f5398d36284f79690cf988762b7c091249f50a6c11db613a46c057000"
444+
checksum = "fb7c65a13f32f02aba8f1d9a37f206af615f77ac564624b81a4c593c6c1735b9"
445445
dependencies = [
446446
"chalk-derive",
447447
"chalk-ir",
448+
"chalk-solve",
448449
"rustc-hash",
449450
"tracing",
450451
]
451452

452453
[[package]]
453454
name = "chalk-ir"
454-
version = "0.14.0"
455+
version = "0.21.0"
455456
source = "registry+https://github.com/rust-lang/crates.io-index"
456-
checksum = "fd3fdc1e9f68498ffe80f4a23b0b95f1ca6fb21d5a4c9b0c085fab3ca712bdbe"
457+
checksum = "44361a25dbdb1dc428f56ad7a3c21ba9ca12f3225c26a47919ff6fcb10a583d4"
457458
dependencies = [
458459
"chalk-derive",
459460
"lazy_static",
460461
]
461462

462463
[[package]]
463464
name = "chalk-solve"
464-
version = "0.14.0"
465+
version = "0.21.0"
465466
source = "registry+https://github.com/rust-lang/crates.io-index"
466-
checksum = "5b9fd4102807b7ebe8fb034fa0f488c5656e1966d3261b558b81a08d519cdb29"
467+
checksum = "a886da37a0dc457057d86f78f026f7a09c6d8088aa13f4f4127fdb8dc80119a3"
467468
dependencies = [
468469
"chalk-derive",
469-
"chalk-engine",
470470
"chalk-ir",
471471
"ena",
472472
"itertools 0.9.0",
473473
"petgraph",
474474
"rustc-hash",
475475
"tracing",
476+
"tracing-subscriber",
477+
"tracing-tree",
476478
]
477479

478480
[[package]]
@@ -4038,6 +4040,7 @@ dependencies = [
40384040
name = "rustc_traits"
40394041
version = "0.0.0"
40404042
dependencies = [
4043+
"chalk-engine",
40414044
"chalk-ir",
40424045
"chalk-solve",
40434046
"rustc_ast",
@@ -4996,21 +4999,61 @@ dependencies = [
49964999
"lazy_static",
49975000
]
49985001

5002+
[[package]]
5003+
name = "tracing-log"
5004+
version = "0.1.1"
5005+
source = "registry+https://github.com/rust-lang/crates.io-index"
5006+
checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9"
5007+
dependencies = [
5008+
"lazy_static",
5009+
"log",
5010+
"tracing-core",
5011+
]
5012+
5013+
[[package]]
5014+
name = "tracing-serde"
5015+
version = "0.1.1"
5016+
source = "registry+https://github.com/rust-lang/crates.io-index"
5017+
checksum = "b6ccba2f8f16e0ed268fc765d9b7ff22e965e7185d32f8f1ec8294fe17d86e79"
5018+
dependencies = [
5019+
"serde",
5020+
"tracing-core",
5021+
]
5022+
49995023
[[package]]
50005024
name = "tracing-subscriber"
50015025
version = "0.2.11"
50025026
source = "registry+https://github.com/rust-lang/crates.io-index"
50035027
checksum = "abd165311cc4d7a555ad11cc77a37756df836182db0d81aac908c8184c584f40"
50045028
dependencies = [
50055029
"ansi_term 0.12.1",
5030+
"chrono",
50065031
"lazy_static",
50075032
"matchers",
50085033
"parking_lot 0.11.0",
50095034
"regex",
5035+
"serde",
5036+
"serde_json",
50105037
"sharded-slab",
50115038
"smallvec 1.4.2",
50125039
"thread_local",
50135040
"tracing-core",
5041+
"tracing-log",
5042+
"tracing-serde",
5043+
]
5044+
5045+
[[package]]
5046+
name = "tracing-tree"
5047+
version = "0.1.5"
5048+
source = "registry+https://github.com/rust-lang/crates.io-index"
5049+
checksum = "e1a3dc4774db3a6b2d66a4f8d8de670e874ec3ed55615860c994927419b32c5f"
5050+
dependencies = [
5051+
"ansi_term 0.12.1",
5052+
"atty",
5053+
"chrono",
5054+
"termcolor",
5055+
"tracing",
5056+
"tracing-subscriber",
50145057
]
50155058

50165059
[[package]]

compiler/rustc_middle/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ rustc_serialize = { path = "../rustc_serialize" }
2727
rustc_ast = { path = "../rustc_ast" }
2828
rustc_span = { path = "../rustc_span" }
2929
byteorder = { version = "1.3" }
30-
chalk-ir = "0.14.0"
30+
chalk-ir = "0.21.0"
3131
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
3232
measureme = "0.7.1"
3333
rustc_session = { path = "../rustc_session" }

compiler/rustc_middle/src/traits/chalk.rs

+51-2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
7575
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
7676
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
7777
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
78+
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
7879
type DefId = DefId;
7980
type InternedAdtId = &'tcx AdtDef;
8081
type Identifier = ();
@@ -108,8 +109,42 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
108109
application_ty: &chalk_ir::ApplicationTy<Self>,
109110
fmt: &mut fmt::Formatter<'_>,
110111
) -> Option<fmt::Result> {
111-
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
112-
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
112+
match application_ty.name {
113+
chalk_ir::TypeName::Ref(mutbl) => {
114+
let data = application_ty.substitution.interned();
115+
match (&**data[0].interned(), &**data[1].interned()) {
116+
(
117+
chalk_ir::GenericArgData::Lifetime(lifetime),
118+
chalk_ir::GenericArgData::Ty(ty),
119+
) => Some(match mutbl {
120+
chalk_ir::Mutability::Not => write!(fmt, "(&{:?} {:?})", lifetime, ty),
121+
chalk_ir::Mutability::Mut => write!(fmt, "(&{:?} mut {:?})", lifetime, ty),
122+
}),
123+
_ => unreachable!(),
124+
}
125+
}
126+
chalk_ir::TypeName::Array => {
127+
let data = application_ty.substitution.interned();
128+
match (&**data[0].interned(), &**data[1].interned()) {
129+
(chalk_ir::GenericArgData::Ty(ty), chalk_ir::GenericArgData::Const(len)) => {
130+
Some(write!(fmt, "[{:?}; {:?}]", ty, len))
131+
}
132+
_ => unreachable!(),
133+
}
134+
}
135+
chalk_ir::TypeName::Slice => {
136+
let data = application_ty.substitution.interned();
137+
let ty = match &**data[0].interned() {
138+
chalk_ir::GenericArgData::Ty(t) => t,
139+
_ => unreachable!(),
140+
};
141+
Some(write!(fmt, "[{:?}]", ty))
142+
}
143+
_ => {
144+
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
145+
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
146+
}
147+
}
113148
}
114149

115150
fn debug_substitution(
@@ -321,6 +356,20 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
321356
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
322357
canonical_var_kinds
323358
}
359+
360+
fn intern_constraints<E>(
361+
&self,
362+
data: impl IntoIterator<Item = Result<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>, E>>,
363+
) -> Result<Self::InternedConstraints, E> {
364+
data.into_iter().collect::<Result<Vec<_>, _>>()
365+
}
366+
367+
fn constraints_data<'a>(
368+
&self,
369+
constraints: &'a Self::InternedConstraints,
370+
) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
371+
constraints
372+
}
324373
}
325374

326375
impl<'tcx> chalk_ir::interner::HasInterner for RustInterner<'tcx> {

compiler/rustc_traits/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ rustc_hir = { path = "../rustc_hir" }
1212
rustc_index = { path = "../rustc_index" }
1313
rustc_ast = { path = "../rustc_ast" }
1414
rustc_span = { path = "../rustc_span" }
15-
chalk-ir = "0.14.0"
16-
chalk-solve = "0.14.0"
15+
chalk-ir = "0.21.0"
16+
chalk-solve = "0.21.0"
17+
chalk-engine = "0.21.0"
1718
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
1819
rustc_infer = { path = "../rustc_infer" }
1920
rustc_trait_selection = { path = "../rustc_trait_selection" }

0 commit comments

Comments
 (0)