Fix a numerical underflow in tuple wrap suggestion

This commit is contained in:
Michael Goulet 2022-07-19 22:47:00 +00:00
parent 29c5a028b0
commit 43c0c63eda
3 changed files with 26 additions and 0 deletions

View file

@ -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 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.