From 29dccfe9e498f41169c120e515494cdd9b5b3e11 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 30 Jul 2022 05:43:26 +0000 Subject: [PATCH] Bless chalk tests --- .../src/traits/error_reporting/mod.rs | 3 +- src/test/ui/chalkify/closure.rs | 5 +- src/test/ui/chalkify/closure.stderr | 74 +++++++++---------- src/test/ui/chalkify/trait-objects.rs | 3 +- src/test/ui/chalkify/trait-objects.stderr | 28 +++++++ 5 files changed, 72 insertions(+), 41 deletions(-) create mode 100644 src/test/ui/chalkify/trait-objects.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 46c03757e60..54281f91205 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -867,7 +867,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ); } - let is_fn_trait = ty::ClosureKind::from_def_id(tcx, trait_ref.def_id()).is_some(); + let is_fn_trait = + ty::ClosureKind::from_def_id(tcx, trait_ref.def_id()).is_some(); let is_target_feature_fn = if let ty::FnDef(def_id, _) = *trait_ref.skip_binder().self_ty().kind() { diff --git a/src/test/ui/chalkify/closure.rs b/src/test/ui/chalkify/closure.rs index 81114d491d7..408e8802d86 100644 --- a/src/test/ui/chalkify/closure.rs +++ b/src/test/ui/chalkify/closure.rs @@ -1,4 +1,5 @@ -// check-fail +// known-bug: unknown +// FIXME(chalk): Chalk needs support for the Tuple trait // compile-flags: -Z chalk fn main() -> () { @@ -25,7 +26,7 @@ fn main() -> () { let mut c = b; c(); - b(); //~ ERROR + b(); // FIXME: reenable when this is fixed ~ 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 ca62ad834bc..bcee0cab96a 100644 --- a/src/test/ui/chalkify/closure.stderr +++ b/src/test/ui/chalkify/closure.stderr @@ -1,5 +1,5 @@ error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:6:5 + --> $DIR/closure.rs:7:5 | LL | t(); | ^^^ the trait `Tuple` is not implemented for `()` @@ -10,7 +10,7 @@ LL | fn main() -> () where (): Tuple { | +++++++++++++++ error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:12:5 + --> $DIR/closure.rs:13:5 | LL | b(); | ^^^ the trait `Tuple` is not implemented for `()` @@ -20,42 +20,9 @@ help: consider introducing a `where` clause, but there might be an alternative b LL | fn main() -> () where (): Tuple { | +++++++++++++++ -error[E0277]: `()` is not a tuple - --> $DIR/closure.rs:16: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:17: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:23: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:27:5 - | LL | c(); | ^^^ the trait `Tuple` is not implemented for `()` | @@ -64,11 +31,44 @@ help: consider introducing a `where` clause, but there might be an alternative b LL | fn main() -> () where (): Tuple { | +++++++++++++++ +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 | b(); - | ^^^ `()` is not a tuple +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 | diff --git a/src/test/ui/chalkify/trait-objects.rs b/src/test/ui/chalkify/trait-objects.rs index d56abc42bf5..30929e943bd 100644 --- a/src/test/ui/chalkify/trait-objects.rs +++ b/src/test/ui/chalkify/trait-objects.rs @@ -1,4 +1,5 @@ -// check-pass +// known-bug: unknown +// FIXME(chalk): Chalk needs support for the Tuple trait // 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 new file mode 100644 index 00000000000..098bd2d3226 --- /dev/null +++ b/src/test/ui/chalkify/trait-objects.stderr @@ -0,0 +1,28 @@ +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` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`.