diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index e6fa95b91e9b3..e3db70845ddf1 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -573,6 +573,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // If so, we might have just forgotten to wrap some args in a tuple. if let Some(ty::Tuple(tys)) = formal_and_expected_inputs.get(mismatch_idx.into()).map(|tys| tys.1.kind()) + // If the tuple is unit, we're not actually wrapping any arguments. + && !tys.is_empty() && provided_arg_tys.len() == formal_and_expected_inputs.len() - 1 + tys.len() { // Wrap up the N provided arguments starting at this position in a tuple. diff --git a/src/test/ui/argument-suggestions/issue-99482.rs b/src/test/ui/argument-suggestions/issue-99482.rs new file mode 100644 index 0000000000000..731b863069b23 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-99482.rs @@ -0,0 +1,5 @@ +fn main() { + let f = |_: (), f: fn()| f; + let _f = f(main); + //~^ ERROR this function takes 2 arguments but 1 argument was supplied +} diff --git a/src/test/ui/argument-suggestions/issue-99482.stderr b/src/test/ui/argument-suggestions/issue-99482.stderr new file mode 100644 index 0000000000000..bc005e82a2c46 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-99482.stderr @@ -0,0 +1,19 @@ +error[E0057]: this function takes 2 arguments but 1 argument was supplied + --> $DIR/issue-99482.rs:3:14 + | +LL | let _f = f(main); + | ^ ---- an argument of type `()` is missing + | +note: closure defined here + --> $DIR/issue-99482.rs:2:13 + | +LL | let f = |_: (), f: fn()| f; + | ^^^^^^^^^^^^^^^^ +help: provide the argument + | +LL | let _f = f((), main); + | ~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0057`.