Skip to content

Commit b68b1cd

Browse files
Revert the message as before if number of input or expected arguments is one
1 parent 2e0f26b commit b68b1cd

File tree

1 file changed

+15
-2
lines changed
  • compiler/rustc_hir_typeck/src/fn_ctxt

1 file changed

+15
-2
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10681068
} else {
10691069
"".to_string()
10701070
};
1071-
labels.push((provided_span, format!("unexpected {} argument{provided_ty_name}", ordinalize(arg_idx.as_usize() + 1))));
1071+
let ord = if provided_arg_tys.len() == 1 {
1072+
"".to_string()
1073+
} else {
1074+
format!("{} ", ordinalize(arg_idx.as_usize() + 1))
1075+
};
1076+
labels.push((
1077+
provided_span,
1078+
format!("unexpected {ord}argument{provided_ty_name}"),
1079+
));
10721080
let mut span = provided_span;
10731081
if span.can_be_used_for_suggestions()
10741082
&& error_span.can_be_used_for_suggestions()
@@ -1149,7 +1157,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11491157
} else {
11501158
"".to_string()
11511159
};
1152-
labels.push((span, format!("{} argument{rendered} is missing", ordinalize(expected_idx.as_usize() + 1))));
1160+
let ord = if formal_and_expected_inputs.len() == 1 {
1161+
"an".to_string()
1162+
} else {
1163+
ordinalize(expected_idx.as_usize() + 1)
1164+
};
1165+
labels.push((span, format!("{ord} argument{rendered} is missing")));
11531166

11541167
suggestion_text = match suggestion_text {
11551168
SuggestionText::None => SuggestionText::Provide(false),

0 commit comments

Comments
 (0)