From 5363f350887b1e5b5dd21a86f88c8af9d7fea6da Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:25 +0200 Subject: Merging upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- .../assert-trailing-junk.with-generic-asset.stderr | 4 ++ ...sert-trailing-junk.without-generic-asset.stderr | 4 ++ src/test/ui/macros/attr-from-macro.rs | 20 ++++++++ src/test/ui/macros/auxiliary/attr-from-macro.rs | 15 ++++++ src/test/ui/macros/issue-103529.rs | 13 ++++++ src/test/ui/macros/issue-103529.stderr | 39 ++++++++++++++++ .../issue-104769-concat_bytes-invalid-literal.rs | 8 ++++ ...ssue-104769-concat_bytes-invalid-literal.stderr | 16 +++++++ src/test/ui/macros/issue-105011.rs | 3 ++ src/test/ui/macros/issue-105011.stderr | 8 ++++ src/test/ui/macros/issue-38715.rs | 12 ++++- src/test/ui/macros/issue-38715.stderr | 15 +++++- src/test/ui/macros/issue-68060.rs | 4 ++ src/test/ui/macros/issue-68060.stderr | 18 +++++++- .../ui/macros/macro-at-most-once-rep-2015.stderr | 54 ++++++++++++++++++++++ .../ui/macros/macro-at-most-once-rep-2018.stderr | 54 ++++++++++++++++++++++ src/test/ui/macros/macro-non-lifetime.stderr | 6 +++ src/test/ui/macros/missing-comma.stderr | 36 +++++++++++++++ src/test/ui/macros/nonterminal-matching.stderr | 8 ++++ src/test/ui/macros/recovery-allowed.rs | 8 ++++ src/test/ui/macros/recovery-allowed.stderr | 10 ++++ src/test/ui/macros/recovery-forbidden.rs | 13 ++++++ src/test/ui/macros/syntax-error-recovery.stderr | 1 + src/test/ui/macros/trace_faulty_macros.stderr | 1 + 24 files changed, 366 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/macros/attr-from-macro.rs create mode 100644 src/test/ui/macros/auxiliary/attr-from-macro.rs create mode 100644 src/test/ui/macros/issue-103529.rs create mode 100644 src/test/ui/macros/issue-103529.stderr create mode 100644 src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.rs create mode 100644 src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr create mode 100644 src/test/ui/macros/issue-105011.rs create mode 100644 src/test/ui/macros/issue-105011.stderr create mode 100644 src/test/ui/macros/recovery-allowed.rs create mode 100644 src/test/ui/macros/recovery-allowed.stderr create mode 100644 src/test/ui/macros/recovery-forbidden.rs (limited to 'src/test/ui/macros') diff --git a/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr b/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr index 09dd16a0b..1e73320e4 100644 --- a/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr +++ b/src/test/ui/macros/assert-trailing-junk.with-generic-asset.stderr @@ -17,6 +17,8 @@ LL | assert!(true, "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: unexpected string literal --> $DIR/assert-trailing-junk.rs:18:18 @@ -33,6 +35,8 @@ LL | assert!(true "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: macro requires an expression as an argument --> $DIR/assert-trailing-junk.rs:22:5 diff --git a/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr b/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr index 09dd16a0b..1e73320e4 100644 --- a/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr +++ b/src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr @@ -17,6 +17,8 @@ LL | assert!(true, "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: unexpected string literal --> $DIR/assert-trailing-junk.rs:18:18 @@ -33,6 +35,8 @@ LL | assert!(true "whatever" blah); | -^^^^ no rules expected this token in macro call | | | help: missing comma here + | + = note: while trying to match sequence start error: macro requires an expression as an argument --> $DIR/assert-trailing-junk.rs:22:5 diff --git a/src/test/ui/macros/attr-from-macro.rs b/src/test/ui/macros/attr-from-macro.rs new file mode 100644 index 000000000..bb3a5c94d --- /dev/null +++ b/src/test/ui/macros/attr-from-macro.rs @@ -0,0 +1,20 @@ +// aux-build:attr-from-macro.rs +// run-pass + +extern crate attr_from_macro; + +attr_from_macro::creator! { + struct Foo; + enum Bar; + enum FooBar; +} + +fn main() { + // Checking the `repr(u32)` on the enum. + assert_eq!(4, std::mem::size_of::()); + // Checking the `repr(u16)` on the enum. + assert_eq!(2, std::mem::size_of::()); + + // Checking the Debug impl on the types. + eprintln!("{:?} {:?} {:?}", Foo, Bar::A, FooBar::A); +} diff --git a/src/test/ui/macros/auxiliary/attr-from-macro.rs b/src/test/ui/macros/auxiliary/attr-from-macro.rs new file mode 100644 index 000000000..9b388675c --- /dev/null +++ b/src/test/ui/macros/auxiliary/attr-from-macro.rs @@ -0,0 +1,15 @@ +#[macro_export] +macro_rules! creator { + (struct $name1:ident; enum $name2:ident; enum $name3:ident;) => { + #[derive(Debug)] + pub struct $name1; + + #[derive(Debug)] + #[repr(u32)] + pub enum $name2 { A } + + #[derive(Debug)] + #[repr(u16)] + pub enum $name3 { A } + } +} diff --git a/src/test/ui/macros/issue-103529.rs b/src/test/ui/macros/issue-103529.rs new file mode 100644 index 000000000..fa05baed7 --- /dev/null +++ b/src/test/ui/macros/issue-103529.rs @@ -0,0 +1,13 @@ +macro_rules! m { + ($s:stmt) => {} +} + +m! { mut x } +//~^ ERROR expected expression, found keyword `mut` +//~| ERROR expected a statement +m! { auto x } +//~^ ERROR invalid variable declaration +m! { var x } +//~^ ERROR invalid variable declaration + +fn main() {} diff --git a/src/test/ui/macros/issue-103529.stderr b/src/test/ui/macros/issue-103529.stderr new file mode 100644 index 000000000..61e322afc --- /dev/null +++ b/src/test/ui/macros/issue-103529.stderr @@ -0,0 +1,39 @@ +error: expected expression, found keyword `mut` + --> $DIR/issue-103529.rs:5:6 + | +LL | m! { mut x } + | ^^^ expected expression + +error: expected a statement + --> $DIR/issue-103529.rs:5:10 + | +LL | ($s:stmt) => {} + | ------- while parsing argument for this `stmt` macro fragment +... +LL | m! { mut x } + | ^ + +error: invalid variable declaration + --> $DIR/issue-103529.rs:8:6 + | +LL | m! { auto x } + | ^^^^ + | +help: write `let` instead of `auto` to introduce a new variable + | +LL | m! { let x } + | ~~~ + +error: invalid variable declaration + --> $DIR/issue-103529.rs:10:6 + | +LL | m! { var x } + | ^^^ + | +help: write `let` instead of `var` to introduce a new variable + | +LL | m! { let x } + | ~~~ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.rs b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.rs new file mode 100644 index 000000000..24150376e --- /dev/null +++ b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.rs @@ -0,0 +1,8 @@ +#![feature(concat_bytes)] + +fn main() { + concat_bytes!(7Y); + //~^ ERROR invalid suffix `Y` for number literal + concat_bytes!(888888888888888888888888888888888888888); + //~^ ERROR integer literal is too large +} diff --git a/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr new file mode 100644 index 000000000..8d70faa49 --- /dev/null +++ b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr @@ -0,0 +1,16 @@ +error: invalid suffix `Y` for number literal + --> $DIR/issue-104769-concat_bytes-invalid-literal.rs:4:19 + | +LL | concat_bytes!(7Y); + | ^^ invalid suffix `Y` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: integer literal is too large + --> $DIR/issue-104769-concat_bytes-invalid-literal.rs:6:19 + | +LL | concat_bytes!(888888888888888888888888888888888888888); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/macros/issue-105011.rs b/src/test/ui/macros/issue-105011.rs new file mode 100644 index 000000000..da12c3814 --- /dev/null +++ b/src/test/ui/macros/issue-105011.rs @@ -0,0 +1,3 @@ +fn main() { + println!(""y); //~ ERROR suffixes on string literals are invalid +} diff --git a/src/test/ui/macros/issue-105011.stderr b/src/test/ui/macros/issue-105011.stderr new file mode 100644 index 000000000..e898af7fa --- /dev/null +++ b/src/test/ui/macros/issue-105011.stderr @@ -0,0 +1,8 @@ +error: suffixes on string literals are invalid + --> $DIR/issue-105011.rs:2:14 + | +LL | println!(""y); + | ^^^ invalid suffix `y` + +error: aborting due to previous error + diff --git a/src/test/ui/macros/issue-38715.rs b/src/test/ui/macros/issue-38715.rs index 9a9a501ca..85ed97663 100644 --- a/src/test/ui/macros/issue-38715.rs +++ b/src/test/ui/macros/issue-38715.rs @@ -1,7 +1,17 @@ #[macro_export] -macro_rules! foo { ($i:ident) => {} } +macro_rules! foo { () => {} } #[macro_export] macro_rules! foo { () => {} } //~ ERROR the name `foo` is defined multiple times +mod inner1 { + #[macro_export] + macro_rules! bar { () => {} } +} + +mod inner2 { + #[macro_export] + macro_rules! bar { () => {} } //~ ERROR the name `bar` is defined multiple times +} + fn main() {} diff --git a/src/test/ui/macros/issue-38715.stderr b/src/test/ui/macros/issue-38715.stderr index c87d9f736..828a7f459 100644 --- a/src/test/ui/macros/issue-38715.stderr +++ b/src/test/ui/macros/issue-38715.stderr @@ -1,7 +1,7 @@ error[E0428]: the name `foo` is defined multiple times --> $DIR/issue-38715.rs:5:1 | -LL | macro_rules! foo { ($i:ident) => {} } +LL | macro_rules! foo { () => {} } | ---------------- previous definition of the macro `foo` here ... LL | macro_rules! foo { () => {} } @@ -9,6 +9,17 @@ LL | macro_rules! foo { () => {} } | = note: `foo` must be defined only once in the macro namespace of this module -error: aborting due to previous error +error[E0428]: the name `bar` is defined multiple times + --> $DIR/issue-38715.rs:14:5 + | +LL | macro_rules! bar { () => {} } + | ---------------- previous definition of the macro `bar` here +... +LL | macro_rules! bar { () => {} } + | ^^^^^^^^^^^^^^^^ `bar` redefined here + | + = note: `bar` must be defined only once in the macro namespace of this module + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui/macros/issue-68060.rs b/src/test/ui/macros/issue-68060.rs index aa8f578ad..fb40cd538 100644 --- a/src/test/ui/macros/issue-68060.rs +++ b/src/test/ui/macros/issue-68060.rs @@ -3,7 +3,11 @@ fn main() { .map( #[target_feature(enable = "")] //~^ ERROR: attribute should be applied to a function + //~| ERROR: feature named `` is not valid + //~| NOTE: `` is not valid for this target #[track_caller] + //~^ ERROR: `#[track_caller]` on closures is currently unstable + //~| NOTE: see issue #87417 |_| (), //~^ NOTE: not a function ) diff --git a/src/test/ui/macros/issue-68060.stderr b/src/test/ui/macros/issue-68060.stderr index b13e418e6..52e6ed92e 100644 --- a/src/test/ui/macros/issue-68060.stderr +++ b/src/test/ui/macros/issue-68060.stderr @@ -7,5 +7,21 @@ LL | #[target_feature(enable = "")] LL | |_| (), | ------ not a function definition -error: aborting due to previous error +error: the feature named `` is not valid for this target + --> $DIR/issue-68060.rs:4:30 + | +LL | #[target_feature(enable = "")] + | ^^^^^^^^^^^ `` is not valid for this target + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/issue-68060.rs:8:13 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/macros/macro-at-most-once-rep-2015.stderr b/src/test/ui/macros/macro-at-most-once-rep-2015.stderr index 9a3df858e..7c45b85bc 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2015.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2015.stderr @@ -12,6 +12,8 @@ LL | macro_rules! foo { ... LL | foo!(a?); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:26:11 @@ -21,6 +23,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:27:11 @@ -30,6 +34,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:29:5 @@ -39,6 +45,12 @@ LL | macro_rules! barplus { ... LL | barplus!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:30:15 @@ -48,6 +60,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:31:15 @@ -57,6 +75,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:32:15 @@ -66,6 +90,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2015.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:36:5 @@ -75,6 +105,12 @@ LL | macro_rules! barstar { ... LL | barstar!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2015.rs:37:15 @@ -84,6 +120,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:38:15 @@ -93,6 +135,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2015.rs:39:15 @@ -102,6 +150,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2015.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: aborting due to 12 previous errors diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr index 013fabe13..696520b28 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr @@ -12,6 +12,8 @@ LL | macro_rules! foo { ... LL | foo!(a?); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:26:11 @@ -21,6 +23,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:27:11 @@ -30,6 +34,8 @@ LL | macro_rules! foo { ... LL | foo!(a?a?a); | ^ no rules expected this token in macro call + | + = note: while trying to match sequence end error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:29:5 @@ -39,6 +45,12 @@ LL | macro_rules! barplus { ... LL | barplus!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:30:15 @@ -48,6 +60,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:31:15 @@ -57,6 +75,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:32:15 @@ -66,6 +90,12 @@ LL | macro_rules! barplus { ... LL | barplus!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `+` + --> $DIR/macro-at-most-once-rep-2018.rs:15:11 + | +LL | ($(a)?+) => {}; // ok. matches "a+" and "+" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:36:5 @@ -75,6 +105,12 @@ LL | macro_rules! barstar { ... LL | barstar!(); | ^^^^^^^^^^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: unexpected end of macro invocation --> $DIR/macro-at-most-once-rep-2018.rs:37:15 @@ -84,6 +120,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a); | ^ missing tokens in macro arguments + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:38:15 @@ -93,6 +135,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:39:15 @@ -102,6 +150,12 @@ LL | macro_rules! barstar { ... LL | barstar!(a?a); | ^ no rules expected this token in macro call + | +note: while trying to match `*` + --> $DIR/macro-at-most-once-rep-2018.rs:19:11 + | +LL | ($(a)?*) => {}; // ok. matches "a*" and "*" + | ^ error: aborting due to 12 previous errors diff --git a/src/test/ui/macros/macro-non-lifetime.stderr b/src/test/ui/macros/macro-non-lifetime.stderr index 6234735df..e1ed87f94 100644 --- a/src/test/ui/macros/macro-non-lifetime.stderr +++ b/src/test/ui/macros/macro-non-lifetime.stderr @@ -6,6 +6,12 @@ LL | macro_rules! m { ($x:lifetime) => { } } ... LL | m!(a); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$x:lifetime` + --> $DIR/macro-non-lifetime.rs:3:19 + | +LL | macro_rules! m { ($x:lifetime) => { } } + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr index 6da92bdea..81877a29e 100644 --- a/src/test/ui/macros/missing-comma.stderr +++ b/src/test/ui/macros/missing-comma.stderr @@ -14,6 +14,12 @@ LL | foo!(a b); | -^ no rules expected this token in macro call | | | help: missing comma here + | +note: while trying to match meta-variable `$a:ident` + --> $DIR/missing-comma.rs:2:6 + | +LL | ($a:ident) => (); + | ^^^^^^^^ error: no rules expected the token `e` --> $DIR/missing-comma.rs:23:21 @@ -25,6 +31,12 @@ LL | foo!(a, b, c, d e); | -^ no rules expected this token in macro call | | | help: missing comma here + | +note: while trying to match meta-variable `$d:ident` + --> $DIR/missing-comma.rs:5:36 + | +LL | ($a:ident, $b:ident, $c:ident, $d:ident) => (); + | ^^^^^^^^ error: no rules expected the token `d` --> $DIR/missing-comma.rs:25:18 @@ -36,6 +48,12 @@ LL | foo!(a, b, c d, e); | -^ no rules expected this token in macro call | | | help: missing comma here + | +note: while trying to match meta-variable `$c:ident` + --> $DIR/missing-comma.rs:4:26 + | +LL | ($a:ident, $b:ident, $c:ident) => (); + | ^^^^^^^^ error: no rules expected the token `d` --> $DIR/missing-comma.rs:27:18 @@ -45,6 +63,12 @@ LL | macro_rules! foo { ... LL | foo!(a, b, c d e); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$c:ident` + --> $DIR/missing-comma.rs:4:26 + | +LL | ($a:ident, $b:ident, $c:ident) => (); + | ^^^^^^^^ error: unexpected end of macro invocation --> $DIR/missing-comma.rs:29:23 @@ -54,6 +78,12 @@ LL | macro_rules! bar { ... LL | bar!(Level::Error, ); | ^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$arg:tt` + --> $DIR/missing-comma.rs:10:19 + | +LL | ($lvl:expr, $($arg:tt)+) => {} + | ^^^^^^^ error: no rules expected the token `,` --> $DIR/missing-comma.rs:32:38 @@ -63,6 +93,12 @@ LL | macro_rules! check { ... LL | check!(::fmt, "fmt",); | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$expected:expr` + --> $DIR/missing-comma.rs:14:14 + | +LL | ($ty:ty, $expected:expr) => {}; + | ^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/src/test/ui/macros/nonterminal-matching.stderr b/src/test/ui/macros/nonterminal-matching.stderr index 585f23553..5bbd54390 100644 --- a/src/test/ui/macros/nonterminal-matching.stderr +++ b/src/test/ui/macros/nonterminal-matching.stderr @@ -10,6 +10,14 @@ LL | n!(a $nt_item b); LL | complex_nonterminal!(enum E {}); | ------------------------------- in this macro invocation | +note: while trying to match `enum E {}` + --> $DIR/nonterminal-matching.rs:15:15 + | +LL | macro n(a $nt_item b) { + | ^^^^^^^^ +... +LL | complex_nonterminal!(enum E {}); + | ------------------------------- in this macro invocation = note: this error originates in the macro `complex_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/macros/recovery-allowed.rs b/src/test/ui/macros/recovery-allowed.rs new file mode 100644 index 000000000..ebf65f1cc --- /dev/null +++ b/src/test/ui/macros/recovery-allowed.rs @@ -0,0 +1,8 @@ +macro_rules! please_recover { + ($a:expr) => {}; +} + +please_recover! { not 1 } +//~^ ERROR unexpected `1` after identifier + +fn main() {} diff --git a/src/test/ui/macros/recovery-allowed.stderr b/src/test/ui/macros/recovery-allowed.stderr new file mode 100644 index 000000000..ec036e8b1 --- /dev/null +++ b/src/test/ui/macros/recovery-allowed.stderr @@ -0,0 +1,10 @@ +error: unexpected `1` after identifier + --> $DIR/recovery-allowed.rs:5:23 + | +LL | please_recover! { not 1 } + | ----^ + | | + | help: use `!` to perform bitwise not + +error: aborting due to previous error + diff --git a/src/test/ui/macros/recovery-forbidden.rs b/src/test/ui/macros/recovery-forbidden.rs new file mode 100644 index 000000000..5dd261933 --- /dev/null +++ b/src/test/ui/macros/recovery-forbidden.rs @@ -0,0 +1,13 @@ +// check-pass + +macro_rules! dont_recover_here { + ($e:expr) => { + compile_error!("Must not recover to single !1 expr"); + }; + + (not $a:literal) => {}; +} + +dont_recover_here! { not 1 } + +fn main() {} diff --git a/src/test/ui/macros/syntax-error-recovery.stderr b/src/test/ui/macros/syntax-error-recovery.stderr index c153b3b91..c42ee9b29 100644 --- a/src/test/ui/macros/syntax-error-recovery.stderr +++ b/src/test/ui/macros/syntax-error-recovery.stderr @@ -7,6 +7,7 @@ LL | $token $($inner)? = $value, LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- in this macro invocation | + = help: enum variants can be `Variant`, `Variant = `, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` = note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro expansion ignores token `(String)` and any following diff --git a/src/test/ui/macros/trace_faulty_macros.stderr b/src/test/ui/macros/trace_faulty_macros.stderr index d6fc69402..21e47da07 100644 --- a/src/test/ui/macros/trace_faulty_macros.stderr +++ b/src/test/ui/macros/trace_faulty_macros.stderr @@ -10,6 +10,7 @@ LL | my_faulty_macro!(bcd); LL | my_faulty_macro!(); | ------------------ in this macro invocation | + = note: while trying to match end of macro = note: this error originates in the macro `my_faulty_macro` (in Nightly builds, run with -Z macro-backtrace for more info) note: trace_macro -- cgit v1.2.3