parent
910ec6d97f
commit
ea9ccb6046
8 changed files with 34 additions and 17 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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!() }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue