@@ -191,9 +191,9 @@ fn generic_extension<'cx>(
191
191
let mut best_failure: Option < ( Token , & str ) > = None ;
192
192
193
193
// We create a base parser that can be used for the "black box" parts.
194
- // Every iteration needs a fresh copy of that base parser. However, the
195
- // parser is not mutated on many of the iterations, particularly when
196
- // dealing with macros like this:
194
+ // Every iteration needs a fresh copy of that parser. However, the parser
195
+ // is not mutated on many of the iterations, particularly when dealing with
196
+ // macros like this:
197
197
//
198
198
// macro_rules! foo {
199
199
// ("a") => (A);
@@ -209,11 +209,9 @@ fn generic_extension<'cx>(
209
209
// hacky, but speeds up the `html5ever` benchmark significantly. (Issue
210
210
// 68836 suggests a more comprehensive but more complex change to deal with
211
211
// this situation.)
212
- let base_parser = base_parser_from_cx ( & cx. current_expansion , & cx. parse_sess , arg. clone ( ) ) ;
212
+ let parser = parser_from_cx ( & cx. current_expansion , & cx. parse_sess , arg. clone ( ) ) ;
213
213
214
214
for ( i, lhs) in lhses. iter ( ) . enumerate ( ) {
215
- let mut parser = Cow :: Borrowed ( & base_parser) ;
216
-
217
215
// try each arm's matchers
218
216
let lhs_tt = match * lhs {
219
217
mbe:: TokenTree :: Delimited ( _, ref delim) => & delim. tts [ ..] ,
@@ -226,7 +224,7 @@ fn generic_extension<'cx>(
226
224
// are not recorded. On the first `Success(..)`ful matcher, the spans are merged.
227
225
let mut gated_spans_snaphot = mem:: take ( & mut * cx. parse_sess . gated_spans . spans . borrow_mut ( ) ) ;
228
226
229
- match parse_tt ( & mut parser, lhs_tt) {
227
+ match parse_tt ( & mut Cow :: Borrowed ( & parser) , lhs_tt) {
230
228
Success ( named_matches) => {
231
229
// The matcher was `Success(..)`ful.
232
230
// Merge the gated spans from parsing the matcher with the pre-existing ones.
@@ -293,7 +291,7 @@ fn generic_extension<'cx>(
293
291
// Restore to the state before snapshotting and maybe try again.
294
292
mem:: swap ( & mut gated_spans_snaphot, & mut cx. parse_sess . gated_spans . spans . borrow_mut ( ) ) ;
295
293
}
296
- drop ( base_parser ) ;
294
+ drop ( parser ) ;
297
295
298
296
let ( token, label) = best_failure. expect ( "ran no matchers" ) ;
299
297
let span = token. span . substitute_dummy ( sp) ;
@@ -311,9 +309,8 @@ fn generic_extension<'cx>(
311
309
mbe:: TokenTree :: Delimited ( _, ref delim) => & delim. tts [ ..] ,
312
310
_ => continue ,
313
311
} ;
314
- let base_parser =
315
- base_parser_from_cx ( & cx. current_expansion , & cx. parse_sess , arg. clone ( ) ) ;
316
- match parse_tt ( & mut Cow :: Borrowed ( & base_parser) , lhs_tt) {
312
+ let parser = parser_from_cx ( & cx. current_expansion , & cx. parse_sess , arg. clone ( ) ) ;
313
+ match parse_tt ( & mut Cow :: Borrowed ( & parser) , lhs_tt) {
317
314
Success ( _) => {
318
315
if comma_span. is_dummy ( ) {
319
316
err. note ( "you might be missing a comma" ) ;
@@ -395,8 +392,8 @@ pub fn compile_declarative_macro(
395
392
) ,
396
393
] ;
397
394
398
- let base_parser = Parser :: new ( sess, body, None , true , true , rustc_parse:: MACRO_ARGUMENTS ) ;
399
- let argument_map = match parse_tt ( & mut Cow :: Borrowed ( & base_parser ) , & argument_gram) {
395
+ let parser = Parser :: new ( sess, body, None , true , true , rustc_parse:: MACRO_ARGUMENTS ) ;
396
+ let argument_map = match parse_tt ( & mut Cow :: Borrowed ( & parser ) , & argument_gram) {
400
397
Success ( m) => m,
401
398
Failure ( token, msg) => {
402
399
let s = parse_failure_msg ( & token) ;
@@ -1212,7 +1209,7 @@ fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String {
1212
1209
}
1213
1210
}
1214
1211
1215
- fn base_parser_from_cx < ' cx > (
1212
+ fn parser_from_cx < ' cx > (
1216
1213
current_expansion : & ' cx ExpansionData ,
1217
1214
sess : & ' cx ParseSess ,
1218
1215
tts : TokenStream ,
0 commit comments