Skip to content

Commit 2420b42

Browse files
authored
Rollup merge of #69406 - jackh726:chalk-upgrade, r=nikomatsakis
upgrade chalk and use chalk-solve/chalk-ir/chalk-rust-ir Reintegrate chalk into rustc. r? @nikomatsakis cc. @rust-lang/wg-traits
2 parents 34d6b44 + 5fa4c63 commit 2420b42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2897
-21
lines changed

Cargo.lock

+98
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,77 @@ dependencies = [
429429
"rustc-std-workspace-core",
430430
]
431431

432+
[[package]]
433+
name = "chalk-derive"
434+
version = "0.10.0"
435+
source = "registry+https://github.com/rust-lang/crates.io-index"
436+
checksum = "8d4620afad4d4d9e63f915cfa10c930b7a3c9c3ca5cd88dd771ff8e5bf04ea10"
437+
dependencies = [
438+
"proc-macro2 1.0.3",
439+
"quote 1.0.2",
440+
"syn 1.0.11",
441+
"synstructure 0.12.1",
442+
]
443+
444+
[[package]]
445+
name = "chalk-engine"
446+
version = "0.10.0"
447+
source = "registry+https://github.com/rust-lang/crates.io-index"
448+
checksum = "6ca6e5cef10197789da0b4ec310eda58da4c55530613b2323432642a97372735"
449+
dependencies = [
450+
"chalk-macros",
451+
"rustc-hash",
452+
]
453+
454+
[[package]]
455+
name = "chalk-ir"
456+
version = "0.10.0"
457+
source = "registry+https://github.com/rust-lang/crates.io-index"
458+
checksum = "d45df5fb6328527f976e8a32c9e1c9970084d937ebe93d0d34f5bbf4231cb956"
459+
dependencies = [
460+
"chalk-derive",
461+
"chalk-engine",
462+
"chalk-macros",
463+
]
464+
465+
[[package]]
466+
name = "chalk-macros"
467+
version = "0.10.0"
468+
source = "registry+https://github.com/rust-lang/crates.io-index"
469+
checksum = "9e4782d108e420a1fcf94d8a919cf248db33c5071678e87d9c2d4f20ed1feb32"
470+
dependencies = [
471+
"lazy_static 1.4.0",
472+
]
473+
474+
[[package]]
475+
name = "chalk-rust-ir"
476+
version = "0.10.0"
477+
source = "registry+https://github.com/rust-lang/crates.io-index"
478+
checksum = "a0ec96dbe0ab5fdbadfca4179ec2e1d35f0439c3b53a74988b1aec239c63eb08"
479+
dependencies = [
480+
"chalk-derive",
481+
"chalk-engine",
482+
"chalk-ir",
483+
"chalk-macros",
484+
]
485+
486+
[[package]]
487+
name = "chalk-solve"
488+
version = "0.10.0"
489+
source = "registry+https://github.com/rust-lang/crates.io-index"
490+
checksum = "dfb99fa9530f0e101475fb60adc931f51bdea05b4642a48928b814d7f0141a6b"
491+
dependencies = [
492+
"chalk-derive",
493+
"chalk-engine",
494+
"chalk-ir",
495+
"chalk-macros",
496+
"chalk-rust-ir",
497+
"ena 0.13.1",
498+
"itertools 0.9.0",
499+
"petgraph",
500+
"rustc-hash",
501+
]
502+
432503
[[package]]
433504
name = "chrono"
434505
version = "0.4.6"
@@ -1102,6 +1173,12 @@ dependencies = [
11021173
"winapi 0.3.8",
11031174
]
11041175

1176+
[[package]]
1177+
name = "fixedbitset"
1178+
version = "0.1.9"
1179+
source = "registry+https://github.com/rust-lang/crates.io-index"
1180+
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
1181+
11051182
[[package]]
11061183
name = "flate2"
11071184
version = "1.0.12"
@@ -2328,6 +2405,12 @@ dependencies = [
23282405
"vcpkg",
23292406
]
23302407

2408+
[[package]]
2409+
name = "ordermap"
2410+
version = "0.3.5"
2411+
source = "registry+https://github.com/rust-lang/crates.io-index"
2412+
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
2413+
23312414
[[package]]
23322415
name = "ordslice"
23332416
version = "0.3.0"
@@ -2496,6 +2579,16 @@ dependencies = [
24962579
"sha-1",
24972580
]
24982581

