@@ -45,16 +45,18 @@ pub struct ParserAnyMacro<'a> {
4545 /// Span of the expansion site of the macro this parser is for
4646 site_span : Span ,
4747 /// The ident of the macro we're parsing
48- macro_ident : ast:: Ident
48+ macro_ident : ast:: Ident ,
49+ arm_span : Span ,
4950}
5051
5152impl < ' a > ParserAnyMacro < ' a > {
5253 pub fn make ( mut self : Box < ParserAnyMacro < ' a > > , kind : AstFragmentKind ) -> AstFragment {
53- let ParserAnyMacro { site_span, macro_ident, ref mut parser } = * self ;
54+ let ParserAnyMacro { site_span, macro_ident, ref mut parser, arm_span } = * self ;
5455 let fragment = panictry ! ( parser. parse_ast_fragment( kind, true ) . map_err( |mut e| {
5556 if e. span. is_dummy( ) { // Get around lack of span in error (#30128)
5657 e. set_span( site_span) ;
5758 e. span_label( site_span, "in this macro expansion" ) ;
59+ e. span_label( arm_span, "in this macro arm" ) ;
5860 } else if parser. token == token:: Eof { // (#52866)
5961 e. set_span( parser. sess. source_map( ) . next_point( parser. span) ) ;
6062 }
@@ -146,6 +148,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
146148 quoted:: TokenTree :: Delimited ( _, ref delimed) => delimed. tts . clone ( ) ,
147149 _ => cx. span_bug ( sp, "malformed macro rhs" ) ,
148150 } ;
151+ let arm_span = rhses[ i] . span ( ) ;
149152
150153 let rhs_spans = rhs. iter ( ) . map ( |t| t. span ( ) ) . collect :: < Vec < _ > > ( ) ;
151154 // rhs has holes ( `$id` and `$(...)` that need filled)
@@ -184,7 +187,8 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
184187 // so we can print a useful error message if the parse of the expanded
185188 // macro leaves unparsed tokens.
186189 site_span : sp,
187- macro_ident : name
190+ macro_ident : name,
191+ arm_span,
188192 } )
189193 }
190194 Failure ( sp, tok, t) => if sp. lo ( ) >= best_fail_spot. lo ( ) {
0 commit comments