Skip to content

Commit

Permalink
Fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
long-long-float committed Jul 13, 2024
1 parent c015382 commit 413e25b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_));

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 413e25b

Please sign in to comment.