Skip to content

Commit

Permalink
Rollup merge of rust-lang#89478 - zvavybir:master, r=jyn514
Browse files Browse the repository at this point in the history
Fixed numerus of error message

When there are redundant trait requirements and these are hidden, a message is generated by the following code snippet:
`format!("{} redundant requirements hidden", count)`
But if there is only a single hidden requirement, it will still print this message in plural instead of singular.
  • Loading branch information
Manishearth authored Oct 5, 2021
2 parents 73cde66 + d6a7e74 commit d977385
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::traits::normalize_projection_type;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{error_code, struct_span_err, Applicability, DiagnosticBuilder, Style};
use rustc_errors::{
error_code, pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style,
};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
Expand Down Expand Up @@ -2273,7 +2275,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
parent_trait_ref = child_trait_ref;
}
if count > 0 {
err.note(&format!("{} redundant requirements hidden", count));
err.note(&format!(
"{} redundant requirement{} hidden",
count,
pluralize!(count)
));
err.note(&format!(
"required because of the requirements on the impl of `{}` for `{}`",
parent_trait_ref.print_only_trait_path(),
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/associated-types/impl-wf-cycle-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ note: required because of the requirements on the impl of `Grault` for `(T,)`
|
LL | impl<T: Grault> Grault for (T,)
| ^^^^^^ ^^^^
= note: 1 redundant requirements hidden
= note: 1 redundant requirement hidden
= note: required because of the requirements on the impl of `Grault` for `(T,)`

error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
Expand All @@ -29,7 +29,7 @@ note: required because of the requirements on the impl of `Grault` for `(T,)`
|
LL | impl<T: Grault> Grault for (T,)
| ^^^^^^ ^^^^
= note: 1 redundant requirements hidden
= note: 1 redundant requirement hidden
= note: required because of the requirements on the impl of `Grault` for `(T,)`

error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
Expand All @@ -43,7 +43,7 @@ note: required because of the requirements on the impl of `Grault` for `(T,)`
|
LL | impl<T: Grault> Grault for (T,)
| ^^^^^^ ^^^^
= note: 1 redundant requirements hidden
= note: 1 redundant requirement hidden
= note: required because of the requirements on the impl of `Grault` for `(T,)`

error: aborting due to 3 previous errors
Expand Down

0 comments on commit d977385

Please sign in to comment.