expand: address review comments
This commit is contained in:
parent
21944b3a10
commit
d8080d828c
9 changed files with 64 additions and 64 deletions
|
@ -180,17 +180,12 @@ impl TTMacroExpander for MacroRulesMacroExpander {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MacroRulesDummyExpander;
|
fn macro_rules_dummy_expander<'cx>(
|
||||||
|
_: &'cx mut ExtCtxt<'_>,
|
||||||
impl TTMacroExpander for MacroRulesDummyExpander {
|
span: Span,
|
||||||
fn expand<'cx>(
|
_: TokenStream,
|
||||||
&self,
|
) -> Box<dyn MacResult + 'cx> {
|
||||||
_: &'cx mut ExtCtxt<'_>,
|
DummyResult::any(span)
|
||||||
sp: Span,
|
|
||||||
_: TokenStream,
|
|
||||||
) -> Box<dyn MacResult + 'cx> {
|
|
||||||
DummyResult::any(sp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trace_macros_note(cx_expansions: &mut FxHashMap<Span, Vec<String>>, sp: Span, message: String) {
|
fn trace_macros_note(cx_expansions: &mut FxHashMap<Span, Vec<String>>, sp: Span, message: String) {
|
||||||
|
@ -443,14 +438,14 @@ pub fn compile_declarative_macro(
|
||||||
let s = parse_failure_msg(&token);
|
let s = parse_failure_msg(&token);
|
||||||
let sp = token.span.substitute_dummy(def.span);
|
let sp = token.span.substitute_dummy(def.span);
|
||||||
sess.span_diagnostic.struct_span_err(sp, &s).span_label(sp, msg).emit();
|
sess.span_diagnostic.struct_span_err(sp, &s).span_label(sp, msg).emit();
|
||||||
return mk_syn_ext(Box::new(MacroRulesDummyExpander));
|
return mk_syn_ext(Box::new(macro_rules_dummy_expander));
|
||||||
}
|
}
|
||||||
Error(sp, msg) => {
|
Error(sp, msg) => {
|
||||||
sess.span_diagnostic.struct_span_err(sp.substitute_dummy(def.span), &msg).emit();
|
sess.span_diagnostic.struct_span_err(sp.substitute_dummy(def.span), &msg).emit();
|
||||||
return mk_syn_ext(Box::new(MacroRulesDummyExpander));
|
return mk_syn_ext(Box::new(macro_rules_dummy_expander));
|
||||||
}
|
}
|
||||||
ErrorReported => {
|
ErrorReported => {
|
||||||
return mk_syn_ext(Box::new(MacroRulesDummyExpander));
|
return mk_syn_ext(Box::new(macro_rules_dummy_expander));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -513,16 +508,14 @@ pub fn compile_declarative_macro(
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let expander: Box<_> = Box::new(MacroRulesMacroExpander {
|
mk_syn_ext(Box::new(MacroRulesMacroExpander {
|
||||||
name: def.ident,
|
name: def.ident,
|
||||||
span: def.span,
|
span: def.span,
|
||||||
transparency,
|
transparency,
|
||||||
lhses,
|
lhses,
|
||||||
rhses,
|
rhses,
|
||||||
valid,
|
valid,
|
||||||
});
|
}))
|
||||||
|
|
||||||
mk_syn_ext(expander)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_lhs_nt_follows(
|
fn check_lhs_nt_follows(
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
// aux-build:edition-kw-macro-2015.rs
|
// aux-build:edition-kw-macro-2015.rs
|
||||||
|
|
||||||
|
#![feature(async_closure)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -19,8 +21,10 @@ pub fn check_async() {
|
||||||
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
||||||
r#async = consumes_async_raw!(r#async); // OK
|
r#async = consumes_async_raw!(r#async); // OK
|
||||||
|
|
||||||
if passes_ident!(async) == 1 {} //~ ERROR async closures are unstable
|
if passes_ident!(async) == 1 {}
|
||||||
if passes_ident!(r#async) == 1 {} // OK
|
if passes_ident!(r#async) == 1 {} // OK
|
||||||
module::async(); //~ ERROR expected identifier, found keyword `async`
|
module::async(); //~ ERROR expected identifier, found keyword `async`
|
||||||
module::r#async(); // OK
|
module::r#async(); // OK
|
||||||
|
|
||||||
|
let _recovery_witness: () = 0; //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error: expected identifier, found keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:14:13
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:16:13
|
||||||
|
|
|
|
||||||
LL | let mut async = 1;
|
LL | let mut async = 1;
|
||||||
| ^^^^^ expected identifier, found keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
|
@ -10,7 +10,7 @@ LL | let mut r#async = 1;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:24:13
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:26:13
|
||||||
|
|
|
|
||||||
LL | module::async();
|
LL | module::async();
|
||||||
| ^^^^^ expected identifier, found keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
|
@ -21,13 +21,13 @@ LL | module::r#async();
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: no rules expected the token `r#async`
|
error: no rules expected the token `r#async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:18:31
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:20:31
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async!(r#async);
|
LL | r#async = consumes_async!(r#async);
|
||||||
| ^^^^^^^ no rules expected this token in macro call
|
| ^^^^^^^ no rules expected this token in macro call
|
||||||
|
|
||||||
error: no rules expected the token `async`
|
error: no rules expected the token `async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:19:35
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:21:35
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async_raw!(async);
|
LL | r#async = consumes_async_raw!(async);
|
||||||
| ^^^^^ no rules expected this token in macro call
|
| ^^^^^ no rules expected this token in macro call
|
||||||
|
@ -38,20 +38,19 @@ error: macro expansion ends with an incomplete expression: expected one of `move
|
||||||
LL | ($i: ident) => ($i)
|
LL | ($i: ident) => ($i)
|
||||||
| ^ expected one of `move`, `|`, or `||`
|
| ^ expected one of `move`, `|`, or `||`
|
||||||
|
|
|
|
||||||
::: $DIR/edition-keywords-2018-2015-parsing.rs:22:8
|
::: $DIR/edition-keywords-2018-2015-parsing.rs:24:8
|
||||||
|
|
|
|
||||||
LL | if passes_ident!(async) == 1 {}
|
LL | if passes_ident!(async) == 1 {}
|
||||||
| -------------------- in this macro invocation
|
| -------------------- in this macro invocation
|
||||||
|
|
||||||
error[E0658]: async closures are unstable
|
error[E0308]: mismatched types
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:22:22
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:29:33
|
||||||
|
|
|
|
||||||
LL | if passes_ident!(async) == 1 {}
|
LL | let _recovery_witness: () = 0;
|
||||||
| ^^^^^
|
| -- ^ expected `()`, found integer
|
||||||
|
|
| |
|
||||||
= note: see issue #62290 <https://github.com/rust-lang/rust/issues/62290> for more information
|
| expected due to this
|
||||||
= help: add `#![feature(async_closure)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
// aux-build:edition-kw-macro-2018.rs
|
// aux-build:edition-kw-macro-2018.rs
|
||||||
|
|
||||||
|
#![feature(async_closure)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -19,8 +21,10 @@ pub fn check_async() {
|
||||||
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
|
||||||
r#async = consumes_async_raw!(r#async); // OK
|
r#async = consumes_async_raw!(r#async); // OK
|
||||||
|
|
||||||
if passes_ident!(async) == 1 {} //~ ERROR async closures are unstable
|
if passes_ident!(async) == 1 {}
|
||||||
if passes_ident!(r#async) == 1 {} // OK
|
if passes_ident!(r#async) == 1 {} // OK
|
||||||
module::async(); //~ ERROR expected identifier, found keyword `async`
|
module::async(); //~ ERROR expected identifier, found keyword `async`
|
||||||
module::r#async(); // OK
|
module::r#async(); // OK
|
||||||
|
|
||||||
|
let _recovery_witness: () = 0; //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error: expected identifier, found keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:14:13
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:16:13
|
||||||
|
|
|
|
||||||
LL | let mut async = 1;
|
LL | let mut async = 1;
|
||||||
| ^^^^^ expected identifier, found keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
|
@ -10,7 +10,7 @@ LL | let mut r#async = 1;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:24:13
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:26:13
|
||||||
|
|
|
|
||||||
LL | module::async();
|
LL | module::async();
|
||||||
| ^^^^^ expected identifier, found keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
|
@ -21,13 +21,13 @@ LL | module::r#async();
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: no rules expected the token `r#async`
|
error: no rules expected the token `r#async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:18:31
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:20:31
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async!(r#async);
|
LL | r#async = consumes_async!(r#async);
|
||||||
| ^^^^^^^ no rules expected this token in macro call
|
| ^^^^^^^ no rules expected this token in macro call
|
||||||
|
|
||||||
error: no rules expected the token `async`
|
error: no rules expected the token `async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:19:35
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:21:35
|
||||||
|
|
|
|
||||||
LL | r#async = consumes_async_raw!(async);
|
LL | r#async = consumes_async_raw!(async);
|
||||||
| ^^^^^ no rules expected this token in macro call
|
| ^^^^^ no rules expected this token in macro call
|
||||||
|
@ -38,20 +38,19 @@ error: macro expansion ends with an incomplete expression: expected one of `move
|
||||||
LL | ($i: ident) => ($i)
|
LL | ($i: ident) => ($i)
|
||||||
| ^ expected one of `move`, `|`, or `||`
|
| ^ expected one of `move`, `|`, or `||`
|
||||||
|
|
|
|
||||||
::: $DIR/edition-keywords-2018-2018-parsing.rs:22:8
|
::: $DIR/edition-keywords-2018-2018-parsing.rs:24:8
|
||||||
|
|
|
|
||||||
LL | if passes_ident!(async) == 1 {}
|
LL | if passes_ident!(async) == 1 {}
|
||||||
| -------------------- in this macro invocation
|
| -------------------- in this macro invocation
|
||||||
|
|
||||||
error[E0658]: async closures are unstable
|
error[E0308]: mismatched types
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:22:22
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:29:33
|
||||||
|
|
|
|
||||||
LL | if passes_ident!(async) == 1 {}
|
LL | let _recovery_witness: () = 0;
|
||||||
| ^^^^^
|
| -- ^ expected `()`, found integer
|
||||||
|
|
| |
|
||||||
= note: see issue #62290 <https://github.com/rust-lang/rust/issues/62290> for more information
|
| expected due to this
|
||||||
= help: add `#![feature(async_closure)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
fn main() {}
|
|
||||||
|
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
{ $+ } => { //~ ERROR expected identifier, found `+`
|
{ $+ } => { //~ ERROR expected identifier, found `+`
|
||||||
//~^ ERROR missing fragment specifier
|
//~^ ERROR missing fragment specifier
|
||||||
|
@ -8,3 +6,5 @@ macro_rules! foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
foo!();
|
foo!();
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
error: expected identifier, found `+`
|
error: expected identifier, found `+`
|
||||||
--> $DIR/issue-33569.rs:4:8
|
--> $DIR/issue-33569.rs:2:8
|
||||||
|
|
|
|
||||||
LL | { $+ } => {
|
LL | { $+ } => {
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: expected one of: `*`, `+`, or `?`
|
error: expected one of: `*`, `+`, or `?`
|
||||||
--> $DIR/issue-33569.rs:6:13
|
--> $DIR/issue-33569.rs:4:13
|
||||||
|
|
|
|
||||||
LL | $(x)(y)
|
LL | $(x)(y)
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: missing fragment specifier
|
error: missing fragment specifier
|
||||||
--> $DIR/issue-33569.rs:4:8
|
--> $DIR/issue-33569.rs:2:8
|
||||||
|
|
|
|
||||||
LL | { $+ } => {
|
LL | { $+ } => {
|
||||||
| ^
|
| ^
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
// aux-build:invalid-punct-ident.rs
|
// aux-build:invalid-punct-ident.rs
|
||||||
|
|
||||||
// We use `main` not found below as a witness for error recovery in proc macro expansion.
|
#[macro_use]
|
||||||
|
|
||||||
#[macro_use] //~ ERROR `main` function not found
|
|
||||||
extern crate invalid_punct_ident;
|
extern crate invalid_punct_ident;
|
||||||
|
|
||||||
lexer_failure!();
|
lexer_failure!();
|
||||||
//~^ ERROR proc macro panicked
|
//~^ ERROR proc macro panicked
|
||||||
//~| ERROR unexpected closing delimiter: `)`
|
//~| ERROR unexpected closing delimiter: `)`
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _recovery_witness: () = 0; //~ ERROR mismatched types
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error: unexpected closing delimiter: `)`
|
error: unexpected closing delimiter: `)`
|
||||||
--> $DIR/invalid-punct-ident-4.rs:8:1
|
--> $DIR/invalid-punct-ident-4.rs:6:1
|
||||||
|
|
|
|
||||||
LL | lexer_failure!();
|
LL | lexer_failure!();
|
||||||
| ^^^^^^^^^^^^^^^^^ unexpected closing delimiter
|
| ^^^^^^^^^^^^^^^^^ unexpected closing delimiter
|
||||||
|
@ -7,20 +7,19 @@ LL | lexer_failure!();
|
||||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: proc macro panicked
|
error: proc macro panicked
|
||||||
--> $DIR/invalid-punct-ident-4.rs:8:1
|
--> $DIR/invalid-punct-ident-4.rs:6:1
|
||||||
|
|
|
|
||||||
LL | lexer_failure!();
|
LL | lexer_failure!();
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0601]: `main` function not found in crate `invalid_punct_ident_4`
|
error[E0308]: mismatched types
|
||||||
--> $DIR/invalid-punct-ident-4.rs:5:1
|
--> $DIR/invalid-punct-ident-4.rs:11:33
|
||||||
|
|
|
|
||||||
LL | / #[macro_use]
|
LL | let _recovery_witness: () = 0;
|
||||||
LL | | extern crate invalid_punct_ident;
|
| -- ^ expected `()`, found integer
|
||||||
LL | |
|
| |
|
||||||
LL | | lexer_failure!();
|
| expected due to this
|
||||||
| |_________________^ consider adding a `main` function to `$DIR/invalid-punct-ident-4.rs`
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0601`.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue