From 6de5f6277eb937095639f5f9586b1f4704e2f9a5 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 13 Nov 2022 19:29:38 +0000 Subject: [PATCH 1/2] Bump chalk to v0.87 --- Cargo.lock | 16 ++++++++-------- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c105d04c1f4..e12d7749dc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -502,9 +502,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.80.0" +version = "0.87.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0001adf0cf12361e08b65e1898ea138f8f77d8f5177cbf29b6b3b3532252bd6" +checksum = "d552b2fa341f5fc35c6b917b1d289d3c3a34d0b74e579390ea6192d6152a8cdb" dependencies = [ "proc-macro2", "quote", @@ -514,9 +514,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.80.0" +version = "0.87.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c44ee96f2d67cb5193d1503f185db1abad9933a1c6e6b4169c176f90baecd393" +checksum = "7e54ac43048cb31c470d7b3e3acd409090ef4a5abddfe02455187aebc3d6879f" dependencies = [ "chalk-derive", "chalk-ir", @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.80.0" +version = "0.87.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d8a95548f23618fda86426e4304e563ec2bb7ba0216139f0748d63c107b5f1" +checksum = "43aa55deff4e7fbdb09fa014543372f2c95a06835ac487b9ce57b5099b950838" dependencies = [ "bitflags", "chalk-derive", @@ -538,9 +538,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.80.0" +version = "0.87.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f37f492dacfafe2e21319b80827da2779932909bb392f0cc86b2bd5c07c1b4e1" +checksum = "61213deefc36ba265ad01c4d997e18bcddf7922862a4594a47ca4575afb3dab4" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 8e7d0cf2ab1..5f6e498dbea 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -8,7 +8,7 @@ doctest = false [dependencies] bitflags = "1.2.1" -chalk-ir = "0.80.0" +chalk-ir = "0.87.0" either = "1.5.0" gsgdt = "0.1.2" polonius-engine = "0.13.0" diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 951554c77fb..9474e6df567 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.80.0" -chalk-engine = "0.80.0" -chalk-solve = "0.80.0" +chalk-ir = "0.87.0" +chalk-engine = "0.87.0" +chalk-solve = "0.87.0" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } From 36a106891a1e410656c8fcbe2109ca53c35759ce Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 13 Nov 2022 19:53:35 +0000 Subject: [PATCH 2/2] Make rustc build with new chalk --- compiler/rustc_traits/src/chalk/db.rs | 3 + compiler/rustc_traits/src/chalk/lowering.rs | 3 - src/test/ui/chalkify/closure.rs | 4 +- src/test/ui/chalkify/closure.stderr | 90 ++++----------------- src/test/ui/chalkify/trait-objects.rs | 3 +- src/test/ui/chalkify/trait-objects.stderr | 32 -------- 6 files changed, 21 insertions(+), 114 deletions(-) delete mode 100644 src/test/ui/chalkify/trait-objects.stderr diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 07f92299f72..d15707e5ced 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -142,6 +142,8 @@ fn trait_datum( Some(CoerceUnsized) } else if lang_items.dispatch_from_dyn_trait() == Some(def_id) { Some(DispatchFromDyn) + } else if lang_items.tuple_trait() == Some(def_id) { + Some(Tuple) } else { None }; @@ -570,6 +572,7 @@ fn well_known_trait_id( CoerceUnsized => lang_items.coerce_unsized_trait(), DiscriminantKind => lang_items.discriminant_kind_trait(), DispatchFromDyn => lang_items.dispatch_from_dyn_trait(), + Tuple => lang_items.tuple_trait(), }; def_id.map(chalk_ir::TraitId) } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index b64d53e60de..25cedefa261 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -507,9 +507,6 @@ fn lower_into(self, interner: RustInterner<'tcx>) -> Region<'tcx> { name: ty::BoundRegionKind::BrAnon(p.idx as u32, None), }), chalk_ir::LifetimeData::Static => return interner.tcx.lifetimes.re_static, - chalk_ir::LifetimeData::Empty(_) => { - bug!("Chalk should not have been passed an empty lifetime.") - } chalk_ir::LifetimeData::Erased => return interner.tcx.lifetimes.re_erased, chalk_ir::LifetimeData::Phantom(void, _) => match *void {}, }; diff --git a/src/test/ui/chalkify/closure.rs b/src/test/ui/chalkify/closure.rs index 408e8802d86..568e2e30c41 100644 --- a/src/test/ui/chalkify/closure.rs +++ b/src/test/ui/chalkify/closure.rs @@ -1,5 +1,3 @@ -// known-bug: unknown -// FIXME(chalk): Chalk needs support for the Tuple trait // compile-flags: -Z chalk fn main() -> () { @@ -26,7 +24,7 @@ fn main() -> () { let mut c = b; c(); - b(); // FIXME: reenable when this is fixed ~ ERROR + b(); //~ ERROR // FIXME(chalk): this doesn't quite work /* diff --git a/src/test/ui/chalkify/closure.stderr b/src/test/ui/chalkify/closure.stderr index bcee0cab96a..a33c0ba0d37 100644 --- a/src/test/ui/chalkify/closure.stderr +++ b/src/test/ui/chalkify/closure.stderr @@ -1,80 +1,22 @@ -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:7:5 - | -LL | t(); - | ^^^ the trait `Tuple` is not implemented for `()` - | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() -> () where (): Tuple { - | +++++++++++++++ - -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:13:5 +error[E0382]: borrow of moved value: `b` + --> $DIR/closure.rs:27:5 | +LL | let mut c = b; + | - value moved here +... LL | b(); - | ^^^ the trait `Tuple` is not implemented for `()` + | ^ value borrowed here after move | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement +note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment + --> $DIR/closure.rs:20:9 | -LL | fn main() -> () where (): Tuple { - | +++++++++++++++ +LL | a = 1; + | ^ +help: consider mutably borrowing `b` + | +LL | let mut c = &mut b; + | ++++ -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:17:5 - | -LL | c(); - | ^^^ the trait `Tuple` is not implemented for `()` - | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() -> () where (): Tuple { - | +++++++++++++++ +error: aborting due to previous error -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:18:5 - | -LL | b(); - | ^^^ the trait `Tuple` is not implemented for `()` - | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() -> () where (): Tuple { - | +++++++++++++++ - -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:24:5 - | -LL | b(); - | ^^^ the trait `Tuple` is not implemented for `()` - | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() -> () where (): Tuple { - | +++++++++++++++ - -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:28:5 - | -LL | c(); - | ^^^ the trait `Tuple` is not implemented for `()` - | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() -> () where (): Tuple { - | +++++++++++++++ - -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:29:5 - | -LL | b(); // FIXME: reenable when this is fixed ~ ERROR - | ^^^ the trait `Tuple` is not implemented for `()` - | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() -> () where (): Tuple { - | +++++++++++++++ - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/chalkify/trait-objects.rs b/src/test/ui/chalkify/trait-objects.rs index 30929e943bd..d56abc42bf5 100644 --- a/src/test/ui/chalkify/trait-objects.rs +++ b/src/test/ui/chalkify/trait-objects.rs @@ -1,5 +1,4 @@ -// known-bug: unknown -// FIXME(chalk): Chalk needs support for the Tuple trait +// check-pass // compile-flags: -Z chalk use std::fmt::Display; diff --git a/src/test/ui/chalkify/trait-objects.stderr b/src/test/ui/chalkify/trait-objects.stderr deleted file mode 100644 index 422d39742eb..00000000000 --- a/src/test/ui/chalkify/trait-objects.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error: the type `&dyn Fn(i32) -> _` is not well-formed (chalk) - --> $DIR/trait-objects.rs:11:12 - | -LL | let f: &dyn Fn(i32) -> _ = &|x| x + x; - | ^^^^^^^^^^^^^^^^^ - -error[E0277]: `(i32,)` is not a tuple - --> $DIR/trait-objects.rs:12:5 - | -LL | f(2); - | ^^^^ the trait `Tuple` is not implemented for `(i32,)` - | -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() where (i32,): Tuple { - | +++++++++++++++++++ - -error[E0277]: expected a `Fn<(i32,)>` closure, found `dyn Fn(i32) -> i32` - --> $DIR/trait-objects.rs:12:5 - | -LL | f(2); - | ^^^^ expected an `Fn<(i32,)>` closure, found `dyn Fn(i32) -> i32` - | - = help: the trait `Fn<(i32,)>` is not implemented for `dyn Fn(i32) -> i32` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() where dyn Fn(i32) -> i32: Fn<(i32,)> { - | ++++++++++++++++++++++++++++++++++++ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`.