Fix a numerical underflow in tuple wrap suggestion
This commit is contained in:
parent
29c5a028b0
commit
43c0c63eda
3 changed files with 26 additions and 0 deletions
|
@ -575,6 +575,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// If so, we might have just forgotten to wrap some args in a tuple.
|
// If so, we might have just forgotten to wrap some args in a tuple.
|
||||||
if let Some(ty::Tuple(tys)) =
|
if let Some(ty::Tuple(tys)) =
|
||||||
formal_and_expected_inputs.get(mismatch_idx.into()).map(|tys| tys.1.kind())
|
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()
|
&& 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.
|
// Wrap up the N provided arguments starting at this position in a tuple.
|
||||||
|
|
5
src/test/ui/argument-suggestions/issue-99482.rs
Normal file
5
src/test/ui/argument-suggestions/issue-99482.rs
Normal file
|
@ -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
|
||||||
|
}
|
19
src/test/ui/argument-suggestions/issue-99482.stderr
Normal file
19
src/test/ui/argument-suggestions/issue-99482.stderr
Normal file
|
@ -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`.
|
Loading…
Add table
Add a link
Reference in a new issue