diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-09-07 08:18:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-07 08:18:59 +0200 |
| commit | cb8b5fa4e2a68460ffbf7a733cd2851fa13ba6a9 (patch) | |
| tree | 2421c65faa5f8cfc4b98e6aaf4f0391753d05d6d /compiler/rustc_resolve | |
| parent | f4b2f68e046a42309ca8faed411f7cd5b267cfb9 (diff) | |
| parent | f279ae1b05fe0f12259b3e24d35f5598b18f5ea9 (diff) | |
| download | rust-cb8b5fa4e2a68460ffbf7a733cd2851fa13ba6a9.tar.gz rust-cb8b5fa4e2a68460ffbf7a733cd2851fa13ba6a9.zip | |
Rollup merge of #146254 - yotamofek:pr/itertools-all-equal-value, r=cjgillot
Use `Itertools::all_equal_value()` where applicable Just a small cleanup. We already have `itertools` as a dep in these crates, so might as well use another of its features. Makes the code simpler IMHO :)
Diffstat (limited to 'compiler/rustc_resolve')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index f458a1f17b9..689e713ef46 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1,3 +1,4 @@ +use itertools::Itertools as _; use rustc_ast::visit::{self, Visitor}; use rustc_ast::{ self as ast, CRATE_NODE_ID, Crate, ItemKind, ModKind, NodeId, Path, join_path_idents, @@ -3469,16 +3470,11 @@ fn show_candidates( err.note(note.to_string()); } } else { - let (_, descr_first, _, _, _) = &inaccessible_path_strings[0]; - let descr = if inaccessible_path_strings + let descr = inaccessible_path_strings .iter() - .skip(1) - .all(|(_, descr, _, _, _)| descr == descr_first) - { - descr_first - } else { - "item" - }; + .map(|&(_, descr, _, _, _)| descr) + .all_equal_value() + .unwrap_or("item"); let plural_descr = if descr.ends_with('s') { format!("{descr}es") } else { format!("{descr}s") }; |
