Skip to content

Commit 045dfc0

Browse files
committed
Update chalk
1 parent fb58b7b commit 045dfc0

File tree

7 files changed

+69
-73
lines changed

7 files changed

+69
-73
lines changed

Cargo.lock

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,8 @@ dependencies = [
428428

429429
[[package]]
430430
name = "chalk-derive"
431-
version = "0.10.0"
432-
source = "registry+https://github.com/rust-lang/crates.io-index"
433-
checksum = "8d4620afad4d4d9e63f915cfa10c930b7a3c9c3ca5cd88dd771ff8e5bf04ea10"
431+
version = "0.10.1-dev"
432+
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
434433
dependencies = [
435434
"proc-macro2 1.0.3",
436435
"quote 1.0.2",
@@ -440,19 +439,17 @@ dependencies = [
440439

441440
[[package]]
442441
name = "chalk-engine"
443-
version = "0.10.0"
444-
source = "registry+https://github.com/rust-lang/crates.io-index"
445-
checksum = "6ca6e5cef10197789da0b4ec310eda58da4c55530613b2323432642a97372735"
442+
version = "0.10.1-dev"
443+
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
446444
dependencies = [
447445
"chalk-macros",
448446
"rustc-hash",
449447
]
450448

451449
[[package]]
452450
name = "chalk-ir"
453-
version = "0.10.0"
454-
source = "registry+https://github.com/rust-lang/crates.io-index"
455-
checksum = "d45df5fb6328527f976e8a32c9e1c9970084d937ebe93d0d34f5bbf4231cb956"
451+
version = "0.10.1-dev"
452+
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
456453
dependencies = [
457454
"chalk-derive",
458455
"chalk-engine",
@@ -461,18 +458,16 @@ dependencies = [
461458

462459
[[package]]
463460
name = "chalk-macros"
464-
version = "0.10.0"
465-
source = "registry+https://github.com/rust-lang/crates.io-index"
466-
checksum = "9e4782d108e420a1fcf94d8a919cf248db33c5071678e87d9c2d4f20ed1feb32"
461+
version = "0.10.1-dev"
462+
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
467463
dependencies = [
468464
"lazy_static",
469465
]
470466

471467
[[package]]
472468
name = "chalk-rust-ir"
473-
version = "0.10.0"
474-
source = "registry+https://github.com/rust-lang/crates.io-index"
475-
checksum = "a0ec96dbe0ab5fdbadfca4179ec2e1d35f0439c3b53a74988b1aec239c63eb08"
469+
version = "0.10.1-dev"
470+
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
476471
dependencies = [
477472
"chalk-derive",
478473
"chalk-engine",
@@ -482,9 +477,8 @@ dependencies = [
482477

483478
[[package]]
484479
name = "chalk-solve"
485-
version = "0.10.0"
486-
source = "registry+https://github.com/rust-lang/crates.io-index"
487-
checksum = "dfb99fa9530f0e101475fb60adc931f51bdea05b4642a48928b814d7f0141a6b"
480+
version = "0.10.1-dev"
481+
source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3"
488482
dependencies = [
489483
"chalk-derive",
490484
"chalk-engine",

src/librustc_middle/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ 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 = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" }
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/traits/chalk.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
88
use chalk_ir::{GoalData, Parameter};
99

10-
use rustc_middle::mir::Mutability;
1110
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
1211
use rustc_middle::ty::{self, Ty, TyCtxt};
1312

@@ -24,16 +23,12 @@ use std::hash::{Hash, Hasher};
2423
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
2524
pub enum RustDefId {
2625
Adt(DefId),
27-
Str,
2826
Never,
29-
Slice,
3027
Array,
31-
Ref(Mutability),
32-
RawPtr,
28+
FnDef(DefId),
3329

3430
Trait(DefId),
3531
Impl(DefId),
36-
FnDef(DefId),
3732
AssocTy(DefId),
3833
Opaque(DefId),
3934
}

src/librustc_traits/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ rustc_hir = { path = "../librustc_hir" }
1616
rustc_index = { path = "../librustc_index" }
1717
rustc_ast = { path = "../librustc_ast" }
1818
rustc_span = { path = "../librustc_span" }
19-
chalk-ir = "0.10.0"
20-
chalk-rust-ir = "0.10.0"
21-
chalk-solve = "0.10.0"
19+
#chalk-ir = "0.10.0"
20+
#chalk-rust-ir = "0.10.0"
21+
#chalk-solve = "0.10.0"
22+
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" }
23+
chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" }
24+
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" }
2225
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
2326
rustc_infer = { path = "../librustc_infer" }
2427
rustc_trait_selection = { path = "../librustc_trait_selection" }

src/librustc_traits/chalk/db.rs

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -168,41 +168,25 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
168168
});
169169
struct_datum
170170
}
171-
RustDefId::Ref(_) | RustDefId::RawPtr => Arc::new(chalk_rust_ir::StructDatum {
171+
RustDefId::Array => Arc::new(chalk_rust_ir::StructDatum {
172172
id: struct_id,
173173
binders: chalk_ir::Binders::new(
174174
chalk_ir::ParameterKinds::from(
175175
&self.interner,
176-
vec![
177-
chalk_ir::ParameterKind::Lifetime(()),
178-
chalk_ir::ParameterKind::Ty(()),
179-
],
176+
Some(chalk_ir::ParameterKind::Ty(())),
180177
),
181178
chalk_rust_ir::StructDatumBound { fields: vec![], where_clauses: vec![] },
182179
),
183180
flags: chalk_rust_ir::StructFlags { upstream: false, fundamental: false },
184181
}),
185-
RustDefId::Array | RustDefId::Slice => Arc::new(chalk_rust_ir::StructDatum {
182+
RustDefId::Never | RustDefId::FnDef(_) => Arc::new(chalk_rust_ir::StructDatum {
186183
id: struct_id,
187184
binders: chalk_ir::Binders::new(
188-
chalk_ir::ParameterKinds::from(
189-
&self.interner,
190-
Some(chalk_ir::ParameterKind::Ty(())),
191-
),
185+
chalk_ir::ParameterKinds::new(&self.interner),
192186
chalk_rust_ir::StructDatumBound { fields: vec![], where_clauses: vec![] },
193187
),
194188
flags: chalk_rust_ir::StructFlags { upstream: false, fundamental: false },
195189
}),
196-
RustDefId::Str | RustDefId::Never | RustDefId::FnDef(_) => {
197-
Arc::new(chalk_rust_ir::StructDatum {
198-
id: struct_id,
199-
binders: chalk_ir::Binders::new(
200-
chalk_ir::ParameterKinds::new(&self.interner),
201-
chalk_rust_ir::StructDatumBound { fields: vec![], where_clauses: vec![] },
202-
),
203-
flags: chalk_rust_ir::StructFlags { upstream: false, fundamental: false },
204-
})
205-
}
206190

207191
v => bug!("Used not struct variant ({:?}) when expecting struct variant.", v),
208192
}
@@ -286,12 +270,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
286270
// FIXME(chalk): this match can be removed when builtin types supported
287271
match struct_id.0 {
288272
RustDefId::Adt(_) => {}
289-
RustDefId::Str => return false,
290273
RustDefId::Never => return false,
291-
RustDefId::Slice => return false,
292274
RustDefId::Array => return false,
293-
RustDefId::Ref(_) => return false,
294-
RustDefId::RawPtr => return false,
295275
_ => bug!("Did not use `Adt` variant when expecting adt."),
296276
}
297277
let adt_def_id: DefId = match struct_id.0 {
@@ -388,7 +368,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
388368
chalk_ir::TypeName::Struct(chalk_ir::StructId(rust_def_id)) => {
389369
use rustc_middle::traits::ChalkRustDefId::*;
390370
match rust_def_id {
391-
Never | Array | RawPtr | FnDef(_) | Ref(_) => Some(true),
371+
Never | Array | FnDef(_) => Some(true),
392372

393373
Adt(adt_def_id) => {
394374
let adt_def = self.tcx.adt_def(adt_def_id);
@@ -405,8 +385,6 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
405385
}
406386
}
407387

408-
Str | Slice => Some(false),
409-
410388
Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(),
411389
}
412390
}
@@ -421,7 +399,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
421399
chalk_ir::TypeName::Struct(chalk_ir::StructId(rust_def_id)) => {
422400
use rustc_middle::traits::ChalkRustDefId::*;
423401
match rust_def_id {
424-
Never | RawPtr | Ref(_) | Str | Slice => Some(false),
402+
Never => Some(false),
425403
FnDef(_) | Array => Some(true),
426404
Adt(adt_def_id) => {
427405
let adt_def = self.tcx.adt_def(adt_def_id);
@@ -489,6 +467,14 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
489467
};
490468
Some(t)
491469
}
470+
471+
fn is_object_safe(&self, trait_id: chalk_ir::TraitId<RustInterner<'tcx>>) -> bool {
472+
let def_id: DefId = match trait_id.0 {
473+
RustDefId::Trait(def_id) => def_id,
474+
_ => bug!("Did not use `Trait` variant when expecting trait."),
475+
};
476+
self.tcx.is_object_safe(def_id)
477+
}
492478
}
493479

494480
/// Creates a `InternalSubsts` that maps each generic parameter to a higher-ranked

src/librustc_traits/chalk/lowering.rs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
309309
apply(struct_ty(RustDefId::Adt(def.did)), substs.lower_into(interner))
310310
}
311311
Foreign(_def_id) => unimplemented!(),
312-
Str => apply(struct_ty(RustDefId::Str), empty()),
312+
Str => apply(chalk_ir::TypeName::Str, empty()),
313313
Array(ty, _) => apply(
314314
struct_ty(RustDefId::Array),
315315
chalk_ir::Substitution::from1(
@@ -318,25 +318,36 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
318318
),
319319
),
320320
Slice(ty) => apply(
321-
struct_ty(RustDefId::Slice),
321+
chalk_ir::TypeName::Slice,
322322
chalk_ir::Substitution::from1(
323323
interner,
324324
chalk_ir::ParameterKind::Ty(ty.lower_into(interner)).intern(interner),
325325
),
326326
),
327-
RawPtr(_) => apply(struct_ty(RustDefId::RawPtr), empty()),
328-
Ref(region, ty, mutability) => apply(
329-
struct_ty(RustDefId::Ref(mutability)),
330-
chalk_ir::Substitution::from(
331-
interner,
332-
[
333-
chalk_ir::ParameterKind::Lifetime(region.lower_into(interner))
334-
.intern(interner),
335-
chalk_ir::ParameterKind::Ty(ty.lower_into(interner)).intern(interner),
336-
]
337-
.iter(),
338-
),
339-
),
327+
RawPtr(ptr) => {
328+
let name = match ptr.mutbl {
329+
ast::Mutability::Mut => chalk_ir::TypeName::Raw(chalk_ir::Mutability::Mut),
330+
ast::Mutability::Not => chalk_ir::TypeName::Raw(chalk_ir::Mutability::Not),
331+
};
332+
apply(name, chalk_ir::Substitution::from1(interner, ptr.ty.lower_into(interner)))
333+
}
334+
Ref(region, ty, mutability) => {
335+
let name = match mutability {
336+
ast::Mutability::Mut => chalk_ir::TypeName::Ref(chalk_ir::Mutability::Mut),
337+
ast::Mutability::Not => chalk_ir::TypeName::Ref(chalk_ir::Mutability::Not),
338+
};
339+
apply(
340+
name,
341+
chalk_ir::Substitution::from(
342+
interner,
343+
&[
344+
chalk_ir::ParameterKind::Lifetime(region.lower_into(interner))
345+
.intern(interner),
346+
chalk_ir::ParameterKind::Ty(ty.lower_into(interner)).intern(interner),
347+
],
348+
),
349+
)
350+
}
340351
FnDef(def_id, _) => apply(struct_ty(RustDefId::FnDef(def_id)), empty()),
341352
FnPtr(sig) => {
342353
let (inputs_and_outputs, binders, _named_regions) =

src/librustc_traits/chalk/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ crate fn evaluate_goal<'tcx>(
109109
let kind = match _data {
110110
TyData::Apply(_application_ty) => match _application_ty.name {
111111
chalk_ir::TypeName::Struct(_struct_id) => match _struct_id.0 {
112+
RustDefId::Adt(_) => unimplemented!(),
113+
RustDefId::Never => unimplemented!(),
112114
RustDefId::Array => unimplemented!(),
113-
RustDefId::Slice => unimplemented!(),
114-
_ => unimplemented!(),
115+
RustDefId::FnDef(_) => unimplemented!(),
116+
_ => panic!("Unexpected struct id"),
115117
},
116118
chalk_ir::TypeName::Scalar(scalar) => match scalar {
117119
chalk_ir::Scalar::Bool => ty::Bool,
@@ -138,6 +140,10 @@ crate fn evaluate_goal<'tcx>(
138140
},
139141
},
140142
chalk_ir::TypeName::Tuple(_size) => unimplemented!(),
143+
chalk_ir::TypeName::Slice => unimplemented!(),
144+
chalk_ir::TypeName::Raw(_) => unimplemented!(),
145+
chalk_ir::TypeName::Ref(_) => unimplemented!(),
146+
chalk_ir::TypeName::Str => unimplemented!(),
141147
chalk_ir::TypeName::OpaqueType(_ty) => unimplemented!(),
142148
chalk_ir::TypeName::AssociatedType(_assoc_ty) => unimplemented!(),
143149
chalk_ir::TypeName::Error => unimplemented!(),

0 commit comments

Comments
 (0)