diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2018-10-25 10:09:19 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2018-11-23 15:37:31 -0800 |
| commit | ea9ccb6046aa1733aa1761fc942f8432fb63f107 (patch) | |
| tree | db42da1149aebe1315d35101666bd5bee8c29c96 /src/libsyntax/ext | |
| parent | 910ec6d97ff03549c22352d7763be02b60d73470 (diff) | |
| download | rust-ea9ccb6046aa1733aa1761fc942f8432fb63f107.tar.gz rust-ea9ccb6046aa1733aa1761fc942f8432fb63f107.zip | |
Point at end of macro arm when encountering EOF
Fix #52866
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 9 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index f31d80acbfa..26604c46be5 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -724,7 +724,14 @@ pub fn parse( "ambiguity: multiple successful parses".to_string(), ); } else { - return Failure(parser.span, token::Eof); + return Failure( + if parser.span.is_dummy() { + parser.span + } else { + sess.source_map().next_point(parser.span) + }, + token::Eof, + ); } } // Performance hack: eof_items may share matchers via Rc with other things that we want @@ -757,7 +764,7 @@ pub fn parse( ); } // If there are no possible next positions AND we aren't waiting for the black-box parser, - // then their is a syntax error. + // then there is a syntax error. else if bb_items.is_empty() && next_items.is_empty() { return Failure(parser.span, parser.token); } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 6bba891278a..b67c46fe6f4 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -53,6 +53,15 @@ impl<'a> ParserAnyMacro<'a> { 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); + } else if parser.token == token::Eof { // (#52866) + e.set_span(parser.sess.source_map().next_point(parser.span)); + } + if parser.token == token::Eof { + let msg = &e.message[0]; + e.message[0] = ( + msg.0.replace(", found `<eof>`", ", found the end of the macro arm"), + msg.1, + ); } e })); |
