Skip to content

Commit 413e25b

Browse files
Fix error message
1 parent c015382 commit 413e25b

File tree

1 file changed

+4
-10
lines changed
  • compiler/rustc_hir_typeck/src/fn_ctxt

1 file changed

+4
-10
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10531053
.peek()
10541054
.is_some_and(|first| matches!(first, Error::Extra(arg_idx) if arg_idx.index() == 0));
10551055
let mut suggestions = vec![];
1056-
10571056
while let Some(error) = errors.next() {
10581057
only_extras_so_far &= matches!(error, Error::Extra(_));
10591058

@@ -1095,14 +1094,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10951094
} else {
10961095
"".to_string()
10971096
};
1098-
let ord = if provided_arg_tys.len() == 1 {
1097+
let idx = if provided_arg_tys.len() == 1 {
10991098
"".to_string()
11001099
} else {
1101-
format!("#{} ", arg_idx.as_usize() + 1)
1100+
format!(" #{}", arg_idx.as_usize() + 1)
11021101
};
11031102
labels.push((
11041103
provided_span,
1105-
format!("unexpected {ord}argument{provided_ty_name}"),
1104+
format!("unexpected argument{idx}{provided_ty_name}"),
11061105
));
11071106
let mut span = provided_span;
11081107
if span.can_be_used_for_suggestions()
@@ -1184,12 +1183,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11841183
} else {
11851184
"".to_string()
11861185
};
1187-
let ord = if formal_and_expected_inputs.len() == 1 {
1188-
"an".to_string()
1189-
} else {
1190-
format!("#{}", expected_idx.as_usize() + 1)
1191-
};
1192-
labels.push((span, format!("{ord} argument{rendered} is missing")));
1186+
labels.push((span, format!("argument #{}{rendered} is missing", expected_idx.as_usize() + 1)));
11931187

11941188
suggestion_text = match suggestion_text {
11951189
SuggestionText::None => SuggestionText::Provide(false),

0 commit comments

Comments
 (0)