-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: better error cases with bad/missing identifiers in MBEs
- Loading branch information
1 parent
503e129
commit ee200da
Showing
14 changed files
with
120 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Ensures MBEs with a missing ident produce a readable error | ||
|
||
macro_rules! { | ||
//~^ ERROR: expected identifier, found `{` | ||
//~| NOTE: expected identifier | ||
//~| NOTE: maybe you have forgotten to define a name for this `macro_rules!` | ||
() => {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: expected identifier, found `{` | ||
--> $DIR/mbe-missing-ident-error.rs:3:14 | ||
| | ||
LL | macro_rules! { | ||
| ^ expected identifier | ||
| | ||
= note: maybe you have forgotten to define a name for this `macro_rules!` | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Ensures MBEs with a invalid ident produce a readable error | ||
|
||
macro_rules! (meepmeep) { | ||
//~^ ERROR: expected identifier, found `(` | ||
//~| NOTE: expected identifier | ||
//~| NOTE: try removing the parenthesis around the name for this `macro_rules!` | ||
() => {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: expected identifier, found `(` | ||
--> $DIR/mbe-parenthesis-ident-error.rs:3:14 | ||
| | ||
LL | macro_rules! (meepmeep) { | ||
| ^ expected identifier | ||
| | ||
note: try removing the parenthesis around the name for this `macro_rules!` | ||
--> $DIR/mbe-parenthesis-ident-error.rs:3:15 | ||
| | ||
LL | macro_rules! (meepmeep) { | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
// check-pass | ||
// check-fail | ||
|
||
macro_rules! macro_rules { () => { struct S; } } // OK | ||
macro_rules! macro_rules { () => {} } //~ ERROR: user-defined macro may not be named `macro_rules` | ||
|
||
macro_rules! {} // OK, calls the macro defined above | ||
|
||
fn main() { | ||
let s = S; | ||
} | ||
macro_rules! {} //~ ERROR: expected identifier, found `{` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: user-defined macro may not be named `macro_rules` | ||
--> $DIR/user-defined-macro-rules.rs:3:14 | ||
| | ||
LL | macro_rules! macro_rules { () => {} } | ||
| ^^^^^^^^^^^ | ||
|
||
error: expected identifier, found `{` | ||
--> $DIR/user-defined-macro-rules.rs:5:14 | ||
| | ||
LL | macro_rules! {} | ||
| ^ expected identifier | ||
| | ||
= note: maybe you have forgotten to define a name for this `macro_rules!` | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.