summaryrefslogtreecommitdiffstats
path: root/src/test/ui/macros
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/macros')
-rw-r--r--src/test/ui/macros/format-parse-errors.stderr2
-rw-r--r--src/test/ui/macros/issue-102878.rs10
-rw-r--r--src/test/ui/macros/issue-102878.stderr60
-rw-r--r--src/test/ui/macros/issue-39404.stderr2
-rw-r--r--src/test/ui/macros/issue-84195-lint-anon-const.stderr4
-rw-r--r--src/test/ui/macros/issue-99265.stderr278
-rw-r--r--src/test/ui/macros/issue-99907.stderr4
-rw-r--r--src/test/ui/macros/lint-trailing-macro-call.stderr2
-rw-r--r--src/test/ui/macros/macro-comma-behavior-rpass.rs1
-rw-r--r--src/test/ui/macros/macro-context.stderr4
-rw-r--r--src/test/ui/macros/macro-in-expression-context.stderr2
-rw-r--r--src/test/ui/macros/macro-match-nonterminal.stderr2
-rw-r--r--src/test/ui/macros/macro-missing-fragment-deduplication.stderr2
-rw-r--r--src/test/ui/macros/macro-missing-fragment.stderr4
-rw-r--r--src/test/ui/macros/macro-or-patterns-back-compat.stderr4
-rw-r--r--src/test/ui/macros/macro-use-all-and-none.stderr2
-rw-r--r--src/test/ui/macros/macro_rules-unmatchable-literals.rs14
-rw-r--r--src/test/ui/macros/macro_rules-unmatchable-literals.stderr14
-rw-r--r--src/test/ui/macros/macros-nonfatal-errors.rs23
-rw-r--r--src/test/ui/macros/macros-nonfatal-errors.stderr12
-rw-r--r--src/test/ui/macros/must-use-in-macro-55516.stderr2
-rw-r--r--src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs1
-rw-r--r--src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs1
-rw-r--r--src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs1
-rw-r--r--src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr44
-rw-r--r--src/test/ui/macros/stringify.rs1
-rw-r--r--src/test/ui/macros/syntax-error-recovery.rs18
-rw-r--r--src/test/ui/macros/syntax-error-recovery.stderr30
28 files changed, 361 insertions, 183 deletions
diff --git a/src/test/ui/macros/format-parse-errors.stderr b/src/test/ui/macros/format-parse-errors.stderr
index 1a7578e60..f9ea4c633 100644
--- a/src/test/ui/macros/format-parse-errors.stderr
+++ b/src/test/ui/macros/format-parse-errors.stderr
@@ -22,7 +22,7 @@ error: positional arguments cannot follow named arguments
--> $DIR/format-parse-errors.rs:10:9
|
LL | foo = foo,
- | --- named argument
+ | --------- named argument
LL | bar,
| ^^^ positional arguments must be before named arguments
diff --git a/src/test/ui/macros/issue-102878.rs b/src/test/ui/macros/issue-102878.rs
new file mode 100644
index 000000000..aac589193
--- /dev/null
+++ b/src/test/ui/macros/issue-102878.rs
@@ -0,0 +1,10 @@
+macro_rules!test{($l:expr,$_:r)=>({const:y y)}
+//~^ ERROR mismatched closing delimiter: `)`
+//~| ERROR invalid fragment specifier `r`
+//~| ERROR expected identifier, found keyword `const`
+//~| ERROR expected identifier, found keyword `const`
+//~| ERROR expected identifier, found `:`
+
+fn s(){test!(1,i)}
+
+fn main() {}
diff --git a/src/test/ui/macros/issue-102878.stderr b/src/test/ui/macros/issue-102878.stderr
new file mode 100644
index 000000000..e0b8855a3
--- /dev/null
+++ b/src/test/ui/macros/issue-102878.stderr
@@ -0,0 +1,60 @@
+error: mismatched closing delimiter: `)`
+ --> $DIR/issue-102878.rs:1:35
+ |
+LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)}
+ | -^ ^ mismatched closing delimiter
+ | ||
+ | |unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: invalid fragment specifier `r`
+ --> $DIR/issue-102878.rs:1:27
+ |
+LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)}
+ | ^^^^
+ |
+ = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
+
+error: expected identifier, found keyword `const`
+ --> $DIR/issue-102878.rs:1:36
+ |
+LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)}
+ | ^^^^^ expected identifier, found keyword
+...
+LL | fn s(){test!(1,i)}
+ | ---------- in this macro invocation
+ |
+ = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: escape `const` to use it as an identifier
+ |
+LL | macro_rules!test{($l:expr,$_:r)=>({r#const:y y)}
+ | ++
+
+error: expected identifier, found keyword `const`
+ --> $DIR/issue-102878.rs:1:36
+ |
+LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)}
+ | ^^^^^ expected identifier, found keyword
+...
+LL | fn s(){test!(1,i)}
+ | ---------- in this macro invocation
+ |
+ = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: escape `const` to use it as an identifier
+ |
+LL | macro_rules!test{($l:expr,$_:r)=>({r#const:y y)}
+ | ++
+
+error: expected identifier, found `:`
+ --> $DIR/issue-102878.rs:1:41
+ |
+LL | macro_rules!test{($l:expr,$_:r)=>({const:y y)}
+ | ^ expected identifier
+...
+LL | fn s(){test!(1,i)}
+ | ---------- in this macro invocation
+ |
+ = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 5 previous errors
+
diff --git a/src/test/ui/macros/issue-39404.stderr b/src/test/ui/macros/issue-39404.stderr
index d2f2a823c..3886a70bb 100644
--- a/src/test/ui/macros/issue-39404.stderr
+++ b/src/test/ui/macros/issue-39404.stderr
@@ -4,9 +4,9 @@ error: missing fragment specifier
LL | macro_rules! m { ($i) => {} }
| ^^
|
- = note: `#[deny(missing_fragment_specifier)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
+ = note: `#[deny(missing_fragment_specifier)]` on by default
error: aborting due to previous error
diff --git a/src/test/ui/macros/issue-84195-lint-anon-const.stderr b/src/test/ui/macros/issue-84195-lint-anon-const.stderr
index 39485d74e..306c08b13 100644
--- a/src/test/ui/macros/issue-84195-lint-anon-const.stderr
+++ b/src/test/ui/macros/issue-84195-lint-anon-const.stderr
@@ -7,13 +7,13 @@ LL | () => { 0; };
LL | let val: [u8; len!()] = [];
| ------ in this macro invocation
|
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
note: the lint level is defined here
--> $DIR/issue-84195-lint-anon-const.rs:5:9
|
LL | #![deny(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
= note: this error originates in the macro `len` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
diff --git a/src/test/ui/macros/issue-99265.stderr b/src/test/ui/macros/issue-99265.stderr
index 2bfeedd7d..9185dbff6 100644
--- a/src/test/ui/macros/issue-99265.stderr
+++ b/src/test/ui/macros/issue-99265.stderr
@@ -77,18 +77,18 @@ help: use the named argument by name to avoid ambiguity
LL | println!("Hello {:width$}!", "x", width = 5);
| ~~~~~~
-warning: named argument `width` is not used by name
- --> $DIR/issue-99265.rs:23:46
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:23:33
|
LL | println!("Hello {:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | -- ^^^^^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `width` by position
+ | -------- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `f` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("Hello {:width$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | ~~~~~~
+LL | println!("Hello {f:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | +
warning: named argument `precision` is not used by name
--> $DIR/issue-99265.rs:23:57
@@ -103,31 +103,31 @@ help: use the named argument by name to avoid ambiguity
LL | println!("Hello {:1$.precision$}!", f = 0.02f32, width = 5, precision = 2);
| ~~~~~~~~~~
-warning: named argument `f` is not used by name
- --> $DIR/issue-99265.rs:23:33
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:23:46
|
LL | println!("Hello {:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | -- ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `f` by position
+ | -- ^^^^^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `width` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("Hello {f:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | +
+LL | println!("Hello {:width$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~~~~~~
-warning: named argument `width` is not used by name
- --> $DIR/issue-99265.rs:31:47
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:31:34
|
LL | println!("Hello {0:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | -- ^^^^^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `width` by position
+ | --------- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `f` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("Hello {0:width$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | ~~~~~~
+LL | println!("Hello {f:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~
warning: named argument `precision` is not used by name
--> $DIR/issue-99265.rs:31:58
@@ -142,32 +142,32 @@ help: use the named argument by name to avoid ambiguity
LL | println!("Hello {0:1$.precision$}!", f = 0.02f32, width = 5, precision = 2);
| ~~~~~~~~~~
-warning: named argument `f` is not used by name
- --> $DIR/issue-99265.rs:31:34
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:31:47
|
LL | println!("Hello {0:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | - ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `f` by position
+ | -- ^^^^^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `width` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("Hello {f:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
- | ~
+LL | println!("Hello {0:width$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~~~~~~
-warning: named argument `width` is not used by name
- --> $DIR/issue-99265.rs:52:9
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:49:9
|
LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
- | -- this formatting argument uses named argument `width` by position
+ | --------- this formatting argument uses named argument `f` by position
...
-LL | width = 5,
- | ^^^^^ this named argument is referred to by position in formatting string
+LL | f = 0.02f32,
+ | ^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | "{}, Hello {1:width$.3$} {4:5$.6$}! {1}",
- | ~~~~~~
+LL | "{}, Hello {f:2$.3$} {4:5$.6$}! {1}",
+ | ~
warning: named argument `precision` is not used by name
--> $DIR/issue-99265.rs:54:9
@@ -183,33 +183,33 @@ help: use the named argument by name to avoid ambiguity
LL | "{}, Hello {1:2$.precision$} {4:5$.6$}! {1}",
| ~~~~~~~~~~
-warning: named argument `f` is not used by name
- --> $DIR/issue-99265.rs:49:9
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:52:9
|
LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
- | - this formatting argument uses named argument `f` by position
+ | -- this formatting argument uses named argument `width` by position
...
-LL | f = 0.02f32,
- | ^ this named argument is referred to by position in formatting string
+LL | width = 5,
+ | ^^^^^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | "{}, Hello {f:2$.3$} {4:5$.6$}! {1}",
- | ~
+LL | "{}, Hello {1:width$.3$} {4:5$.6$}! {1}",
+ | ~~~~~~
-warning: named argument `width2` is not used by name
- --> $DIR/issue-99265.rs:58:9
+warning: named argument `g` is not used by name
+ --> $DIR/issue-99265.rs:56:9
|
LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
- | -- this formatting argument uses named argument `width2` by position
+ | --------- this formatting argument uses named argument `g` by position
...
-LL | width2 = 5,
- | ^^^^^^ this named argument is referred to by position in formatting string
+LL | g = 0.02f32,
+ | ^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | "{}, Hello {1:2$.3$} {4:width2$.6$}! {1}",
- | ~~~~~~~
+LL | "{}, Hello {1:2$.3$} {g:5$.6$}! {1}",
+ | ~
warning: named argument `precision2` is not used by name
--> $DIR/issue-99265.rs:60:9
@@ -225,25 +225,25 @@ help: use the named argument by name to avoid ambiguity
LL | "{}, Hello {1:2$.3$} {4:5$.precision2$}! {1}",
| ~~~~~~~~~~~
-warning: named argument `g` is not used by name
- --> $DIR/issue-99265.rs:56:9
+warning: named argument `width2` is not used by name
+ --> $DIR/issue-99265.rs:58:9
|
LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
- | - this formatting argument uses named argument `g` by position
+ | -- this formatting argument uses named argument `width2` by position
...
-LL | g = 0.02f32,
- | ^ this named argument is referred to by position in formatting string
+LL | width2 = 5,
+ | ^^^^^^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | "{}, Hello {1:2$.3$} {g:5$.6$}! {1}",
- | ~
+LL | "{}, Hello {1:2$.3$} {4:width2$.6$}! {1}",
+ | ~~~~~~~
warning: named argument `f` is not used by name
--> $DIR/issue-99265.rs:49:9
|
LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
- | - this formatting argument uses named argument `f` by position
+ | --- this formatting argument uses named argument `f` by position
...
LL | f = 0.02f32,
| ^ this named argument is referred to by position in formatting string
@@ -257,7 +257,7 @@ warning: named argument `f` is not used by name
--> $DIR/issue-99265.rs:64:31
|
LL | println!("Hello {:0.1}!", f = 0.02f32);
- | -- ^ this named argument is referred to by position in formatting string
+ | ------ ^ this named argument is referred to by position in formatting string
| |
| this formatting argument uses named argument `f` by position
|
@@ -270,9 +270,9 @@ warning: named argument `f` is not used by name
--> $DIR/issue-99265.rs:68:32
|
LL | println!("Hello {0:0.1}!", f = 0.02f32);
- | - ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `f` by position
+ | ------- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `f` by position
|
help: use the named argument by name to avoid ambiguity
|
@@ -283,6 +283,19 @@ warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:79:23
|
LL | println!("{:0$}", v = val);
+ | ----- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{v:0$}", v = val);
+ | +
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:79:23
+ |
+LL | println!("{:0$}", v = val);
| -- ^ this named argument is referred to by position in formatting string
| |
| this formatting argument uses named argument `v` by position
@@ -293,17 +306,17 @@ LL | println!("{:v$}", v = val);
| ~~
warning: named argument `v` is not used by name
- --> $DIR/issue-99265.rs:79:23
+ --> $DIR/issue-99265.rs:84:24
|
-LL | println!("{:0$}", v = val);
- | -- ^ this named argument is referred to by position in formatting string
+LL | println!("{0:0$}", v = val);
+ | ------ ^ this named argument is referred to by position in formatting string
| |
| this formatting argument uses named argument `v` by position
|
help: use the named argument by name to avoid ambiguity
|
LL | println!("{v:0$}", v = val);
- | +
+ | ~
warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:84:24
@@ -319,30 +332,17 @@ LL | println!("{0:v$}", v = val);
| ~~
warning: named argument `v` is not used by name
- --> $DIR/issue-99265.rs:84:24
- |
-LL | println!("{0:0$}", v = val);
- | - ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `v` by position
- |
-help: use the named argument by name to avoid ambiguity
- |
-LL | println!("{v:0$}", v = val);
- | ~
-
-warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:89:26
|
LL | println!("{:0$.0$}", v = val);
- | -- ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `v` by position
+ | -------- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("{:v$.0$}", v = val);
- | ~~
+LL | println!("{v:0$.0$}", v = val);
+ | +
warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:89:26
@@ -361,27 +361,27 @@ warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:89:26
|
LL | println!("{:0$.0$}", v = val);
- | -- ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `v` by position
+ | -- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("{v:0$.0$}", v = val);
- | +
+LL | println!("{:v$.0$}", v = val);
+ | ~~
warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:96:27
|
LL | println!("{0:0$.0$}", v = val);
- | -- ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `v` by position
+ | --------- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("{0:v$.0$}", v = val);
- | ~~
+LL | println!("{v:0$.0$}", v = val);
+ | ~
warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:96:27
@@ -400,14 +400,14 @@ warning: named argument `v` is not used by name
--> $DIR/issue-99265.rs:96:27
|
LL | println!("{0:0$.0$}", v = val);
- | - ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `v` by position
+ | -- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("{v:0$.0$}", v = val);
- | ~
+LL | println!("{0:v$.0$}", v = val);
+ | ~~
warning: named argument `a` is not used by name
--> $DIR/issue-99265.rs:104:28
@@ -426,28 +426,28 @@ warning: named argument `a` is not used by name
--> $DIR/issue-99265.rs:104:28
|
LL | println!("{} {a} {0}", a = 1);
- | - ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `a` by position
+ | --- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `a` by position
|
help: use the named argument by name to avoid ambiguity
|
LL | println!("{} {a} {a}", a = 1);
| ~
-warning: named argument `b` is not used by name
- --> $DIR/issue-99265.rs:115:23
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:115:14
|
LL | {:1$.2$}",
- | -- this formatting argument uses named argument `b` by position
+ | -------- this formatting argument uses named argument `a` by position
...
LL | a = 1.0, b = 1, c = 2,
- | ^ this named argument is referred to by position in formatting string
+ | ^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | {:b$.2$}",
- | ~~
+LL | {a:1$.2$}",
+ | +
warning: named argument `c` is not used by name
--> $DIR/issue-99265.rs:115:30
@@ -463,33 +463,33 @@ help: use the named argument by name to avoid ambiguity
LL | {:1$.c$}",
| ~~
-warning: named argument `a` is not used by name
- --> $DIR/issue-99265.rs:115:14
+warning: named argument `b` is not used by name
+ --> $DIR/issue-99265.rs:115:23
|
LL | {:1$.2$}",
- | -- this formatting argument uses named argument `a` by position
+ | -- this formatting argument uses named argument `b` by position
...
LL | a = 1.0, b = 1, c = 2,
- | ^ this named argument is referred to by position in formatting string
+ | ^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | {a:1$.2$}",
- | +
+LL | {:b$.2$}",
+ | ~~
-warning: named argument `b` is not used by name
- --> $DIR/issue-99265.rs:126:23
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:126:14
|
LL | {0:1$.2$}",
- | -- this formatting argument uses named argument `b` by position
+ | --------- this formatting argument uses named argument `a` by position
...
LL | a = 1.0, b = 1, c = 2,
- | ^ this named argument is referred to by position in formatting string
+ | ^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | {0:b$.2$}",
- | ~~
+LL | {a:1$.2$}",
+ | ~
warning: named argument `c` is not used by name
--> $DIR/issue-99265.rs:126:30
@@ -505,32 +505,32 @@ help: use the named argument by name to avoid ambiguity
LL | {0:1$.c$}",
| ~~
-warning: named argument `a` is not used by name
- --> $DIR/issue-99265.rs:126:14
+warning: named argument `b` is not used by name
+ --> $DIR/issue-99265.rs:126:23
|
LL | {0:1$.2$}",
- | - this formatting argument uses named argument `a` by position
+ | -- this formatting argument uses named argument `b` by position
...
LL | a = 1.0, b = 1, c = 2,
- | ^ this named argument is referred to by position in formatting string
+ | ^ this named argument is referred to by position in formatting string
|
help: use the named argument by name to avoid ambiguity
|
-LL | {a:1$.2$}",
- | ~
+LL | {0:b$.2$}",
+ | ~~
-warning: named argument `width` is not used by name
- --> $DIR/issue-99265.rs:132:39
+warning: named argument `x` is not used by name
+ --> $DIR/issue-99265.rs:132:30
|
LL | println!("{{{:1$.2$}}}", x = 1.0, width = 3, precision = 2);
- | -- ^^^^^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `width` by position
+ | -------- ^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `x` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("{{{:width$.2$}}}", x = 1.0, width = 3, precision = 2);
- | ~~~~~~
+LL | println!("{{{x:1$.2$}}}", x = 1.0, width = 3, precision = 2);
+ | +
warning: named argument `precision` is not used by name
--> $DIR/issue-99265.rs:132:50
@@ -545,18 +545,18 @@ help: use the named argument by name to avoid ambiguity
LL | println!("{{{:1$.precision$}}}", x = 1.0, width = 3, precision = 2);
| ~~~~~~~~~~
-warning: named argument `x` is not used by name
- --> $DIR/issue-99265.rs:132:30
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:132:39
|
LL | println!("{{{:1$.2$}}}", x = 1.0, width = 3, precision = 2);
- | -- ^ this named argument is referred to by position in formatting string
- | |
- | this formatting argument uses named argument `x` by position
+ | -- ^^^^^ this named argument is referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `width` by position
|
help: use the named argument by name to avoid ambiguity
|
-LL | println!("{{{x:1$.2$}}}", x = 1.0, width = 3, precision = 2);
- | +
+LL | println!("{{{:width$.2$}}}", x = 1.0, width = 3, precision = 2);
+ | ~~~~~~
warning: 42 warnings emitted
diff --git a/src/test/ui/macros/issue-99907.stderr b/src/test/ui/macros/issue-99907.stderr
index 4786ce003..eefb28dee 100644
--- a/src/test/ui/macros/issue-99907.stderr
+++ b/src/test/ui/macros/issue-99907.stderr
@@ -2,7 +2,7 @@ warning: named argument `f` is not used by name
--> $DIR/issue-99907.rs:5:30
|
LL | println!("Hello {:.1}!", f = 0.02f32);
- | -- ^ this named argument is referred to by position in formatting string
+ | ----- ^ this named argument is referred to by position in formatting string
| |
| this formatting argument uses named argument `f` by position
|
@@ -16,7 +16,7 @@ warning: named argument `f` is not used by name
--> $DIR/issue-99907.rs:9:31
|
LL | println!("Hello {:1.1}!", f = 0.02f32);
- | -- ^ this named argument is referred to by position in formatting string
+ | ------ ^ this named argument is referred to by position in formatting string
| |
| this formatting argument uses named argument `f` by position
|
diff --git a/src/test/ui/macros/lint-trailing-macro-call.stderr b/src/test/ui/macros/lint-trailing-macro-call.stderr
index a98a559c8..6ab121f7c 100644
--- a/src/test/ui/macros/lint-trailing-macro-call.stderr
+++ b/src/test/ui/macros/lint-trailing-macro-call.stderr
@@ -7,11 +7,11 @@ LL | #[cfg(FALSE)] 25;
LL | expand_it!()
| ------------ in this macro invocation
|
- = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
= note: macro invocations at the end of a block are treated as expressions
= note: to ignore the value produced by the macro, add a semicolon after the invocation of `expand_it`
+ = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
= note: this warning originates in the macro `expand_it` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted
diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs
index dfd58b25d..8406b4e78 100644
--- a/src/test/ui/macros/macro-comma-behavior-rpass.rs
+++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs
@@ -14,7 +14,6 @@
// compile-flags: --test -C debug_assertions=yes
// revisions: std core
-// ignore-wasm32-bare compiled with panic=abort by default
#![cfg_attr(core, no_std)]
#[cfg(core)]
diff --git a/src/test/ui/macros/macro-context.stderr b/src/test/ui/macros/macro-context.stderr
index 5dc178070..f597c398b 100644
--- a/src/test/ui/macros/macro-context.stderr
+++ b/src/test/ui/macros/macro-context.stderr
@@ -57,7 +57,7 @@ error[E0425]: cannot find value `i` in this scope
--> $DIR/macro-context.rs:3:13
|
LL | () => ( i ; typeof );
- | ^ help: a local variable with a similar name exists: `a`
+ | ^ not found in this scope
...
LL | let i = m!();
| ---- in this macro invocation
@@ -73,9 +73,9 @@ LL | () => ( i ; typeof );
LL | let i = m!();
| ---- in this macro invocation
|
- = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
+ = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 6 previous errors; 1 warning emitted
diff --git a/src/test/ui/macros/macro-in-expression-context.stderr b/src/test/ui/macros/macro-in-expression-context.stderr
index 1840babd6..1023189ea 100644
--- a/src/test/ui/macros/macro-in-expression-context.stderr
+++ b/src/test/ui/macros/macro-in-expression-context.stderr
@@ -20,11 +20,11 @@ LL | assert_eq!("A", "A");
LL | foo!()
| ------ in this macro invocation
|
- = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
= note: macro invocations at the end of a block are treated as expressions
= note: to ignore the value produced by the macro, add a semicolon after the invocation of `foo`
+ = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error; 1 warning emitted
diff --git a/src/test/ui/macros/macro-match-nonterminal.stderr b/src/test/ui/macros/macro-match-nonterminal.stderr
index 48b9bc6ff..ef7261c02 100644
--- a/src/test/ui/macros/macro-match-nonterminal.stderr
+++ b/src/test/ui/macros/macro-match-nonterminal.stderr
@@ -10,9 +10,9 @@ error: missing fragment specifier
LL | ($a, $b) => {
| ^
|
- = note: `#[deny(missing_fragment_specifier)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
+ = note: `#[deny(missing_fragment_specifier)]` on by default
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:10
diff --git a/src/test/ui/macros/macro-missing-fragment-deduplication.stderr b/src/test/ui/macros/macro-missing-fragment-deduplication.stderr
index 7622ca054..3b9e716e1 100644
--- a/src/test/ui/macros/macro-missing-fragment-deduplication.stderr
+++ b/src/test/ui/macros/macro-missing-fragment-deduplication.stderr
@@ -10,9 +10,9 @@ error: missing fragment specifier
LL | ($name) => {}
| ^^^^^
|
- = note: `#[deny(missing_fragment_specifier)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
+ = note: `#[deny(missing_fragment_specifier)]` on by default
error: aborting due to 2 previous errors
diff --git a/src/test/ui/macros/macro-missing-fragment.stderr b/src/test/ui/macros/macro-missing-fragment.stderr
index 1bf6f04ec..2aa1e58f6 100644
--- a/src/test/ui/macros/macro-missing-fragment.stderr
+++ b/src/test/ui/macros/macro-missing-fragment.stderr
@@ -10,13 +10,13 @@ warning: missing fragment specifier
LL | ( $( any_token $field_rust_type )* ) => {};
| ^^^^^^^^^^^^^^^^
|
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/macro-missing-fragment.rs:1:9
|
LL | #![warn(missing_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
warning: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:12:7
diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.stderr b/src/test/ui/macros/macro-or-patterns-back-compat.stderr
index 9a5b8009f..e04dfefa4 100644
--- a/src/test/ui/macros/macro-or-patterns-back-compat.stderr
+++ b/src/test/ui/macros/macro-or-patterns-back-compat.stderr
@@ -4,13 +4,13 @@ error: the meaning of the `pat` fragment specifier is changing in Rust 2021, whi
LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
| ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
|
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/or-patterns-macro-rules.html>
note: the lint level is defined here
--> $DIR/macro-or-patterns-back-compat.rs:4:9
|
LL | #![deny(rust_2021_incompatible_or_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/or-patterns-macro-rules.html>
error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
--> $DIR/macro-or-patterns-back-compat.rs:13:23
diff --git a/src/test/ui/macros/macro-use-all-and-none.stderr b/src/test/ui/macros/macro-use-all-and-none.stderr
index 6de7ffb2f..00b10dccd 100644
--- a/src/test/ui/macros/macro-use-all-and-none.stderr
+++ b/src/test/ui/macros/macro-use-all-and-none.stderr
@@ -4,12 +4,12 @@ warning: unused attribute
LL | #[macro_use()]
| ^^^^^^^^^^^^^^ help: remove this attribute
|
+ = note: attribute `macro_use` with an empty list has no effect
note: the lint level is defined here
--> $DIR/macro-use-all-and-none.rs:4:9
|
LL | #![warn(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
- = note: attribute `macro_use` with an empty list has no effect
warning: 1 warning emitted
diff --git a/src/test/ui/macros/macro_rules-unmatchable-literals.rs b/src/test/ui/macros/macro_rules-unmatchable-literals.rs
new file mode 100644
index 000000000..bde0fe1a0
--- /dev/null
+++ b/src/test/ui/macros/macro_rules-unmatchable-literals.rs
@@ -0,0 +1,14 @@
+// Pinning tests for things that don't work to make sure we notice if that changes
+
+#![crate_type = "lib"]
+
+macro_rules! octal_with_bad_digit {
+ ( 0o1238 ) => {}; //~ ERROR invalid digit
+}
+
+macro_rules! binary_with_bad_digit {
+ ( 0b012 ) => {}; //~ ERROR invalid digit
+}
+
+// This can't happen for Hex and Decimal as things like `123A` and `0xFFG`
+// get treated as unknown *suffixes*, rather than digits.
diff --git a/src/test/ui/macros/macro_rules-unmatchable-literals.stderr b/src/test/ui/macros/macro_rules-unmatchable-literals.stderr
new file mode 100644
index 000000000..956a66979
--- /dev/null
+++ b/src/test/ui/macros/macro_rules-unmatchable-literals.stderr
@@ -0,0 +1,14 @@
+error: invalid digit for a base 8 literal
+ --> $DIR/macro_rules-unmatchable-literals.rs:6:12
+ |
+LL | ( 0o1238 ) => {};
+ | ^
+
+error: invalid digit for a base 2 literal
+ --> $DIR/macro_rules-unmatchable-literals.rs:10:11
+ |
+LL | ( 0b012 ) => {};
+ | ^
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/macros/macros-nonfatal-errors.rs b/src/test/ui/macros/macros-nonfatal-errors.rs
index e7a01f105..ab14c3589 100644
--- a/src/test/ui/macros/macros-nonfatal-errors.rs
+++ b/src/test/ui/macros/macros-nonfatal-errors.rs
@@ -4,7 +4,7 @@
// immediately, so that we get more errors listed at a time.
#![feature(trace_macros, concat_idents)]
-#![feature(stmt_expr_attributes, arbitrary_enum_discriminant)]
+#![feature(stmt_expr_attributes)]
use std::arch::asm;
@@ -116,3 +116,24 @@ fn main() {
trace_macros!(invalid); //~ ERROR
}
+
+/// Check that `#[derive(Default)]` does use a `T : Default` bound when the
+/// `#[default]` variant is `#[non_exhaustive]` (should this end up allowed).
+const _: () = {
+ #[derive(Default)]
+ enum NonExhaustiveDefaultGeneric<T> {
+ #[default]
+ #[non_exhaustive]
+ Foo, //~ ERROR default variant must be exhaustive
+ Bar(T),
+ }
+
+ fn assert_impls_default<T: Default>() {}
+
+ enum NotDefault {}
+
+ // Note: the `derive(Default)` currently bails early enough for trait-checking
+ // not to happen. Should it bail late enough, or even pass, make sure to
+ // assert that the following line fails.
+ let _ = assert_impls_default::<NonExhaustiveDefaultGeneric<NotDefault>>;
+};
diff --git a/src/test/ui/macros/macros-nonfatal-errors.stderr b/src/test/ui/macros/macros-nonfatal-errors.stderr
index b3c6d07f9..d42f6c179 100644
--- a/src/test/ui/macros/macros-nonfatal-errors.stderr
+++ b/src/test/ui/macros/macros-nonfatal-errors.stderr
@@ -215,11 +215,21 @@ error: trace_macros! accepts only `true` or `false`
LL | trace_macros!(invalid);
| ^^^^^^^^^^^^^^^^^^^^^^
+error: default variant must be exhaustive
+ --> $DIR/macros-nonfatal-errors.rs:127:9
+ |
+LL | #[non_exhaustive]
+ | ----------------- declared `#[non_exhaustive]` here
+LL | Foo,
+ | ^^^
+ |
+ = help: consider a manual implementation of `Default`
+
error: cannot find macro `llvm_asm` in this scope
--> $DIR/macros-nonfatal-errors.rs:99:5
|
LL | llvm_asm!(invalid);
| ^^^^^^^^
-error: aborting due to 27 previous errors
+error: aborting due to 28 previous errors
diff --git a/src/test/ui/macros/must-use-in-macro-55516.stderr b/src/test/ui/macros/must-use-in-macro-55516.stderr
index b56b00cc7..8878b0eea 100644
--- a/src/test/ui/macros/must-use-in-macro-55516.stderr
+++ b/src/test/ui/macros/must-use-in-macro-55516.stderr
@@ -4,8 +4,8 @@ warning: unused `Result` that must be used
LL | write!(&mut example, "{}", 42);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: `-W unused-must-use` implied by `-W unused`
= note: this `Result` may be an `Err` variant, which should be handled
+ = note: `-W unused-must-use` implied by `-W unused`
= note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted
diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
index f538ec643..b8b6f0846 100644
--- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
+++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
@@ -2,6 +2,7 @@
// ignore-tidy-linelength
// only-x86_64
// run-pass
+// needs-unwind Asserting on contents of error message
#![allow(path_statements, unused_allocation)]
#![feature(box_syntax, core_intrinsics, generic_assert, generic_assert_internals)]
diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs
index 86697c58f..d46f396ee 100644
--- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs
+++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs
@@ -2,6 +2,7 @@
// ignore-tidy-linelength
// only-x86_64
// run-pass
+// needs-unwind Asserting on contents of error message
#![feature(core_intrinsics, generic_assert, generic_assert_internals)]
diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs
index 06c4993ec..1f5a29ab5 100644
--- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs
+++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs
@@ -1,6 +1,7 @@
// aux-build:common.rs
// only-x86_64
// run-pass
+// needs-unwind Asserting on contents of error message
#![feature(core_intrinsics, generic_assert, generic_assert_internals)]
diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr b/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr
index 0188938a3..a6cff95fd 100644
--- a/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr
+++ b/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr
@@ -319,11 +319,11 @@ LL | unknown_metavar!(a);
|
= note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0425]: cannot find function `count` in this scope
- --> $DIR/syntax-errors.rs:29:30
+error[E0425]: cannot find value `i` in this scope
+ --> $DIR/syntax-errors.rs:29:36
|
LL | ( $( $i:ident ),* ) => { count(i) };
- | ^^^^^ not found in this scope
+ | ^ not found in this scope
...
LL | no_curly__no_rhs_dollar__round!(a, b, c);
| ---------------------------------------- in this macro invocation
@@ -331,10 +331,27 @@ LL | no_curly__no_rhs_dollar__round!(a, b, c);
= note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0425]: cannot find value `i` in this scope
- --> $DIR/syntax-errors.rs:29:36
+ --> $DIR/syntax-errors.rs:35:29
+ |
+LL | ( $i:ident ) => { count(i) };
+ | ^ not found in this scope
+...
+LL | no_curly__no_rhs_dollar__no_round!(a);
+ | ------------------------------------- in this macro invocation
+ |
+ = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/syntax-errors.rs:153:37
+ |
+LL | no_curly__rhs_dollar__no_round!(a);
+ | ^ not found in this scope
+
+error[E0425]: cannot find function `count` in this scope
+ --> $DIR/syntax-errors.rs:29:30
|
LL | ( $( $i:ident ),* ) => { count(i) };
- | ^ not found in this scope
+ | ^^^^^ not found in this scope
...
LL | no_curly__no_rhs_dollar__round!(a, b, c);
| ---------------------------------------- in this macro invocation
@@ -352,17 +369,6 @@ LL | no_curly__no_rhs_dollar__no_round!(a);
|
= note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0425]: cannot find value `i` in this scope
- --> $DIR/syntax-errors.rs:35:29
- |
-LL | ( $i:ident ) => { count(i) };
- | ^ not found in this scope
-...
-LL | no_curly__no_rhs_dollar__no_round!(a);
- | ------------------------------------- in this macro invocation
- |
- = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error[E0425]: cannot find function `count` in this scope
--> $DIR/syntax-errors.rs:46:23
|
@@ -374,12 +380,6 @@ LL | no_curly__rhs_dollar__no_round!(a);
|
= note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0425]: cannot find value `a` in this scope
- --> $DIR/syntax-errors.rs:153:37
- |
-LL | no_curly__rhs_dollar__no_round!(a);
- | ^ not found in this scope
-
error: aborting due to 40 previous errors
For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/macros/stringify.rs b/src/test/ui/macros/stringify.rs
index dd159cb5b..bc0d44881 100644
--- a/src/test/ui/macros/stringify.rs
+++ b/src/test/ui/macros/stringify.rs
@@ -8,7 +8,6 @@
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(generators)]
-#![feature(half_open_range_patterns)]
#![feature(more_qualified_paths)]
#![feature(raw_ref_op)]
#![feature(trait_alias)]
diff --git a/src/test/ui/macros/syntax-error-recovery.rs b/src/test/ui/macros/syntax-error-recovery.rs
new file mode 100644
index 000000000..ae6de3c50
--- /dev/null
+++ b/src/test/ui/macros/syntax-error-recovery.rs
@@ -0,0 +1,18 @@
+macro_rules! values {
+ ($($token:ident($value:literal) $(as $inner:ty)? => $attr:meta,)*) => {
+ #[derive(Debug)]
+ pub enum TokenKind {
+ $(
+ #[$attr]
+ $token $($inner)? = $value,
+ )*
+ }
+ };
+}
+//~^^^^^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)`
+//~| ERROR macro expansion ignores token `(String)` and any following
+
+values!(STRING(1) as (String) => cfg(test),);
+//~^ ERROR expected one of `!` or `::`, found `<eof>`
+
+fn main() {}
diff --git a/src/test/ui/macros/syntax-error-recovery.stderr b/src/test/ui/macros/syntax-error-recovery.stderr
new file mode 100644
index 000000000..c153b3b91
--- /dev/null
+++ b/src/test/ui/macros/syntax-error-recovery.stderr
@@ -0,0 +1,30 @@
+error: expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)`
+ --> $DIR/syntax-error-recovery.rs:7:26
+ |
+LL | $token $($inner)? = $value,
+ | ^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}`
+...
+LL | values!(STRING(1) as (String) => cfg(test),);
+ | -------------------------------------------- in this macro invocation
+ |
+ = 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
+ --> $DIR/syntax-error-recovery.rs:7:26
+ |
+LL | $token $($inner)? = $value,
+ | ^^^^^^
+...
+LL | values!(STRING(1) as (String) => cfg(test),);
+ | -------------------------------------------- caused by the macro expansion here
+ |
+ = note: the usage of `values!` is likely invalid in item context
+
+error: expected one of `!` or `::`, found `<eof>`
+ --> $DIR/syntax-error-recovery.rs:15:9
+ |
+LL | values!(STRING(1) as (String) => cfg(test),);
+ | ^^^^^^ expected one of `!` or `::`
+
+error: aborting due to 3 previous errors
+