diff options
| author | ecstatic-morse <ecstaticmorse@gmail.com> | 2020-09-21 20:40:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-21 20:40:39 -0700 |
| commit | dc42aa8cd4418fe012394c6263a093b0333467b9 (patch) | |
| tree | 8fd51be89374cb13e5af826628ef7f0558ad0961 | |
| parent | 11f7bfab91c4a285ca5a54609322fd7b85dfc3bd (diff) | |
| parent | f5d71a9b3cf3018ec646acb6f8fa731fb8ca902e (diff) | |
| download | rust-dc42aa8cd4418fe012394c6263a093b0333467b9.tar.gz rust-dc42aa8cd4418fe012394c6263a093b0333467b9.zip | |
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 https://github.com/rust-lang/rust/pull/76130
| -rw-r--r-- | compiler/rustc_parse/src/lib.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 72a34b86ae2..21bbdc9ba8d 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -3,6 +3,7 @@ #![feature(bool_to_option)] #![feature(crate_visibility_modifier)] #![feature(bindings_after_at)] +#![feature(iter_order_by)] #![feature(or_patterns)] use rustc_ast as ast; @@ -459,14 +460,10 @@ pub fn tokenstream_probably_equal_for_proc_macro( // Break tokens after we expand any nonterminals, so that we break tokens // that are produced as a result of nonterminal expansion. - let mut t1 = first.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens); - let mut t2 = other.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens); - for (t1, t2) in t1.by_ref().zip(t2.by_ref()) { - if !tokentree_probably_equal_for_proc_macro(&t1, &t2, sess) { - return false; - } - } - t1.next().is_none() && t2.next().is_none() + let t1 = first.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens); + let t2 = other.trees().filter(semantic_tree).flat_map(expand_nt).flat_map(break_tokens); + + t1.eq_by(t2, |t1, t2| tokentree_probably_equal_for_proc_macro(&t1, &t2, sess)) } // See comments in `Nonterminal::to_tokenstream` for why we care about |