2582+
[[package]]
2583+
name = "petgraph"
2584+
version = "0.4.13"
2585+
source = "registry+https://github.com/rust-lang/crates.io-index"
2586+
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
2587+
dependencies = [
2588+
"fixedbitset",
2589+
"ordermap",
2590+
]
2591+
24992592
[[package]]
25002593
name = "phf"
25012594
version = "0.7.24"
@@ -4002,6 +4095,7 @@ dependencies = [
40024095
"arena",
40034096
"bitflags",
40044097
"byteorder",
4098+
"chalk-ir",
40054099
"log",
40064100
"measureme",
40074101
"polonius-engine",
@@ -4301,10 +4395,14 @@ dependencies = [
43014395
name = "rustc_traits"
43024396
version = "0.0.0"
43034397
dependencies = [
4398+
"chalk-ir",
4399+
"chalk-rust-ir",
4400+
"chalk-solve",
43044401
"log",
43054402
"rustc_ast",
43064403
"rustc_data_structures",
43074404
"rustc_hir",
4405+
"rustc_index",
43084406
"rustc_infer",
43094407
"rustc_middle",
43104408
"rustc_span",

src/librustc_infer/infer/canonical/canonicalizer.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
353353
// `TyVar(vid)` is unresolved, track its universe index in the canonicalized
354354
// result.
355355
Err(mut ui) => {
356-
// FIXME: perf problem described in #55921.
357-
ui = ty::UniverseIndex::ROOT;
356+
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
357+
// FIXME: perf problem described in #55921.
358+
ui = ty::UniverseIndex::ROOT;
359+
}
358360
self.canonicalize_ty_var(
359361
CanonicalVarInfo {
360362
kind: CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui)),
@@ -439,8 +441,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
439441
// `ConstVar(vid)` is unresolved, track its universe index in the
440442
// canonicalized result
441443
Err(mut ui) => {
442-
// FIXME: perf problem described in #55921.
443-
ui = ty::UniverseIndex::ROOT;
444+
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
445+
// FIXME: perf problem described in #55921.
446+
ui = ty::UniverseIndex::ROOT;
447+
}
444448
return self.canonicalize_const_var(
445449
CanonicalVarInfo { kind: CanonicalVarKind::Const(ui) },
446450
ct,

src/librustc_interface/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ fn test_debugging_options_tracking_hash() {
525525
tracked!(always_encode_mir, true);
526526
tracked!(asm_comments, true);
527527
tracked!(binary_dep_depinfo, true);
528+
tracked!(chalk, true);
528529
tracked!(codegen_backend, Some("abc".to_string()));
529530
tracked!(crate_attr, vec!["abc".to_string()]);
530531
tracked!(debug_macros, true);

src/librustc_middle/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ rustc_serialize = { path = "../libserialize", package = "serialize" }
3131
rustc_ast = { path = "../librustc_ast" }
3232
rustc_span = { path = "../librustc_span" }
3333
byteorder = { version = "1.3" }
34+
chalk-ir = "0.10.0"
3435
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
3536
measureme = "0.7.1"
3637
rustc_session = { path = "../librustc_session" }

src/librustc_middle/dep_graph/dep_node.rs

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
5252
use crate::mir;
5353
use crate::mir::interpret::{GlobalId, LitToConstInput};
54+
use crate::traits;
5455
use crate::traits::query::{
5556
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
5657
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,

src/librustc_middle/query/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::dep_graph::SerializedDepNodeIndex;
22
use crate::mir;
33
use crate::mir::interpret::{GlobalId, LitToConstInput};
4+
use crate::traits;
45
use crate::traits::query::{
56
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
67
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
@@ -1154,6 +1155,15 @@ rustc_queries! {
11541155
desc { "evaluating trait selection obligation `{}`", goal.value.value }
11551156
}
11561157

1158+
query evaluate_goal(
1159+
goal: traits::ChalkCanonicalGoal<'tcx>
1160+
) -> Result<
1161+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1162+
NoSolution
1163+
> {
1164+
desc { "evaluating trait selection obligation `{}`", goal.value }
1165+
}
1166+
11571167
/// Do not call this query directly: part of the `Eq` type-op
11581168
query type_op_ascribe_user_type(
11591169
goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>

0 commit comments

Comments
 (0)