Skip to content

Commit dc42aa8

Browse files
Rollup merge of #76131 - Aaron1011:fix/pretty-print-zip, r=lcnr
Don't use `zip` to compare iterators during pretty-print hack If the right-hand iterator has exactly one more element than the left-hand iterator, then both iterators will be fully consumed, but the extra element will never be compared. Split out from #76130
2 parents 11f7bfa + f5d71a9 commit dc42aa8

File tree

1 file changed

+5
-8
lines changed
  • compiler/rustc_parse/src

1 file changed

+5
-8
lines changed

compiler/rustc_parse/src/lib.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(bool_to_option)]
44
#![feature(crate_visibility_modifier)]
55
#![feature(bindings_after_at)]
6+
#![feature(iter_order_by)]
67
#![feature(or_patterns)]
78

89
use rustc_ast as ast;
@@ -459,14 +460,10 @@ pub fn tokenstream_probably_equal_for_proc_macro(
459460

460461
// Break tokens after we expand any nonterminals, so that we break tokens
461462
// that are produced as a result of nonterminal expansion.
462-
let mut t1 = first.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens);
463-
let mut t2 = other.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens);
464-
for (t1, t2) in t1.by_ref().zip(t2.by_ref()) {
465-
if !tokentree_probably_equal_for_proc_macro(&t1, &t2, sess) {
466-
return false;
467-
}
468-
}
469-
t1.next().is_none() && t2.next().is_none()
463+
let t1 = first.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens);
464+
let t2 = other.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens);
465+
466+
t1.eq_by(t2, |t1, t2| tokentree_probably_equal_for_proc_macro(&t1, &t2, sess))
470467
}
471468

472469
// See comments in `Nonterminal::to_tokenstream` for why we care about

0 commit comments

Comments
 (0)