Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable Fn trait call notation error for non-tuple argument #105966

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice if this suggested how to fix it, but that seems fine for another PR.

Copy link
Member Author

@compiler-errors compiler-errors Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I promise that I looked how to do this, and it's pretty hard, because we don't pass down the right spans here. Definitely can be a follow-up.

--> $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`.