about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs11
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs9
-rw-r--r--src/test/ui/directory_ownership/macro-expanded-mod.rs3
-rw-r--r--src/test/ui/directory_ownership/macro-expanded-mod.stderr6
-rw-r--r--src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr6
-rw-r--r--src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr6
-rw-r--r--src/test/ui/macros/macro-at-most-once-rep-2018.stderr8
-rw-r--r--src/test/ui/macros/macro-in-expression-context-2.stderr2
8 files changed, 34 insertions, 17 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
         }));
diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.rs b/src/test/ui/directory_ownership/macro-expanded-mod.rs
index 8e631a64f7a..78356f981fc 100644
--- a/src/test/ui/directory_ownership/macro-expanded-mod.rs
+++ b/src/test/ui/directory_ownership/macro-expanded-mod.rs
@@ -12,6 +12,7 @@
 
 macro_rules! mod_decl {
     ($i:ident) => { mod $i; }
+    //~^ ERROR Cannot declare a non-inline module inside a block
 }
 
 mod macro_expanded_mod_helper {
@@ -19,5 +20,5 @@ mod macro_expanded_mod_helper {
 }
 
 fn main() {
-    mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block
+    mod_decl!(foo);
 }
diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.stderr b/src/test/ui/directory_ownership/macro-expanded-mod.stderr
index a9efcd883c1..f58e864a755 100644
--- a/src/test/ui/directory_ownership/macro-expanded-mod.stderr
+++ b/src/test/ui/directory_ownership/macro-expanded-mod.stderr
@@ -1,8 +1,8 @@
 error: Cannot declare a non-inline module inside a block unless it has a path attribute
-  --> $DIR/macro-expanded-mod.rs:22:15
+  --> $DIR/macro-expanded-mod.rs:14:28
    |
-LL |     mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block
-   |               ^^^
+LL |     ($i:ident) => { mod $i; }
+   |                            ^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr
index b6ff60f1492..bf7fc28c758 100644
--- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr
+++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr
@@ -22,11 +22,11 @@ error: no rules expected the token `async`
 LL |     r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
    |                                   ^^^^^ no rules expected the token `async`
 
-error: expected one of `move`, `|`, or `||`, found `<eof>`
-  --> <::edition_kw_macro_2015::passes_ident macros>:1:22
+error: expected one of `move`, `|`, or `||`, found the end of the macro arm
+  --> <::edition_kw_macro_2015::passes_ident macros>:1:25
    |
 LL | ( $ i : ident ) => ( $ i )
-   |                      ^^^ expected one of `move`, `|`, or `||` here
+   |                         ^
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr
index ffe666a7e64..4ab29ba67a0 100644
--- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr
+++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr
@@ -22,11 +22,11 @@ error: no rules expected the token `async`
 LL |     r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
    |                                   ^^^^^ no rules expected the token `async`
 
-error: expected one of `move`, `|`, or `||`, found `<eof>`
-  --> <::edition_kw_macro_2018::passes_ident macros>:1:22
+error: expected one of `move`, `|`, or `||`, found the end of the macro arm
+  --> <::edition_kw_macro_2018::passes_ident macros>:1:25
    |
 LL | ( $ i : ident ) => ( $ i )
-   |                      ^^^ expected one of `move`, `|`, or `||` here
+   |                         ^
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr
index 25dd66b81f5..19a9cf3a6f5 100644
--- a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr
+++ b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr
@@ -41,13 +41,13 @@ LL |     barplus!(); //~ERROR unexpected end of macro invocation
    |     ^^^^^^^^^^^ unexpected end of macro invocation
 
 error: unexpected end of macro invocation
-  --> $DIR/macro-at-most-once-rep-2018.rs:41:14
+  --> $DIR/macro-at-most-once-rep-2018.rs:41:15
    |
 LL | macro_rules! barplus {
    | -------------------- when calling this macro
 ...
 LL |     barplus!(a); //~ERROR unexpected end of macro invocation
-   |              ^ unexpected end of macro invocation
+   |               ^ unexpected end of macro invocation
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:42:15
@@ -77,13 +77,13 @@ LL |     barstar!(); //~ERROR unexpected end of macro invocation
    |     ^^^^^^^^^^^ unexpected end of macro invocation
 
 error: unexpected end of macro invocation
-  --> $DIR/macro-at-most-once-rep-2018.rs:48:14
+  --> $DIR/macro-at-most-once-rep-2018.rs:48:15
    |
 LL | macro_rules! barstar {
    | -------------------- when calling this macro
 ...
 LL |     barstar!(a); //~ERROR unexpected end of macro invocation
-   |              ^ unexpected end of macro invocation
+   |               ^ unexpected end of macro invocation
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:49:15
diff --git a/src/test/ui/macros/macro-in-expression-context-2.stderr b/src/test/ui/macros/macro-in-expression-context-2.stderr
index 80d5dbd66cc..3a4c9c0cdec 100644
--- a/src/test/ui/macros/macro-in-expression-context-2.stderr
+++ b/src/test/ui/macros/macro-in-expression-context-2.stderr
@@ -1,4 +1,4 @@
-error: expected expression, found `<eof>`
+error: expected expression, found the end of the macro arm
   --> $DIR/macro-in-expression-context-2.rs:5:16
    |
 LL |         _ => { empty!() }