From 738b0c06730e4e2c74901d554dcb7d1b40b5cd0a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 20 Dec 2022 18:30:12 +0000 Subject: [PATCH] Re-enable fn trait call notation error --- compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs | 2 +- src/test/ui/unboxed-closures/non-tupled-call.rs | 17 +++++++++++++++++ .../ui/unboxed-closures/non-tupled-call.stderr | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/unboxed-closures/non-tupled-call.rs create mode 100644 src/test/ui/unboxed-closures/non-tupled-call.stderr diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index d1e0964112bc5..877680053f090 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -214,7 +214,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "cannot use call notation; the first type parameter \ for the function trait is neither a tuple nor unit" ) - .delay_as_bug(); + .emit(); (self.err_args(provided_args.len()), None) } } diff --git a/src/test/ui/unboxed-closures/non-tupled-call.rs b/src/test/ui/unboxed-closures/non-tupled-call.rs new file mode 100644 index 0000000000000..08bea4f1678b6 --- /dev/null +++ b/src/test/ui/unboxed-closures/non-tupled-call.rs @@ -0,0 +1,17 @@ +#![feature(fn_traits, unboxed_closures, tuple_trait)] + +use std::default::Default; +use std::marker::Tuple; + +fn wrap(func: impl Fn) { + let x: P = Default::default(); + // Should be: `func.call(x);` + func(x); + //~^ ERROR cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit +} + +fn foo() {} + +fn main() { + wrap(foo); +} diff --git a/src/test/ui/unboxed-closures/non-tupled-call.stderr b/src/test/ui/unboxed-closures/non-tupled-call.stderr new file mode 100644 index 0000000000000..35ac9ebe29103 --- /dev/null +++ b/src/test/ui/unboxed-closures/non-tupled-call.stderr @@ -0,0 +1,9 @@ +error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit + --> $DIR/non-tupled-call.rs:9:5 + | +LL | func(x); + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0059`.