From 8544db0faa9e0f7a70323ad5f3e75358bba6820d Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 23 Oct 2018 10:07:11 -0700 Subject: Add macro call span when lacking any other span in diagnostic --- src/libsyntax/ext/tt/macro_rules.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/ext/tt') diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 87ade278c68..b70a7989275 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -50,7 +50,12 @@ pub struct ParserAnyMacro<'a> { impl<'a> ParserAnyMacro<'a> { pub fn make(mut self: Box>, kind: AstFragmentKind) -> AstFragment { let ParserAnyMacro { site_span, macro_ident, ref mut parser } = *self; - let fragment = panictry!(parser.parse_ast_fragment(kind, true)); + let fragment = panictry!(parser.parse_ast_fragment(kind, true).map_err(|mut e| { + if e.span.is_dummy() { // Get around lack of span in error (#30128) + e.set_span(site_span); + } + e + })); // We allow semicolons at the end of expressions -- e.g. the semicolon in // `macro_rules! m { () => { panic!(); } }` isn't parsed by `.parse_expr()`, -- cgit 1.4.1-3-g733a5