Skip to content

Commit ccd956a

Browse files
committed
Remove Cursor::append.
It's a weird function: it lets you modify the token stream in the middle of iteration. There is only one call site, and it is only used for the rare `ProceduralMasquerade` legacy case.
1 parent 2b646bd commit ccd956a

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
2525
use rustc_span::{Span, DUMMY_SP};
2626
use smallvec::{smallvec, SmallVec};
2727

28-
use std::{fmt, iter, mem};
28+
use std::{fmt, iter};
2929

3030
/// When the main Rust parser encounters a syntax-extension invocation, it
3131
/// parses the arguments to the invocation as a token tree. This is a very
@@ -683,16 +683,6 @@ impl Cursor {
683683
self.index
684684
}
685685

686-
pub fn append(&mut self, new_stream: TokenStream) {
687-
if new_stream.is_empty() {
688-
return;
689-
}
690-
let index = self.index;
691-
let stream = mem::take(&mut self.stream);
692-
*self = TokenStream::from_streams(smallvec![stream, new_stream]).into_trees();
693-
self.index = index;
694-
}
695-
696686
pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> {
697687
self.stream.0[self.index..].get(n).map(|(tree, _)| tree)
698688
}

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ impl server::TokenStream for Rustc<'_, '_> {
522522
// FIXME: It needs to be removed, but there are some
523523
// compatibility issues (see #73345).
524524
if group.flatten {
525-
cursor.append(group.stream);
526-
continue;
525+
tts.append(&mut self.into_trees(group.stream));
526+
} else {
527+
tts.push(TokenTree::Group(group));
527528
}
528-
tts.push(TokenTree::Group(group));
529529
}
530530
Some(tt) => tts.push(tt),
531531
None => return tts,

0 commit comments

Comments
 (0)