-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not suggest adding semicolon/changing delimiters for macros in ite…
…m position that originates in macros
- Loading branch information
1 parent
b31f9cc
commit 0ef4098
Showing
4 changed files
with
123 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
fn compile_error() -> TokenStream { | ||
r#"compile_error!("")"#.parse().unwrap() | ||
} | ||
|
||
#[proc_macro_derive(MyTrait)] | ||
pub fn derive(input: TokenStream) -> TokenStream { | ||
compile_error() | ||
} | ||
#[proc_macro_attribute] | ||
pub fn attribute_macro(_attr: TokenStream, mut input: TokenStream) -> TokenStream { | ||
input.extend(compile_error()); | ||
input | ||
} | ||
#[proc_macro] | ||
pub fn fn_macro(_item: TokenStream) -> TokenStream { | ||
compile_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,16 @@ | ||
// aux-build: issue-91800-macro.rs | ||
|
||
#[macro_use] | ||
extern crate issue_91800_macro; | ||
|
||
#[derive(MyTrait)] | ||
//~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon | ||
//~| ERROR proc-macro derive produced unparseable tokens | ||
#[attribute_macro] | ||
//~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon | ||
struct MyStruct; | ||
|
||
fn_macro! {} | ||
//~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon | ||
|
||
fn main() {} |
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,56 @@ | ||
error: macros that expand to items must be delimited with braces or followed by a semicolon | ||
--> $DIR/issue-91800.rs:6:10 | ||
| | ||
LL | #[derive(MyTrait)] | ||
| ^^^^^^^ | ||
| | ||
= note: this error originates in the derive macro `MyTrait` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: proc-macro derive produced unparseable tokens | ||
--> $DIR/issue-91800.rs:6:10 | ||
| | ||
LL | #[derive(MyTrait)] | ||
| ^^^^^^^ | ||
|
||
error: | ||
--> $DIR/issue-91800.rs:6:10 | ||
| | ||
LL | #[derive(MyTrait)] | ||
| ^^^^^^^ | ||
| | ||
= note: this error originates in the derive macro `MyTrait` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: macros that expand to items must be delimited with braces or followed by a semicolon | ||
--> $DIR/issue-91800.rs:9:1 | ||
| | ||
LL | #[attribute_macro] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the attribute macro `attribute_macro` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: | ||
--> $DIR/issue-91800.rs:9:1 | ||
| | ||
LL | #[attribute_macro] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the attribute macro `attribute_macro` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: macros that expand to items must be delimited with braces or followed by a semicolon | ||
--> $DIR/issue-91800.rs:13:1 | ||
| | ||
LL | fn_macro! {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the macro `fn_macro` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: | ||
--> $DIR/issue-91800.rs:13:1 | ||
| | ||
LL | fn_macro! {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the macro `fn_macro` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 7 previous errors | ||
|