Rollup merge of #62258 - petrochenkov:idclean, r=Centril
syntax: Unsupport `foo! bar { ... }` macros in the parser
Their support in expansion was removed in https://github.com/rust-lang/rust/pull/61606.
Also un-reserve `macro_rules` as a macro name, there's no ambiguity between `macro_rules` definitions and macro calls (it also wasn't reserved correctly).
cc https://github.com/rust-lang-nursery/wg-grammar/issues/51
This commit is contained in:
commit
8867ba19de
11 changed files with 111 additions and 230 deletions
|
|
@ -11,13 +11,9 @@ macro_rules! foo{
|
|||
pub fn main() {
|
||||
foo!();
|
||||
|
||||
assert!({one! two()});
|
||||
//~^ ERROR macros that expand to items
|
||||
//~| ERROR cannot find macro `one!` in this scope
|
||||
//~| ERROR mismatched types
|
||||
assert!({one! two()}); //~ ERROR expected open delimiter
|
||||
|
||||
// regardless of whether nested macro_rules works, the following should at
|
||||
// least throw a conventional error.
|
||||
assert!({one! two});
|
||||
//~^ ERROR expected `(` or `{`, found `}`
|
||||
assert!({one! two}); //~ ERROR expected open delimiter
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +1,14 @@
|
|||
error: macros that expand to items must be delimited with braces or followed by a semicolon
|
||||
--> $DIR/issue-10536.rs:14:22
|
||||
error: expected open delimiter
|
||||
--> $DIR/issue-10536.rs:14:19
|
||||
|
|
||||
LL | assert!({one! two()});
|
||||
| ^^
|
||||
help: change the delimiters to curly braces
|
||||
|
|
||||
LL | assert!({one! two {}});
|
||||
| ^^
|
||||
help: add a semicolon
|
||||
|
|
||||
LL | assert!({one! two();});
|
||||
| ^
|
||||
| ^^^ expected open delimiter
|
||||
|
||||
error: expected `(` or `{`, found `}`
|
||||
--> $DIR/issue-10536.rs:21:22
|
||||
error: expected open delimiter
|
||||
--> $DIR/issue-10536.rs:18:19
|
||||
|
|
||||
LL | assert!({one! two});
|
||||
| ^ expected `(` or `{`
|
||||
| ^^^ expected open delimiter
|
||||
|
||||
error: cannot find macro `one!` in this scope
|
||||
--> $DIR/issue-10536.rs:14:14
|
||||
|
|
||||
LL | assert!({one! two()});
|
||||
| ^^^
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-10536.rs:14:13
|
||||
|
|
||||
LL | assert!({one! two()});
|
||||
| ^^^^^^^^^^^^ expected bool, found ()
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
foo! bar < //~ ERROR expected `(` or `{`, found `<`
|
||||
foo! bar < //~ ERROR expected open delimiter
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: expected `(` or `{`, found `<`
|
||||
--> $DIR/macro-bad-delimiter-ident.rs:2:14
|
||||
error: expected open delimiter
|
||||
--> $DIR/macro-bad-delimiter-ident.rs:2:10
|
||||
|
|
||||
LL | foo! bar <
|
||||
| ^ expected `(` or `{`
|
||||
| ^^^ expected open delimiter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#![allow(unused_macros)]
|
||||
// check-pass
|
||||
|
||||
macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules`
|
||||
macro_rules! macro_rules { () => { struct S; } } // OK
|
||||
|
||||
fn main() {}
|
||||
macro_rules! {} // OK, calls the macro defined above
|
||||
|
||||
fn main() {
|
||||
let s = S;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
error: user-defined macros may not be named `macro_rules`
|
||||
--> $DIR/user-defined-macro-rules.rs:3:1
|
||||
|
|
||||
LL | macro_rules! macro_rules { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue