Skip to content

Commit

Permalink
Rollup merge of rust-lang#105966 - compiler-errors:issue-105936, r=eholk
Browse files Browse the repository at this point in the history
Re-enable `Fn` trait call notation error for non-tuple argument

I have no idea why I delayed this bug... but also there doesn't seem to be a UI test that actually shows a change, so maybe that's why.

Fixes rust-lang#105936
  • Loading branch information
matthiaskrgr authored Dec 22, 2022
2 parents 616f1dd + 738b0c0 commit ee15eb7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/unboxed-closures/non-tupled-call.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(fn_traits, unboxed_closures, tuple_trait)]

use std::default::Default;
use std::marker::Tuple;

fn wrap<P: Tuple + Default, T>(func: impl Fn<P, Output = T>) {
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);
}
9 changes: 9 additions & 0 deletions src/test/ui/unboxed-closures/non-tupled-call.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit ee15eb7

Please sign in to comment.