@@ -7,6 +7,7 @@ use ast::token::IdentIsRaw;
77use rustc_ast:: token:: NtPatKind :: * ;
88use rustc_ast:: token:: TokenKind :: * ;
99use rustc_ast:: token:: { self , Delimiter , NonterminalKind , Token , TokenKind } ;
10+ use rustc_ast:: tokenarena:: TokenArena ;
1011use rustc_ast:: tokenstream:: { self , DelimSpan , TokenStream } ;
1112use rustc_ast:: { self as ast, DUMMY_NODE_ID , NodeId , Safety } ;
1213use rustc_ast_pretty:: pprust;
@@ -132,7 +133,7 @@ impl<'a, 'b> ParserAnyMacro<'a, 'b> {
132133 matched_rule_bindings : & ' b [ MatcherLoc ] ,
133134 ) -> Self {
134135 Self {
135- parser : Parser :: new ( & cx. sess . psess , tts, None ) ,
136+ parser : Parser :: new ( & cx. sess . psess , TokenArena :: from_stream ( & tts) , None ) ,
136137
137138 // Pass along the original expansion site and the name of the macro
138139 // so we can print a useful error message if the parse of the expanded
@@ -796,7 +797,7 @@ pub fn compile_declarative_macro(
796797 let macro_rules = macro_def. macro_rules ;
797798 let exp_sep = if macro_rules { exp ! ( Semi ) } else { exp ! ( Comma ) } ;
798799
799- let body = macro_def. body . tokens . clone ( ) ;
800+ let body = TokenArena :: from_stream ( & macro_def. body . tokens ) ;
800801 let mut p = Parser :: new ( & sess. psess , body, rustc_parse:: MACRO_ARGUMENTS ) ;
801802
802803 // Don't abort iteration early, so that multiple errors can be reported. We only abort early on
@@ -1869,5 +1870,6 @@ pub(super) fn parser_from_cx(
18691870 recovery : Recovery ,
18701871) -> Parser < ' _ > {
18711872 tts. desugar_doc_comments ( ) ;
1872- Parser :: new ( psess, tts, rustc_parse:: MACRO_ARGUMENTS ) . recovery ( recovery)
1873+ Parser :: new ( psess, TokenArena :: from_stream ( & tts) , rustc_parse:: MACRO_ARGUMENTS )
1874+ . recovery ( recovery)
18731875}
0 commit comments