Skip to content

Commit 299a65f

Browse files
committed
Update chalk 0.32.0 -> 0.35.0
1 parent 1f5c655 commit 299a65f

File tree

7 files changed

+214
-304
lines changed

7 files changed

+214
-304
lines changed

Cargo.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
460460

461461
[[package]]
462462
name = "chalk-derive"
463-
version = "0.32.0"
463+
version = "0.35.0"
464464
source = "registry+https://github.com/rust-lang/crates.io-index"
465-
checksum = "2d072b2ba723f0bada7c515d8b3725224bc4f5052d2a92dcbeb0b118ff37084a"
465+
checksum = "bc6d2895e93c0939074a7a0f525fd549b49da8362dea3def555e4aab95ff64cd"
466466
dependencies = [
467467
"proc-macro2",
468468
"quote",
@@ -472,9 +472,9 @@ dependencies = [
472472

473473
[[package]]
474474
name = "chalk-engine"
475-
version = "0.32.0"
475+
version = "0.35.0"
476476
source = "registry+https://github.com/rust-lang/crates.io-index"
477-
checksum = "6fb5475f6083d6d6c509e1c335c4f69ad04144ac090faa1afb134a53c3695841"
477+
checksum = "93ed23c35d243ccc2caeae7ba4660a091e74b11c40e441d7849f07d8e71b5cb8"
478478
dependencies = [
479479
"chalk-derive",
480480
"chalk-ir",
@@ -485,19 +485,19 @@ dependencies = [
485485

486486
[[package]]
487487
name = "chalk-ir"
488-
version = "0.32.0"
488+
version = "0.35.0"
489489
source = "registry+https://github.com/rust-lang/crates.io-index"
490-
checksum = "f60cdb0e18c5455cb6a85e8464aad3622b70476018edfa8845691df66f7e9a05"
490+
checksum = "40d7f6140cccc889117e7372b6f9cfbc8103c86a1a0269ff6ab868f20ab414d6"
491491
dependencies = [
492492
"chalk-derive",
493493
"lazy_static",
494494
]
495495

496496
[[package]]
497497
name = "chalk-solve"
498-
version = "0.32.0"
498+
version = "0.35.0"
499499
source = "registry+https://github.com/rust-lang/crates.io-index"
500-
checksum = "981534d499a8476ecc0b520be4d3864757f96211826a75360fbf2cb6fae362ab"
500+
checksum = "fa65b636e64cbfcba31f053da97c32f3e15f2670b3cc620b84231a1656d754ec"
501501
dependencies = [
502502
"chalk-derive",
503503
"chalk-ir",

compiler/rustc_middle/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" }
2626
rustc_serialize = { path = "../rustc_serialize" }
2727
rustc_ast = { path = "../rustc_ast" }
2828
rustc_span = { path = "../rustc_span" }
29-
chalk-ir = "0.32.0"
29+
chalk-ir = "0.35.0"
3030
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
3131
measureme = "9.0.0"
3232
rustc_session = { path = "../rustc_session" }

compiler/rustc_middle/src/traits/chalk.rs

+26-42
Original file line numberDiff line numberDiff line change
@@ -102,48 +102,6 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
102102
Some(write())
103103
}
104104

105-
fn debug_application_ty(
106-
application_ty: &chalk_ir::ApplicationTy<Self>,
107-
fmt: &mut fmt::Formatter<'_>,
108-
) -> Option<fmt::Result> {
109-
match application_ty.name {
110-
chalk_ir::TypeName::Ref(mutbl) => {
111-
let data = application_ty.substitution.interned();
112-
match (&**data[0].interned(), &**data[1].interned()) {
113-
(
114-
chalk_ir::GenericArgData::Lifetime(lifetime),
115-
chalk_ir::GenericArgData::Ty(ty),
116-
) => Some(match mutbl {
117-
chalk_ir::Mutability::Not => write!(fmt, "(&{:?} {:?})", lifetime, ty),
118-
chalk_ir::Mutability::Mut => write!(fmt, "(&{:?} mut {:?})", lifetime, ty),
119-
}),
120-
_ => unreachable!(),
121-
}
122-
}
123-
chalk_ir::TypeName::Array => {
124-
let data = application_ty.substitution.interned();
125-
match (&**data[0].interned(), &**data[1].interned()) {
126-
(chalk_ir::GenericArgData::Ty(ty), chalk_ir::GenericArgData::Const(len)) => {
127-
Some(write!(fmt, "[{:?}; {:?}]", ty, len))
128-
}
129-
_ => unreachable!(),
130-
}
131-
}
132-
chalk_ir::TypeName::Slice => {
133-
let data = application_ty.substitution.interned();
134-
let ty = match &**data[0].interned() {
135-
chalk_ir::GenericArgData::Ty(t) => t,
136-
_ => unreachable!(),
137-
};
138-
Some(write!(fmt, "[{:?}]", ty))
139-
}
140-
_ => {
141-
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
142-
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
143-
}
144-
}
145-
}
146-
147105
fn debug_substitution(
148106
substitution: &chalk_ir::Substitution<Self>,
149107
fmt: &mut fmt::Formatter<'_>,
@@ -174,6 +132,32 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
174132
Some(write!(fmt, "{:?}", clauses.interned()))
175133
}
176134

135+
fn debug_ty(ty: &chalk_ir::Ty<Self>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
136+
match &ty.interned().kind {
137+
chalk_ir::TyKind::Ref(chalk_ir::Mutability::Not, lifetime, ty) => {
138+
Some(write!(fmt, "(&{:?} {:?})", lifetime, ty))
139+
}
140+
chalk_ir::TyKind::Ref(chalk_ir::Mutability::Mut, lifetime, ty) => {
141+
Some(write!(fmt, "(&{:?} mut {:?})", lifetime, ty))
142+
}
143+
chalk_ir::TyKind::Array(ty, len) => Some(write!(fmt, "[{:?}; {:?}]", ty, len)),
144+
chalk_ir::TyKind::Slice(ty) => Some(write!(fmt, "[{:?}]", ty)),
145+
chalk_ir::TyKind::Tuple(len, substs) => Some((|| {
146+
write!(fmt, "(")?;
147+
for (idx, substitution) in substs.interned().iter().enumerate() {
148+
if idx == *len && *len != 1 {
149+
// Don't add a trailing comma if the tuple has more than one element
150+
write!(fmt, "{:?}", substitution)?;
151+
} else {
152+
write!(fmt, "{:?},", substitution)?;
153+
}
154+
}
155+
write!(fmt, ")")
156+
})()),
157+
_ => None,
158+
}
159+
}
160+
177161
fn debug_alias(
178162
alias_ty: &chalk_ir::AliasTy<Self>,
179163
fmt: &mut fmt::Formatter<'_>,

compiler/rustc_traits/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +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.32.0"
16-
chalk-solve = "0.32.0"
17-
chalk-engine = "0.32.0"
15+
chalk-ir = "0.35.0"
16+
chalk-solve = "0.35.0"
17+
chalk-engine = "0.35.0"
1818
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
1919
rustc_infer = { path = "../rustc_infer" }
2020
rustc_trait_selection = { path = "../rustc_trait_selection" }

compiler/rustc_traits/src/chalk/db.rs

+34-42
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
324324
fn impl_provided_for(
325325
&self,
326326
auto_trait_id: chalk_ir::TraitId<RustInterner<'tcx>>,
327-
app_ty: &chalk_ir::ApplicationTy<RustInterner<'tcx>>,
327+
chalk_ty: &chalk_ir::TyKind<RustInterner<'tcx>>,
328328
) -> bool {
329329
use chalk_ir::Scalar::*;
330-
use chalk_ir::TypeName::*;
330+
use chalk_ir::TyKind::*;
331331

332332
let trait_def_id = auto_trait_id.0;
333333
let all_impls = self.interner.tcx.all_impls(trait_def_id);
334334
for impl_def_id in all_impls {
335335
let trait_ref = self.interner.tcx.impl_trait_ref(impl_def_id).unwrap();
336336
let self_ty = trait_ref.self_ty();
337-
let provides = match (self_ty.kind(), app_ty.name) {
338-
(&ty::Adt(impl_adt_def, ..), Adt(id)) => impl_adt_def.did == id.0.did,
339-
(_, AssociatedType(_ty_id)) => {
337+
let provides = match (self_ty.kind(), chalk_ty) {
338+
(&ty::Adt(impl_adt_def, ..), Adt(id, ..)) => impl_adt_def.did == id.0.did,
339+
(_, AssociatedType(_ty_id, ..)) => {
340340
// FIXME(chalk): See https://github.com/rust-lang/rust/pull/77152#discussion_r494484774
341341
false
342342
}
@@ -365,28 +365,30 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
365365
(ast::FloatTy::F32, chalk_ir::FloatTy::F32)
366366
| (ast::FloatTy::F64, chalk_ir::FloatTy::F64)
367367
),
368-
(&ty::Tuple(..), Tuple(..)) => true,
369-
(&ty::Array(..), Array) => true,
370-
(&ty::Slice(..), Slice) => true,
371-
(&ty::RawPtr(type_and_mut), Raw(mutability)) => {
368+
(&ty::Tuple(substs), Tuple(len, _)) => substs.len() == *len,
369+
(&ty::Array(..), Array(..)) => true,
370+
(&ty::Slice(..), Slice(..)) => true,
371+
(&ty::RawPtr(type_and_mut), Raw(mutability, _)) => {
372372
match (type_and_mut.mutbl, mutability) {
373373
(ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true,
374374
(ast::Mutability::Mut, chalk_ir::Mutability::Not) => false,
375375
(ast::Mutability::Not, chalk_ir::Mutability::Mut) => false,
376376
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
377377
}
378378
}
379-
(&ty::Ref(.., mutability1), Ref(mutability2)) => match (mutability1, mutability2) {
380-
(ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true,
381-
(ast::Mutability::Mut, chalk_ir::Mutability::Not) => false,
382-
(ast::Mutability::Not, chalk_ir::Mutability::Mut) => false,
383-
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
384-
},
385-
(&ty::Opaque(def_id, ..), OpaqueType(opaque_ty_id)) => def_id == opaque_ty_id.0,
386-
(&ty::FnDef(def_id, ..), FnDef(fn_def_id)) => def_id == fn_def_id.0,
379+
(&ty::Ref(.., mutability1), Ref(mutability2, ..)) => {
380+
match (mutability1, mutability2) {
381+
(ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true,
382+
(ast::Mutability::Mut, chalk_ir::Mutability::Not) => false,
383+
(ast::Mutability::Not, chalk_ir::Mutability::Mut) => false,
384+
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
385+
}
386+
}
387+
(&ty::Opaque(def_id, ..), OpaqueType(opaque_ty_id, ..)) => def_id == opaque_ty_id.0,
388+
(&ty::FnDef(def_id, ..), FnDef(fn_def_id, ..)) => def_id == fn_def_id.0,
387389
(&ty::Str, Str) => true,
388390
(&ty::Never, Never) => true,
389-
(&ty::Closure(def_id, ..), Closure(closure_id)) => def_id == closure_id.0,
391+
(&ty::Closure(def_id, ..), Closure(closure_id, _)) => def_id == closure_id.0,
390392
(&ty::Foreign(def_id), Foreign(foreign_def_id)) => def_id == foreign_def_id.0,
391393
(&ty::Error(..), Error) => false,
392394
_ => false,
@@ -506,17 +508,11 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
506508
substs: &chalk_ir::Substitution<RustInterner<'tcx>>,
507509
) -> chalk_solve::rust_ir::ClosureKind {
508510
let kind = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 3];
509-
match kind.assert_ty_ref(&self.interner).data(&self.interner) {
510-
chalk_ir::TyData::Apply(apply) => match apply.name {
511-
chalk_ir::TypeName::Scalar(scalar) => match scalar {
512-
chalk_ir::Scalar::Int(int_ty) => match int_ty {
513-
chalk_ir::IntTy::I8 => chalk_solve::rust_ir::ClosureKind::Fn,
514-
chalk_ir::IntTy::I16 => chalk_solve::rust_ir::ClosureKind::FnMut,
515-
chalk_ir::IntTy::I32 => chalk_solve::rust_ir::ClosureKind::FnOnce,
516-
_ => bug!("bad closure kind"),
517-
},
518-
_ => bug!("bad closure kind"),
519-
},
511+
match kind.assert_ty_ref(&self.interner).kind(&self.interner) {
512+
chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(int_ty)) => match int_ty {
513+
chalk_ir::IntTy::I8 => chalk_solve::rust_ir::ClosureKind::Fn,
514+
chalk_ir::IntTy::I16 => chalk_solve::rust_ir::ClosureKind::FnMut,
515+
chalk_ir::IntTy::I32 => chalk_solve::rust_ir::ClosureKind::FnOnce,
520516
_ => bug!("bad closure kind"),
521517
},
522518
_ => bug!("bad closure kind"),
@@ -530,23 +526,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
530526
) -> chalk_ir::Binders<chalk_solve::rust_ir::FnDefInputsAndOutputDatum<RustInterner<'tcx>>>
531527
{
532528
let sig = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 2];
533-
match sig.assert_ty_ref(&self.interner).data(&self.interner) {
534-
chalk_ir::TyData::Function(f) => {
529+
match sig.assert_ty_ref(&self.interner).kind(&self.interner) {
530+
chalk_ir::TyKind::Function(f) => {
535531
let substitution = f.substitution.as_slice(&self.interner);
536532
let return_type =
537533
substitution.last().unwrap().assert_ty_ref(&self.interner).clone();
538534
// Closure arguments are tupled
539535
let argument_tuple = substitution[0].assert_ty_ref(&self.interner);
540-
let argument_types = match argument_tuple.data(&self.interner) {
541-
chalk_ir::TyData::Apply(apply) => match apply.name {
542-
chalk_ir::TypeName::Tuple(_) => apply
543-
.substitution
544-
.iter(&self.interner)
545-
.map(|arg| arg.assert_ty_ref(&self.interner))
546-
.cloned()
547-
.collect(),
548-
_ => bug!("Expecting closure FnSig args to be tupled."),
549-
},
536+
let argument_types = match argument_tuple.kind(&self.interner) {
537+
chalk_ir::TyKind::Tuple(_len, substitution) => substitution
538+
.iter(&self.interner)
539+
.map(|arg| arg.assert_ty_ref(&self.interner))
540+
.cloned()
541+
.collect(),
550542
_ => bug!("Expecting closure FnSig args to be tupled."),
551543
};
552544

@@ -637,7 +629,7 @@ fn binders_for<'tcx>(
637629
bound_vars.iter().map(|arg| match arg.unpack() {
638630
ty::subst::GenericArgKind::Lifetime(_re) => chalk_ir::VariableKind::Lifetime,
639631
ty::subst::GenericArgKind::Type(_ty) => {
640-
chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General)
632+
chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General)
641633
}
642634
ty::subst::GenericArgKind::Const(c) => {
643635
chalk_ir::VariableKind::Const(c.ty.lower_into(interner))

0 commit comments

Comments
 (0)