about summary refs log tree commit diff
path: root/compiler/rustc_hir/src
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-09-29 21:06:45 +1000
committerGitHub <noreply@github.com>2025-09-29 21:06:45 +1000
commit08616a17457bb93eb177d9189f92345d1924294d (patch)
tree63c971995ccb1993d59c0c8f27d310c8fee0a08a /compiler/rustc_hir/src
parentacd91e2fe1abc802a41cef4496a375bde7053394 (diff)
parent68a7c250788833305f73f816b284aafa9e62370a (diff)
downloadrust-08616a17457bb93eb177d9189f92345d1924294d.tar.gz
rust-08616a17457bb93eb177d9189f92345d1924294d.zip
Rollup merge of #147101 - yotamofek:pr/iter-eq-and-eq-by, r=jdonszelmann
Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library

Now that rust-lang/rust#137122 has landed, we can replace stuff that looks like:
```rust
let a: &[T];
let b: &[T];
let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b)
```
with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path.
Also dogfooded `Iterator::eq_by` (cc rust-lang/rust#64295 ) while I'm at it.

First commit (4d1b6fad230f8a5ccceccc7562eadc4ea50059da) should be very straightforward to review, second one (049a4606cb3906787aedf508ee8eea09c2bb3b9a) is slightly more creative, but IMHO a nice cleanup.
Diffstat (limited to 'compiler/rustc_hir/src')
-rw-r--r--compiler/rustc_hir/src/hir.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index 493236718a8..bc1c47e95c3 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -1298,10 +1298,7 @@ impl AttributeExt for Attribute {
     #[inline]
     fn path_matches(&self, name: &[Symbol]) -> bool {
         match &self {
-            Attribute::Unparsed(n) => {
-                n.path.segments.len() == name.len()
-                    && n.path.segments.iter().zip(name).all(|(s, n)| s.name == *n)
-            }
+            Attribute::Unparsed(n) => n.path.segments.iter().map(|ident| &ident.name).eq(name),
             _ => false,
         }
     }