diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2022-05-24 23:41:34 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-16 02:19:31 +0000 |
| commit | 0ef4098a540f0e8b91f64e1a5670b4e3ff1f48f3 (patch) | |
| tree | 83c7c2bfc3a7e460dc67a9e52cdd255aa0c1ed2d /src/test/ui/proc-macro | |
| parent | b31f9cc22bcd720b37ddf927afe378108a5b9a54 (diff) | |
| download | rust-0ef4098a540f0e8b91f64e1a5670b4e3ff1f48f3.tar.gz rust-0ef4098a540f0e8b91f64e1a5670b4e3ff1f48f3.zip | |
Do not suggest adding semicolon/changing delimiters for macros in item position that originates in macros
Diffstat (limited to 'src/test/ui/proc-macro')
| -rw-r--r-- | src/test/ui/proc-macro/auxiliary/issue-91800-macro.rs | 26 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/issue-91800.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/issue-91800.stderr | 56 |
3 files changed, 98 insertions, 0 deletions
diff --git a/src/test/ui/proc-macro/auxiliary/issue-91800-macro.rs b/src/test/ui/proc-macro/auxiliary/issue-91800-macro.rs new file mode 100644 index 00000000000..958a8bed9e2 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/issue-91800-macro.rs @@ -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() +} diff --git a/src/test/ui/proc-macro/issue-91800.rs b/src/test/ui/proc-macro/issue-91800.rs new file mode 100644 index 00000000000..0c1281de4f8 --- /dev/null +++ b/src/test/ui/proc-macro/issue-91800.rs @@ -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() {} diff --git a/src/test/ui/proc-macro/issue-91800.stderr b/src/test/ui/proc-macro/issue-91800.stderr new file mode 100644 index 00000000000..9c356263a36 --- /dev/null +++ b/src/test/ui/proc-macro/issue-91800.stderr @@ -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 + |
