Skip to content

Commit c53fc09

Browse files
committed
Tweak wording on "other methods available" note
Handle correct gramar in the face of a single other option, or many.
1 parent a89269e commit c53fc09

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{Applicability, Diag, MultiSpan, listify};
1+
use rustc_errors::{Applicability, Diag, MultiSpan, listify, pluralize};
22
use rustc_hir::def::{DefKind, Res};
33
use rustc_hir::intravisit::Visitor;
44
use rustc_hir::{self as hir, find_attr};
@@ -1072,9 +1072,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10721072
),
10731073
);
10741074
if suggestions.len() > other_methods_in_scope.len() {
1075+
let n = suggestions.len() - other_methods_in_scope.len();
10751076
err.note(format!(
1076-
"additionally, there are {} other available methods that aren't in scope",
1077-
suggestions.len() - other_methods_in_scope.len()
1077+
"additionally, there {are} {n} other available method{s} that {are}n't in scope",
1078+
are = pluralize!("is", n),
1079+
s = pluralize!(n),
10781080
));
10791081
}
10801082
err.multipart_suggestions(

tests/ui/mismatched_types/diagnostic-method-lookup-returns-sig-with-fewer-args.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ note: the `get` call is resolved to the method in `Target`, shadowing the method
1616
|
1717
LL | target.get(10.0); // (used to crash here)
1818
| ^^^ refers to `Target::get`
19-
= note: additionally, there are 1 other available methods that aren't in scope
19+
= note: additionally, there is 1 other available method that isn't in scope
2020
help: you might have meant to call one of the other methods; you can use the fully-qualified path to call one of them explicitly
2121
|
2222
LL - target.get(10.0); // (used to crash here)

0 commit comments

Comments
 (0)