@@ -46,7 +46,7 @@ use print::pprust;
46
46
use ptr:: P ;
47
47
use parse:: PResult ;
48
48
use ThinVec ;
49
- use tokenstream:: { self , DelimSpan , ThinTokenStream , TokenTree , TokenStream } ;
49
+ use tokenstream:: { self , DelimSpan , TokenTree , TokenStream , TreeAndJoint } ;
50
50
use symbol:: { Symbol , keywords} ;
51
51
52
52
use std:: borrow:: Cow ;
@@ -280,17 +280,17 @@ struct TokenCursorFrame {
280
280
/// on the parser.
281
281
#[ derive( Clone ) ]
282
282
enum LastToken {
283
- Collecting ( Vec < TokenStream > ) ,
284
- Was ( Option < TokenStream > ) ,
283
+ Collecting ( Vec < TreeAndJoint > ) ,
284
+ Was ( Option < TreeAndJoint > ) ,
285
285
}
286
286
287
287
impl TokenCursorFrame {
288
- fn new ( sp : DelimSpan , delim : DelimToken , tts : & ThinTokenStream ) -> Self {
288
+ fn new ( sp : DelimSpan , delim : DelimToken , tts : & TokenStream ) -> Self {
289
289
TokenCursorFrame {
290
290
delim : delim,
291
291
span : sp,
292
292
open_delim : delim == token:: NoDelim ,
293
- tree_cursor : tts. stream ( ) . into_trees ( ) ,
293
+ tree_cursor : tts. clone ( ) . into_trees ( ) ,
294
294
close_delim : delim == token:: NoDelim ,
295
295
last_token : LastToken :: Was ( None ) ,
296
296
}
@@ -2330,7 +2330,7 @@ impl<'a> Parser<'a> {
2330
2330
} )
2331
2331
}
2332
2332
2333
- fn expect_delimited_token_tree ( & mut self ) -> PResult < ' a , ( MacDelimiter , ThinTokenStream ) > {
2333
+ fn expect_delimited_token_tree ( & mut self ) -> PResult < ' a , ( MacDelimiter , TokenStream ) > {
2334
2334
let delim = match self . token {
2335
2335
token:: OpenDelim ( delim) => delim,
2336
2336
_ => {
@@ -2350,7 +2350,7 @@ impl<'a> Parser<'a> {
2350
2350
token:: Brace => MacDelimiter :: Brace ,
2351
2351
token:: NoDelim => self . bug ( "unexpected no delimiter" ) ,
2352
2352
} ;
2353
- Ok ( ( delim, tts. stream ( ) . into ( ) ) )
2353
+ Ok ( ( delim, tts. into ( ) ) )
2354
2354
}
2355
2355
2356
2356
/// At the bottom (top?) of the precedence hierarchy,
@@ -4641,7 +4641,7 @@ impl<'a> Parser<'a> {
4641
4641
let ident = self . parse_ident ( ) ?;
4642
4642
let tokens = if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
4643
4643
match self . parse_token_tree ( ) {
4644
- TokenTree :: Delimited ( _, _, tts) => tts. stream ( ) ,
4644
+ TokenTree :: Delimited ( _, _, tts) => tts,
4645
4645
_ => unreachable ! ( ) ,
4646
4646
}
4647
4647
} else if self . check ( & token:: OpenDelim ( token:: Paren ) ) {
@@ -7757,7 +7757,7 @@ impl<'a> Parser<'a> {
7757
7757
& mut self . token_cursor . stack [ prev] . last_token
7758
7758
} ;
7759
7759
7760
- // Pull our the toekns that we've collected from the call to `f` above
7760
+ // Pull out the tokens that we've collected from the call to `f` above.
7761
7761
let mut collected_tokens = match * last_token {
7762
7762
LastToken :: Collecting ( ref mut v) => mem:: replace ( v, Vec :: new ( ) ) ,
7763
7763
LastToken :: Was ( _) => panic ! ( "our vector went away?" ) ,
@@ -7776,10 +7776,9 @@ impl<'a> Parser<'a> {
7776
7776
// call. In that case we need to record all the tokens we collected in
7777
7777
// our parent list as well. To do that we push a clone of our stream
7778
7778
// onto the previous list.
7779
- let stream = collected_tokens. into_iter ( ) . collect :: < TokenStream > ( ) ;
7780
7779
match prev_collecting {
7781
7780
Some ( mut list) => {
7782
- list. push ( stream . clone ( ) ) ;
7781
+ list. extend ( collected_tokens . iter ( ) . cloned ( ) ) ;
7783
7782
list. extend ( extra_token) ;
7784
7783
* last_token = LastToken :: Collecting ( list) ;
7785
7784
}
@@ -7788,7 +7787,7 @@ impl<'a> Parser<'a> {
7788
7787
}
7789
7788
}
7790
7789
7791
- Ok ( ( ret?, stream ) )
7790
+ Ok ( ( ret?, TokenStream :: new ( collected_tokens ) ) )
7792
7791
}
7793
7792
7794
7793
pub fn parse_item ( & mut self ) -> PResult < ' a , Option < P < Item > > > {
0 commit comments