@@ -46,7 +46,7 @@ use print::pprust;
4646use ptr:: P ;
4747use parse:: PResult ;
4848use ThinVec ;
49- use tokenstream:: { self , DelimSpan , ThinTokenStream , TokenTree , TokenStream } ;
49+ use tokenstream:: { self , DelimSpan , TokenTree , TokenStream , TreeAndJoint } ;
5050use symbol:: { Symbol , keywords} ;
5151
5252use std:: borrow:: Cow ;
@@ -280,17 +280,17 @@ struct TokenCursorFrame {
280280/// on the parser.
281281#[ derive( Clone ) ]
282282enum LastToken {
283- Collecting ( Vec < TokenStream > ) ,
284- Was ( Option < TokenStream > ) ,
283+ Collecting ( Vec < TreeAndJoint > ) ,
284+ Was ( Option < TreeAndJoint > ) ,
285285}
286286
287287impl TokenCursorFrame {
288- fn new ( sp : DelimSpan , delim : DelimToken , tts : & ThinTokenStream ) -> Self {
288+ fn new ( sp : DelimSpan , delim : DelimToken , tts : & TokenStream ) -> Self {
289289 TokenCursorFrame {
290290 delim : delim,
291291 span : sp,
292292 open_delim : delim == token:: NoDelim ,
293- tree_cursor : tts. stream ( ) . into_trees ( ) ,
293+ tree_cursor : tts. clone ( ) . into_trees ( ) ,
294294 close_delim : delim == token:: NoDelim ,
295295 last_token : LastToken :: Was ( None ) ,
296296 }
@@ -2330,7 +2330,7 @@ impl<'a> Parser<'a> {
23302330 } )
23312331 }
23322332
2333- fn expect_delimited_token_tree ( & mut self ) -> PResult < ' a , ( MacDelimiter , ThinTokenStream ) > {
2333+ fn expect_delimited_token_tree ( & mut self ) -> PResult < ' a , ( MacDelimiter , TokenStream ) > {
23342334 let delim = match self . token {
23352335 token:: OpenDelim ( delim) => delim,
23362336 _ => {
@@ -2350,7 +2350,7 @@ impl<'a> Parser<'a> {
23502350 token:: Brace => MacDelimiter :: Brace ,
23512351 token:: NoDelim => self . bug ( "unexpected no delimiter" ) ,
23522352 } ;
2353- Ok ( ( delim, tts. stream ( ) . into ( ) ) )
2353+ Ok ( ( delim, tts. into ( ) ) )
23542354 }
23552355
23562356 /// At the bottom (top?) of the precedence hierarchy,
@@ -4641,7 +4641,7 @@ impl<'a> Parser<'a> {
46414641 let ident = self . parse_ident ( ) ?;
46424642 let tokens = if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
46434643 match self . parse_token_tree ( ) {
4644- TokenTree :: Delimited ( _, _, tts) => tts. stream ( ) ,
4644+ TokenTree :: Delimited ( _, _, tts) => tts,
46454645 _ => unreachable ! ( ) ,
46464646 }
46474647 } else if self . check ( & token:: OpenDelim ( token:: Paren ) ) {
@@ -7766,7 +7766,7 @@ impl<'a> Parser<'a> {
77667766 & mut self . token_cursor . stack [ prev] . last_token
77677767 } ;
77687768
7769- // Pull our the toekns that we've collected from the call to `f` above
7769+ // Pull out the tokens that we've collected from the call to `f` above.
77707770 let mut collected_tokens = match * last_token {
77717771 LastToken :: Collecting ( ref mut v) => mem:: replace ( v, Vec :: new ( ) ) ,
77727772 LastToken :: Was ( _) => panic ! ( "our vector went away?" ) ,
@@ -7785,10 +7785,9 @@ impl<'a> Parser<'a> {
77857785 // call. In that case we need to record all the tokens we collected in
77867786 // our parent list as well. To do that we push a clone of our stream
77877787 // onto the previous list.
7788- let stream = collected_tokens. into_iter ( ) . collect :: < TokenStream > ( ) ;
77897788 match prev_collecting {
77907789 Some ( mut list) => {
7791- list. push ( stream . clone ( ) ) ;
7790+ list. extend ( collected_tokens . iter ( ) . cloned ( ) ) ;
77927791 list. extend ( extra_token) ;
77937792 * last_token = LastToken :: Collecting ( list) ;
77947793 }
@@ -7797,7 +7796,7 @@ impl<'a> Parser<'a> {
77977796 }
77987797 }
77997798
7800- Ok ( ( ret?, stream ) )
7799+ Ok ( ( ret?, TokenStream :: new ( collected_tokens ) ) )
78017800 }
78027801
78037802 pub fn parse_item ( & mut self ) -> PResult < ' a , Option < P < Item > > > {
0 commit comments