Skip to content

Commit a8cf399

Browse files
committed
Auto merge of #72936 - jackh726:chalk-more, r=nikomatsakis
Upgrade Chalk Things done in this PR: - Upgrade Chalk to `0.11.0` - Added compare-mode=chalk - Bump rustc-hash in `librustc_data_structures` to `1.1.0` to match Chalk - Removed `RustDefId` since the builtin type support is there - Add a few more `FIXME(chalk)`s for problem spots I hit when running all tests with chalk - Added some more implementation code for some newer builtin Chalk types (e.g. `FnDef`, `Array`) - Lower `RegionOutlives` and `ObjectSafe` predicates - Lower `Dyn` without the region - Handle `Int`/`Float` `CanonicalVarKind`s - Uncomment some Chalk tests that actually work now - Remove the revisions in `src/test/ui/coherence/coherence-subtyping.rs` since they aren't doing anything different r? @nikomatsakis
2 parents 349f6bf + d63195b commit a8cf399

File tree

24 files changed

+550
-499
lines changed

24 files changed

+550
-499
lines changed

Cargo.lock

+20-62
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ dependencies = [
434434

435435
[[package]]
436436
name = "chalk-derive"
437-
version = "0.10.0"
437+
version = "0.11.0"
438438
source = "registry+https://github.com/rust-lang/crates.io-index"
439-
checksum = "8d4620afad4d4d9e63f915cfa10c930b7a3c9c3ca5cd88dd771ff8e5bf04ea10"
439+
checksum = "5b9bd01eab87277d973183a1d2e56bace1c11f8242c52c20636fb7dddf343ac9"
440440
dependencies = [
441441
"proc-macro2 1.0.3",
442442
"quote 1.0.2",
@@ -446,58 +446,35 @@ dependencies = [
446446

447447
[[package]]
448448
name = "chalk-engine"
449-
version = "0.10.0"
449+
version = "0.11.0"
450450
source = "registry+https://github.com/rust-lang/crates.io-index"
451-
checksum = "6ca6e5cef10197789da0b4ec310eda58da4c55530613b2323432642a97372735"
451+
checksum = "6c7a637c3d17ed555aef16e16952a5d1e127bd55178cc30be22afeb92da90c7d"
452452
dependencies = [
453-
"chalk-macros",
453+
"chalk-derive",
454+
"chalk-ir",
454455
"rustc-hash",
455456
]
456457

457458
[[package]]
458459
name = "chalk-ir"
459-
version = "0.10.0"
460+
version = "0.11.0"
460461
source = "registry+https://github.com/rust-lang/crates.io-index"
461-
checksum = "d45df5fb6328527f976e8a32c9e1c9970084d937ebe93d0d34f5bbf4231cb956"
462+
checksum = "595e5735ded16c3f3dc348f7b15bbb2521a0080b1863cac38ad5271589944670"
462463
dependencies = [
463464
"chalk-derive",
464-
"chalk-engine",
465-
"chalk-macros",
466-
]
467-
468-
[[package]]
469-
name = "chalk-macros"
470-
version = "0.10.0"
471-
source = "registry+https://github.com/rust-lang/crates.io-index"
472-
checksum = "9e4782d108e420a1fcf94d8a919cf248db33c5071678e87d9c2d4f20ed1feb32"
473-
dependencies = [
474465
"lazy_static",
475466
]
476467

477-
[[package]]
478-
name = "chalk-rust-ir"
479-
version = "0.10.0"
480-
source = "registry+https://github.com/rust-lang/crates.io-index"
481-
checksum = "a0ec96dbe0ab5fdbadfca4179ec2e1d35f0439c3b53a74988b1aec239c63eb08"
482-
dependencies = [
483-
"chalk-derive",
484-
"chalk-engine",
485-
"chalk-ir",
486-
"chalk-macros",
487-
]
488-
489468
[[package]]
490469
name = "chalk-solve"
491-
version = "0.10.0"
470+
version = "0.11.0"
492471
source = "registry+https://github.com/rust-lang/crates.io-index"
493-
checksum = "dfb99fa9530f0e101475fb60adc931f51bdea05b4642a48928b814d7f0141a6b"
472+
checksum = "5d9d938139db425867a30cc0cfec0269406d8238d0571d829041eaa7a8455d11"
494473
dependencies = [
495474
"chalk-derive",
496475
"chalk-engine",
497476
"chalk-ir",
498-
"chalk-macros",
499-
"chalk-rust-ir",
500-
"ena 0.13.1",
477+
"ena",
501478
"itertools 0.9.0",
502479
"petgraph",
503480
"rustc-hash",
@@ -1061,15 +1038,6 @@ dependencies = [
10611038
"strum_macros",
10621039
]
10631040

1064-
[[package]]
1065-
name = "ena"
1066-
version = "0.13.1"
1067-
source = "registry+https://github.com/rust-lang/crates.io-index"
1068-
checksum = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36"
1069-
dependencies = [
1070-
"log",
1071-
]
1072-
10731041
[[package]]
10741042
name = "ena"
10751043
version = "0.14.0"
@@ -1181,9 +1149,9 @@ dependencies = [
11811149

11821150
[[package]]
11831151
name = "fixedbitset"
1184-
version = "0.1.9"
1152+
version = "0.2.0"
11851153
source = "registry+https://github.com/rust-lang/crates.io-index"
1186-
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
1154+
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
11871155

11881156
[[package]]
11891157
name = "flate2"
@@ -2370,12 +2338,6 @@ dependencies = [
23702338
"vcpkg",
23712339
]
23722340

2373-
[[package]]
2374-
name = "ordermap"
2375-
version = "0.3.5"
2376-
source = "registry+https://github.com/rust-lang/crates.io-index"
2377-
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
2378-
23792341
[[package]]
23802342
name = "ordslice"
23812343
version = "0.3.0"
@@ -2546,12 +2508,12 @@ dependencies = [
25462508

25472509
[[package]]
25482510
name = "petgraph"
2549-
version = "0.4.13"
2511+
version = "0.5.1"
25502512
source = "registry+https://github.com/rust-lang/crates.io-index"
2551-
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
2513+
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
25522514
dependencies = [
25532515
"fixedbitset",
2554-
"ordermap",
2516+
"indexmap",
25552517
]
25562518

25572519
[[package]]
@@ -3292,7 +3254,7 @@ dependencies = [
32923254
"bitflags",
32933255
"cfg-if",
32943256
"crossbeam-utils 0.7.2",
3295-
"ena 0.14.0",
3257+
"ena",
32963258
"indexmap",
32973259
"jobserver",
32983260
"lazy_static",
@@ -3501,12 +3463,9 @@ dependencies = [
35013463

35023464
[[package]]
35033465
name = "rustc-hash"
3504-
version = "1.0.1"
3466+
version = "1.1.0"
35053467
source = "registry+https://github.com/rust-lang/crates.io-index"
3506-
checksum = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
3507-
dependencies = [
3508-
"byteorder",
3509-
]
3468+
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
35103469

35113470
[[package]]
35123471
name = "rustc-main"
@@ -3757,7 +3716,7 @@ dependencies = [
37573716
"bitflags",
37583717
"cfg-if",
37593718
"crossbeam-utils 0.7.2",
3760-
"ena 0.14.0",
3719+
"ena",
37613720
"indexmap",
37623721
"jobserver",
37633722
"lazy_static",
@@ -4376,7 +4335,6 @@ name = "rustc_traits"
43764335
version = "0.0.0"
43774336
dependencies = [
43784337
"chalk-ir",
4379-
"chalk-rust-ir",
43804338
"chalk-solve",
43814339
"log",
43824340
"rustc_ast",

src/librustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ crossbeam-utils = { version = "0.7", features = ["nightly"] }
2323
stable_deref_trait = "1.0.0"
2424
rayon = { version = "0.3.0", package = "rustc-rayon" }
2525
rayon-core = { version = "0.3.0", package = "rustc-rayon-core" }
26-
rustc-hash = "1.0.1"
26+
rustc-hash = "1.1.0"
2727
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
2828
rustc_index = { path = "../librustc_index", package = "rustc_index" }
2929
bitflags = "1.2.1"

src/librustc_middle/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ rustc_serialize = { path = "../librustc_serialize" }
3030
rustc_ast = { path = "../librustc_ast" }
3131
rustc_span = { path = "../librustc_span" }
3232
byteorder = { version = "1.3" }
33-
chalk-ir = "0.10.0"
33+
chalk-ir = "0.11.0"
3434
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
3535
measureme = "0.7.1"
3636
rustc_session = { path = "../librustc_session" }

src/librustc_middle/traits/chalk.rs

+44-50
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
//! its name suggest, is to provide an abstraction boundary for creating
66
//! interned Chalk types.
77
8-
use chalk_ir::{GoalData, Parameter};
9-
10-
use rustc_middle::mir::Mutability;
8+
use rustc_middle::mir::interpret::ConstValue;
119
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
12-
use rustc_middle::ty::{self, Ty, TyCtxt};
10+
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
1311

1412
use rustc_hir::def_id::DefId;
1513

@@ -19,27 +17,6 @@ use std::cmp::Ordering;
1917
use std::fmt;
2018
use std::hash::{Hash, Hasher};
2119

22-
/// Since Chalk doesn't have full support for all Rust builtin types yet, we
23-
/// need to use an enum here, rather than just `DefId`.
24-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
25-
pub enum RustDefId {
26-
Adt(DefId),
27-
Str,
28-
Never,
29-
Slice,
30-
Array,
31-
Ref(Mutability),
32-
RawPtr,
33-
34-
Trait(DefId),
35-
36-
Impl(DefId),
37-
38-
FnDef(DefId),
39-
40-
AssocTy(DefId),
41-
}
42-
4320
#[derive(Copy, Clone)]
4421
pub struct RustInterner<'tcx> {
4522
pub tcx: TyCtxt<'tcx>,
@@ -86,16 +63,19 @@ impl fmt::Debug for RustInterner<'_> {
8663
impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
8764
type InternedType = Box<chalk_ir::TyData<Self>>;
8865
type InternedLifetime = Box<chalk_ir::LifetimeData<Self>>;
89-
type InternedParameter = Box<chalk_ir::ParameterData<Self>>;
66+
type InternedConst = Box<chalk_ir::ConstData<Self>>;
67+
type InternedConcreteConst = ConstValue<'tcx>;
68+
type InternedGenericArg = Box<chalk_ir::GenericArgData<Self>>;
9069
type InternedGoal = Box<chalk_ir::GoalData<Self>>;
9170
type InternedGoals = Vec<chalk_ir::Goal<Self>>;
92-
type InternedSubstitution = Vec<chalk_ir::Parameter<Self>>;
71+
type InternedSubstitution = Vec<chalk_ir::GenericArg<Self>>;
9372
type InternedProgramClause = Box<chalk_ir::ProgramClauseData<Self>>;
9473
type InternedProgramClauses = Vec<chalk_ir::ProgramClause<Self>>;
9574
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
96-
type InternedParameterKinds = Vec<chalk_ir::ParameterKind<()>>;
97-
type InternedCanonicalVarKinds = Vec<chalk_ir::ParameterKind<chalk_ir::UniverseIndex>>;
98-
type DefId = RustDefId;
75+
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
76+
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
77+
type DefId = DefId;
78+
type InternedAdtId = &'tcx AdtDef;
9979
type Identifier = ();
10080

10181
fn debug_program_clause_implication(
@@ -209,25 +189,39 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
209189
&lifetime
210190
}
211191

212-
fn intern_parameter(
192+
fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
193+
Box::new(constant)
194+
}
195+
196+
fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
197+
&constant
198+
}
199+
200+
fn const_eq(
213201
&self,
214-
parameter: chalk_ir::ParameterData<Self>,
215-
) -> Self::InternedParameter {
216-
Box::new(parameter)
202+
_ty: &Self::InternedType,
203+
c1: &Self::InternedConcreteConst,
204+
c2: &Self::InternedConcreteConst,
205+
) -> bool {
206+
c1 == c2
207+
}
208+
209+
fn intern_generic_arg(&self, data: chalk_ir::GenericArgData<Self>) -> Self::InternedGenericArg {
210+
Box::new(data)
217211
}
218212

219-
fn parameter_data<'a>(
213+
fn generic_arg_data<'a>(
220214
&self,
221-
parameter: &'a Self::InternedParameter,
222-
) -> &'a chalk_ir::ParameterData<Self> {
223-
&parameter
215+
data: &'a Self::InternedGenericArg,
216+
) -> &'a chalk_ir::GenericArgData<Self> {
217+
&data
224218
}
225219

226-
fn intern_goal(&self, goal: GoalData<Self>) -> Self::InternedGoal {
220+
fn intern_goal(&self, goal: chalk_ir::GoalData<Self>) -> Self::InternedGoal {
227221
Box::new(goal)
228222
}
229223

230-
fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> {
224+
fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a chalk_ir::GoalData<Self> {
231225
&goal
232226
}
233227

@@ -244,15 +238,15 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
244238

245239
fn intern_substitution<E>(
246240
&self,
247-
data: impl IntoIterator<Item = Result<chalk_ir::Parameter<Self>, E>>,
241+
data: impl IntoIterator<Item = Result<chalk_ir::GenericArg<Self>, E>>,
248242
) -> Result<Self::InternedSubstitution, E> {
249243
data.into_iter().collect::<Result<Vec<_>, _>>()
250244
}
251245

252246
fn substitution_data<'a>(
253247
&self,
254248
substitution: &'a Self::InternedSubstitution,
255-
) -> &'a [Parameter<Self>] {
249+
) -> &'a [chalk_ir::GenericArg<Self>] {
256250
substitution
257251
}
258252

@@ -298,31 +292,31 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
298292
clauses
299293
}
300294

301-
fn intern_parameter_kinds<E>(
295+
fn intern_generic_arg_kinds<E>(
302296
&self,
303-
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<()>, E>>,
304-
) -> Result<Self::InternedParameterKinds, E> {
297+
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
298+
) -> Result<Self::InternedVariableKinds, E> {
305299
data.into_iter().collect::<Result<Vec<_>, _>>()
306300
}
307301

308-
fn parameter_kinds_data<'a>(
302+
fn variable_kinds_data<'a>(
309303
&self,
310-
parameter_kinds: &'a Self::InternedParameterKinds,
311-
) -> &'a [chalk_ir::ParameterKind<()>] {
304+
parameter_kinds: &'a Self::InternedVariableKinds,
305+
) -> &'a [chalk_ir::VariableKind<Self>] {
312306
parameter_kinds
313307
}
314308

315309
fn intern_canonical_var_kinds<E>(
316310
&self,
317-
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<chalk_ir::UniverseIndex>, E>>,
311+
data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
318312
) -> Result<Self::InternedCanonicalVarKinds, E> {
319313
data.into_iter().collect::<Result<Vec<_>, _>>()
320314
}
321315

322316
fn canonical_var_kinds_data<'a>(
323317
&self,
324318
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
325-
) -> &'a [chalk_ir::ParameterKind<chalk_ir::UniverseIndex>] {
319+
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
326320
canonical_var_kinds
327321
}
328322
}

src/librustc_middle/traits/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ pub use self::ObligationCauseCode::*;
3333
pub use self::SelectionError::*;
3434

3535
pub use self::chalk::{
36-
ChalkEnvironmentAndGoal, ChalkEnvironmentClause, RustDefId as ChalkRustDefId,
37-
RustInterner as ChalkRustInterner,
36+
ChalkEnvironmentAndGoal, ChalkEnvironmentClause, RustInterner as ChalkRustInterner,
3837
};
3938

4039
/// Depending on the stage of compilation, we want projection to be

0 commit comments

Comments
 (0)