about summary refs log tree commit diff
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2025-05-26 13:47:53 +0800
committeryukang <moorekang@gmail.com>2025-05-26 13:47:53 +0800
commit6b5b97a4df3331e82ee7f57f2c33818b997f98d0 (patch)
tree4c8afbc80f4fca29b3b7631121692ea61419e348
parent9f8929fbeca4b5c2302b326606ae800156915840 (diff)
downloadrust-6b5b97a4df3331e82ee7f57f2c33818b997f98d0.tar.gz
rust-6b5b97a4df3331e82ee7f57f2c33818b997f98d0.zip
Fix incorrect eq_unspanned in TokenStream
-rw-r--r--compiler/rustc_ast/src/tokenstream.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs
index 636c26bcde0..7f2ba28f81b 100644
--- a/compiler/rustc_ast/src/tokenstream.rs
+++ b/compiler/rustc_ast/src/tokenstream.rs
@@ -696,14 +696,8 @@ impl TokenStream {
 
     /// Compares two `TokenStream`s, checking equality without regarding span information.
     pub fn eq_unspanned(&self, other: &TokenStream) -> bool {
-        let mut iter1 = self.iter();
-        let mut iter2 = other.iter();
-        for (tt1, tt2) in iter::zip(&mut iter1, &mut iter2) {
-            if !tt1.eq_unspanned(tt2) {
-                return false;
-            }
-        }
-        iter1.next().is_none() && iter2.next().is_none()
+        self.len() == other.len()
+            && self.iter().zip(other.iter()).all(|(tt1, tt2)| tt1.eq_unspanned(tt2))
     }
 
     /// Create a token stream containing a single token with alone spacing. The