@@ -45,16 +45,18 @@ pub struct ParserAnyMacro<'a> {
45
45
/// Span of the expansion site of the macro this parser is for
46
46
site_span : Span ,
47
47
/// The ident of the macro we're parsing
48
- macro_ident : ast:: Ident
48
+ macro_ident : ast:: Ident ,
49
+ arm_span : Span ,
49
50
}
50
51
51
52
impl < ' a > ParserAnyMacro < ' a > {
52
53
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 ;
54
55
let fragment = panictry ! ( parser. parse_ast_fragment( kind, true ) . map_err( |mut e| {
55
56
if e. span. is_dummy( ) { // Get around lack of span in error (#30128)
56
57
e. set_span( site_span) ;
57
58
e. span_label( site_span, "in this macro expansion" ) ;
59
+ e. span_label( arm_span, "in this macro arm" ) ;
58
60
} else if parser. token == token:: Eof { // (#52866)
59
61
e. set_span( parser. sess. source_map( ) . next_point( parser. span) ) ;
60
62
}
@@ -146,6 +148,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
146
148
quoted:: TokenTree :: Delimited ( _, ref delimed) => delimed. tts . clone ( ) ,
147
149
_ => cx. span_bug ( sp, "malformed macro rhs" ) ,
148
150
} ;
151
+ let arm_span = rhses[ i] . span ( ) ;
149
152
150
153
let rhs_spans = rhs. iter ( ) . map ( |t| t. span ( ) ) . collect :: < Vec < _ > > ( ) ;
151
154
// rhs has holes ( `$id` and `$(...)` that need filled)
@@ -184,7 +187,8 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
184
187
// so we can print a useful error message if the parse of the expanded
185
188
// macro leaves unparsed tokens.
186
189
site_span : sp,
187
- macro_ident : name
190
+ macro_ident : name,
191
+ arm_span,
188
192
} )
189
193
}
190
194
Failure ( sp, tok, t) => if sp. lo ( ) >= best_fail_spot. lo ( ) {
0 commit comments