diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index fe7d0de580bd1..9930fa598bed2 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -1053,7 +1053,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .peek() .is_some_and(|first| matches!(first, Error::Extra(arg_idx) if arg_idx.index() == 0)); let mut suggestions = vec![]; - while let Some(error) = errors.next() { only_extras_so_far &= matches!(error, Error::Extra(_)); @@ -1095,14 +1094,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { "".to_string() }; - let ord = if provided_arg_tys.len() == 1 { + let idx = if provided_arg_tys.len() == 1 { "".to_string() } else { - format!("#{} ", arg_idx.as_usize() + 1) + format!(" #{}", arg_idx.as_usize() + 1) }; labels.push(( provided_span, - format!("unexpected {ord}argument{provided_ty_name}"), + format!("unexpected argument{idx}{provided_ty_name}"), )); let mut span = provided_span; if span.can_be_used_for_suggestions() @@ -1184,12 +1183,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { "".to_string() }; - let ord = if formal_and_expected_inputs.len() == 1 { - "an".to_string() - } else { - format!("#{}", expected_idx.as_usize() + 1) - }; - labels.push((span, format!("{ord} argument{rendered} is missing"))); + labels.push((span, format!("argument #{}{rendered} is missing", expected_idx.as_usize() + 1))); suggestion_text = match suggestion_text { SuggestionText::None => SuggestionText::Provide(false),