@@ -245,7 +245,7 @@ fn generic_extension<'cx>(
245
245
// this situation.)
246
246
let parser = parser_from_cx ( sess, arg. clone ( ) ) ;
247
247
248
- let tt_parser = TtParser ;
248
+ let tt_parser = TtParser :: new ( name ) ;
249
249
for ( i, lhs) in lhses. iter ( ) . enumerate ( ) {
250
250
// try each arm's matchers
251
251
let lhs_tt = match * lhs {
@@ -259,7 +259,7 @@ fn generic_extension<'cx>(
259
259
// are not recorded. On the first `Success(..)`ful matcher, the spans are merged.
260
260
let mut gated_spans_snapshot = mem:: take ( & mut * sess. gated_spans . spans . borrow_mut ( ) ) ;
261
261
262
- match tt_parser. parse_tt ( & mut Cow :: Borrowed ( & parser) , lhs_tt, name ) {
262
+ match tt_parser. parse_tt ( & mut Cow :: Borrowed ( & parser) , lhs_tt) {
263
263
Success ( named_matches) => {
264
264
// The matcher was `Success(..)`ful.
265
265
// Merge the gated spans from parsing the matcher with the pre-existing ones.
@@ -352,11 +352,9 @@ fn generic_extension<'cx>(
352
352
mbe:: TokenTree :: Delimited ( _, ref delim) => & delim. tts ,
353
353
_ => continue ,
354
354
} ;
355
- if let Success ( _) = tt_parser. parse_tt (
356
- & mut Cow :: Borrowed ( & parser_from_cx ( sess, arg. clone ( ) ) ) ,
357
- lhs_tt,
358
- name,
359
- ) {
355
+ if let Success ( _) =
356
+ tt_parser. parse_tt ( & mut Cow :: Borrowed ( & parser_from_cx ( sess, arg. clone ( ) ) ) , lhs_tt)
357
+ {
360
358
if comma_span. is_dummy ( ) {
361
359
err. note ( "you might be missing a comma" ) ;
362
360
} else {
@@ -449,27 +447,26 @@ pub fn compile_declarative_macro(
449
447
] ;
450
448
451
449
let parser = Parser :: new ( & sess. parse_sess , body, true , rustc_parse:: MACRO_ARGUMENTS ) ;
452
- let tt_parser = TtParser ;
453
- let argument_map =
454
- match tt_parser. parse_tt ( & mut Cow :: Borrowed ( & parser) , & argument_gram, def. ident ) {
455
- Success ( m) => m,
456
- Failure ( token, msg) => {
457
- let s = parse_failure_msg ( & token) ;
458
- let sp = token. span . substitute_dummy ( def. span ) ;
459
- sess. parse_sess . span_diagnostic . struct_span_err ( sp, & s) . span_label ( sp, msg) . emit ( ) ;
460
- return mk_syn_ext ( Box :: new ( macro_rules_dummy_expander) ) ;
461
- }
462
- Error ( sp, msg) => {
463
- sess. parse_sess
464
- . span_diagnostic
465
- . struct_span_err ( sp. substitute_dummy ( def. span ) , & msg)
466
- . emit ( ) ;
467
- return mk_syn_ext ( Box :: new ( macro_rules_dummy_expander) ) ;
468
- }
469
- ErrorReported => {
470
- return mk_syn_ext ( Box :: new ( macro_rules_dummy_expander) ) ;
471
- }
472
- } ;
450
+ let tt_parser = TtParser :: new ( def. ident ) ;
451
+ let argument_map = match tt_parser. parse_tt ( & mut Cow :: Borrowed ( & parser) , & argument_gram) {
452
+ Success ( m) => m,
453
+ Failure ( token, msg) => {
454
+ let s = parse_failure_msg ( & token) ;
455
+ let sp = token. span . substitute_dummy ( def. span ) ;
456
+ sess. parse_sess . span_diagnostic . struct_span_err ( sp, & s) . span_label ( sp, msg) . emit ( ) ;
457
+ return mk_syn_ext ( Box :: new ( macro_rules_dummy_expander) ) ;
458
+ }
459
+ Error ( sp, msg) => {
460
+ sess. parse_sess
461
+ . span_diagnostic
462
+ . struct_span_err ( sp. substitute_dummy ( def. span ) , & msg)
463
+ . emit ( ) ;
464
+ return mk_syn_ext ( Box :: new ( macro_rules_dummy_expander) ) ;
465
+ }
466
+ ErrorReported => {
467
+ return mk_syn_ext ( Box :: new ( macro_rules_dummy_expander) ) ;
468
+ }
469
+ } ;
473
470
474
471
let mut valid = true ;
475
472
0 commit comments