Updated uitests for new parser

This commit is contained in:
Jonathan Brouwer 2025-07-31 15:38:44 +02:00
parent 17e34f6b24
commit ec5b2cce8e
No known key found for this signature in database
GPG key ID: F13E55D38C971DEF
25 changed files with 193 additions and 151 deletions

View file

@ -94,7 +94,6 @@ check!(reg_f32, f32, freg, "mov.s");
// CHECK: #APP
// CHECK: mov.s $f0, $f0
// CHECK: #NO_APP
#[no_mangle]
check_reg!(f0_f32, f32, "$f0", "mov.s");
// CHECK-LABEL: reg_f32_64:
@ -107,21 +106,18 @@ check!(reg_f32_64, f32, freg, "mov.d");
// CHECK: #APP
// CHECK: mov.d $f0, $f0
// CHECK: #NO_APP
#[no_mangle]
check_reg!(f0_f32_64, f32, "$f0", "mov.d");
// CHECK-LABEL: reg_f64:
// CHECK: #APP
// CHECK: mov.d $f{{[0-9]+}}, $f{{[0-9]+}}
// CHECK: #NO_APP
#[no_mangle]
check!(reg_f64, f64, freg, "mov.d");
// CHECK-LABEL: f0_f64:
// CHECK: #APP
// CHECK: mov.d $f0, $f0
// CHECK: #NO_APP
#[no_mangle]
check_reg!(f0_f64, f64, "$f0", "mov.d");
// CHECK-LABEL: reg_ptr:

View file

@ -1,9 +1,3 @@
error: attribute value must be a literal
--> $DIR/key-value-expansion.rs:21:6
|
LL | bug!((column!()));
| ^^^^^^^^^^^
error: attribute value must be a literal
--> $DIR/key-value-expansion.rs:27:14
|
@ -26,5 +20,11 @@ LL | some_macro!(u8);
|
= note: this error originates in the macro `some_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
error: attribute value must be a literal
--> $DIR/key-value-expansion.rs:21:6
|
LL | bug!((column!()));
| ^^^^^^^^^^^
error: aborting due to 3 previous errors

View file

@ -26,7 +26,7 @@ fn f3() {}
#[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on functions
fn f4() {}
#[rustc_align(-1)] //~ ERROR expected unsuffixed literal, found `-`
#[rustc_align(-1)] //~ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
fn f5() {}
#[rustc_align(3)] //~ ERROR invalid alignment value: not a power of two

View file

@ -1,17 +1,3 @@
error: expected unsuffixed literal, found `-`
--> $DIR/malformed-fn-align.rs:29:15
|
LL | #[rustc_align(-1)]
| ^
error: suffixed literals are not allowed in attributes
--> $DIR/malformed-fn-align.rs:35:15
|
LL | #[rustc_align(4usize)]
| ^^^^^^
|
= help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
error[E0539]: malformed `rustc_align` attribute input
--> $DIR/malformed-fn-align.rs:10:5
|
@ -51,12 +37,32 @@ error[E0589]: invalid alignment value: not a power of two
LL | #[rustc_align(0)]
| ^
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
--> $DIR/malformed-fn-align.rs:29:15
|
LL | #[rustc_align(-1)]
| ^
|
help: negative numbers are not literals, try removing the `-` sign
|
LL - #[rustc_align(-1)]
LL + #[rustc_align(1)]
|
error[E0589]: invalid alignment value: not a power of two
--> $DIR/malformed-fn-align.rs:32:15
|
LL | #[rustc_align(3)]
| ^
error: suffixed literals are not allowed in attributes
--> $DIR/malformed-fn-align.rs:35:15
|
LL | #[rustc_align(4usize)]
| ^^^^^^
|
= help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
error[E0589]: invalid alignment value: not an unsuffixed integer
--> $DIR/malformed-fn-align.rs:35:15
|

View file

@ -5,7 +5,7 @@
macro_rules! pass_nonterminal {
($n:expr) => {
#[repr(align($n))]
//~^ ERROR expected unsuffixed literal, found `expr` metavariable
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable
struct S;
};
}
@ -15,6 +15,5 @@ macro_rules! n {
}
pass_nonterminal!(n!());
//~^ ERROR incorrect `repr(align)` attribute format: `align` expects a literal integer as argument [E0693]
fn main() {}

View file

@ -1,4 +1,4 @@
error: expected unsuffixed literal, found `expr` metavariable
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable
--> $DIR/nonterminal-expansion.rs:7:22
|
LL | #[repr(align($n))]
@ -9,12 +9,5 @@ LL | pass_nonterminal!(n!());
|
= note: this error originates in the macro `pass_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0693]: incorrect `repr(align)` attribute format: `align` expects a literal integer as argument
--> $DIR/nonterminal-expansion.rs:17:19
|
LL | pass_nonterminal!(n!());
| ^
error: aborting due to 1 previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0693`.

View file

@ -28,17 +28,6 @@ LL | #[unsafe(proc_macro_derive(Foo))]
|
= note: extraneous unsafe is not allowed in attributes
error: expected identifier, found keyword `unsafe`
--> $DIR/proc-unsafe-attributes.rs:12:21
|
LL | #[proc_macro_derive(unsafe(Foo))]
| ^^^^^^ expected identifier, found keyword
|
help: escape `unsafe` to use it as an identifier
|
LL | #[proc_macro_derive(r#unsafe(Foo))]
| ++
error: `proc_macro_attribute` is not an unsafe attribute
--> $DIR/proc-unsafe-attributes.rs:18:3
|
@ -114,6 +103,17 @@ LL | #[unsafe(allow(unsafe(dead_code)))]
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: expected identifier, found keyword `unsafe`
--> $DIR/proc-unsafe-attributes.rs:12:21
|
LL | #[proc_macro_derive(unsafe(Foo))]
| ^^^^^^ expected identifier, found keyword
|
help: escape `unsafe` to use it as an identifier
|
LL | #[proc_macro_derive(r#unsafe(Foo))]
| ++
error[E0565]: malformed `proc_macro_derive` attribute input
--> $DIR/proc-unsafe-attributes.rs:12:1
|

View file

@ -43,7 +43,7 @@ struct S9;
macro_rules! generate_s10 {
($expr: expr) => {
#[cfg(feature = $expr)]
//~^ ERROR expected unsuffixed literal, found `expr` metavariable
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable
struct S10;
}
}

View file

@ -81,7 +81,7 @@ LL | #[cfg(a = b"hi")]
|
= note: expected a normal string literal, not a byte string literal
error: expected unsuffixed literal, found `expr` metavariable
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable
--> $DIR/cfg-attr-syntax-validation.rs:45:25
|
LL | #[cfg(feature = $expr)]

View file

@ -1,15 +1,3 @@
error: expected identifier, found `,`
--> $DIR/bad-syntax.rs:44:12
|
LL | #[coverage(,off)]
| ^ expected identifier
|
help: remove this comma
|
LL - #[coverage(,off)]
LL + #[coverage(off)]
|
error: multiple `coverage` attributes
--> $DIR/bad-syntax.rs:9:1
|
@ -162,6 +150,18 @@ LL - #[coverage(off, bogus)]
LL + #[coverage(on)]
|
error: expected identifier, found `,`
--> $DIR/bad-syntax.rs:44:12
|
LL | #[coverage(,off)]
| ^ expected identifier
|
help: remove this comma
|
LL - #[coverage(,off)]
LL + #[coverage(off)]
|
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0539, E0805.

View file

@ -3,9 +3,9 @@
// was a well-formed `MetaItem`.
fn main() {
foo() //~ WARNING use of deprecated function `foo`
foo()
}
#[deprecated(note = test)]
//~^ ERROR expected unsuffixed literal, found `test`
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `test`
fn foo() {}

View file

@ -1,4 +1,4 @@
error: expected unsuffixed literal, found `test`
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `test`
--> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:9:21
|
LL | #[deprecated(note = test)]
@ -9,13 +9,5 @@ help: surround the identifier with quotation marks to make it into a string lite
LL | #[deprecated(note = "test")]
| + +
warning: use of deprecated function `foo`
--> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:6:5
|
LL | foo()
| ^^^
|
= note: `#[warn(deprecated)]` on by default
error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

View file

@ -4,7 +4,9 @@ macro_rules! bar (
macro_rules! foo (
() => (
#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
#[allow_internal_unstable()]
//~^ ERROR allow_internal_unstable side-steps
//~| ERROR `#[allow_internal_unstable]` attribute cannot be used on macro calls
bar!();
);
);

View file

@ -1,8 +1,8 @@
error[E0658]: allow_internal_unstable side-steps feature gating and stability checks
--> $DIR/issue-32782.rs:7:9
|
LL | #[allow_internal_unstable]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[allow_internal_unstable()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | foo!();
| ------ in this macro invocation
@ -11,6 +11,18 @@ LL | foo!();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
error: `#[allow_internal_unstable]` attribute cannot be used on macro calls
--> $DIR/issue-32782.rs:7:9
|
LL | #[allow_internal_unstable()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | foo!();
| ------ in this macro invocation
|
= help: `#[allow_internal_unstable]` can be applied to macro defs and functions
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,5 +1,6 @@
//@ check-pass
#![feature(rustc_attrs)]
#![warn(unused)]
macro_rules! foo {
@ -7,16 +8,16 @@ macro_rules! foo {
}
fn main() {
#[inline] foo!(); //~ WARN unused attribute `inline`
#[rustc_dummy] foo!(); //~ WARN unused attribute `rustc_dummy`
// This does nothing, since `#[allow(warnings)]` is itself
// an inert attribute on a macro call
#[allow(warnings)] #[inline] foo!(); //~ WARN unused attribute `allow`
//~^ WARN unused attribute `inline`
#[allow(warnings)] #[rustc_dummy] foo!(); //~ WARN unused attribute `allow`
//~^ WARN unused attribute `rustc_dummy`
// This does work, since the attribute is on a parent
// of the macro invocation.
#[allow(warnings)] { #[inline] foo!(); }
#[allow(warnings)] { #[rustc_dummy] foo!(); }
// Ok, `cfg` and `cfg_attr` are expanded eagerly and do not warn.
#[cfg(true)] foo!();

View file

@ -1,44 +1,44 @@
warning: unused attribute `inline`
--> $DIR/inert-attr-macro.rs:10:5
warning: unused attribute `rustc_dummy`
--> $DIR/inert-attr-macro.rs:11:5
|
LL | #[inline] foo!();
| ^^^^^^^^^
LL | #[rustc_dummy] foo!();
| ^^^^^^^^^^^^^^
|
note: the built-in attribute `inline` will be ignored, since it's applied to the macro invocation `foo`
--> $DIR/inert-attr-macro.rs:10:15
note: the built-in attribute `rustc_dummy` will be ignored, since it's applied to the macro invocation `foo`
--> $DIR/inert-attr-macro.rs:11:20
|
LL | #[inline] foo!();
| ^^^
LL | #[rustc_dummy] foo!();
| ^^^
note: the lint level is defined here
--> $DIR/inert-attr-macro.rs:3:9
--> $DIR/inert-attr-macro.rs:4:9
|
LL | #![warn(unused)]
| ^^^^^^
= note: `#[warn(unused_attributes)]` implied by `#[warn(unused)]`
warning: unused attribute `allow`
--> $DIR/inert-attr-macro.rs:14:5
--> $DIR/inert-attr-macro.rs:15:5
|
LL | #[allow(warnings)] #[inline] foo!();
LL | #[allow(warnings)] #[rustc_dummy] foo!();
| ^^^^^^^^^^^^^^^^^^
|
note: the built-in attribute `allow` will be ignored, since it's applied to the macro invocation `foo`
--> $DIR/inert-attr-macro.rs:14:34
--> $DIR/inert-attr-macro.rs:15:39
|
LL | #[allow(warnings)] #[inline] foo!();
| ^^^
LL | #[allow(warnings)] #[rustc_dummy] foo!();
| ^^^
warning: unused attribute `inline`
--> $DIR/inert-attr-macro.rs:14:24
warning: unused attribute `rustc_dummy`
--> $DIR/inert-attr-macro.rs:15:24
|
LL | #[allow(warnings)] #[inline] foo!();
| ^^^^^^^^^
LL | #[allow(warnings)] #[rustc_dummy] foo!();
| ^^^^^^^^^^^^^^
|
note: the built-in attribute `inline` will be ignored, since it's applied to the macro invocation `foo`
--> $DIR/inert-attr-macro.rs:14:34
note: the built-in attribute `rustc_dummy` will be ignored, since it's applied to the macro invocation `foo`
--> $DIR/inert-attr-macro.rs:15:39
|
LL | #[allow(warnings)] #[inline] foo!();
| ^^^
LL | #[allow(warnings)] #[rustc_dummy] foo!();
| ^^^
warning: 3 warnings emitted

View file

@ -1,7 +1,7 @@
macro_rules! mac {
($attr_item: meta) => {
#[cfg($attr_item)]
//~^ ERROR expected unsuffixed literal, found `meta` metavariable
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable
struct S;
}
}
@ -9,7 +9,7 @@ macro_rules! mac {
mac!(an(arbitrary token stream));
#[cfg(feature = -1)]
//~^ ERROR expected unsuffixed literal, found `-`
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
fn handler() {}
fn main() {}

View file

@ -1,10 +1,16 @@
error: expected unsuffixed literal, found `-`
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
--> $DIR/attr-bad-meta-4.rs:11:17
|
LL | #[cfg(feature = -1)]
| ^
|
help: negative numbers are not literals, try removing the `-` sign
|
LL - #[cfg(feature = -1)]
LL + #[cfg(feature = 1)]
|
error: expected unsuffixed literal, found `meta` metavariable
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable
--> $DIR/attr-bad-meta-4.rs:3:15
|
LL | #[cfg($attr_item)]

View file

@ -0,0 +1,17 @@
#[cfg(target-os = "windows")]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
pub fn test1() { }
#[cfg(target_os = %)]
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `%`
pub fn test2() { }
#[cfg(target_os?)]
//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `?`
pub fn test3() { }
#[cfg[target_os]]
//~^ ERROR wrong meta list delimiters
pub fn test4() { }
pub fn main() {}

View file

@ -0,0 +1,32 @@
error: expected one of `(`, `,`, `::`, or `=`, found `-`
--> $DIR/attr-incomplete.rs:1:13
|
LL | #[cfg(target-os = "windows")]
| ^ expected one of `(`, `,`, `::`, or `=`
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `%`
--> $DIR/attr-incomplete.rs:5:19
|
LL | #[cfg(target_os = %)]
| ^
error: expected one of `(`, `,`, `::`, or `=`, found `?`
--> $DIR/attr-incomplete.rs:9:16
|
LL | #[cfg(target_os?)]
| ^ expected one of `(`, `,`, `::`, or `=`
error: wrong meta list delimiters
--> $DIR/attr-incomplete.rs:13:6
|
LL | #[cfg[target_os]]
| ^^^^^^^^^^^
|
help: the delimiters should be `(` and `)`
|
LL - #[cfg[target_os]]
LL + #[cfg(target_os)]
|
error: aborting due to 4 previous errors

View file

@ -4,13 +4,13 @@
fn main() {
#[cfg(key=foo)]
//~^ ERROR expected unsuffixed literal, found `foo`
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
//~| HELP surround the identifier with quotation marks to make it into a string literal
println!();
#[cfg(key="bar")]
println!();
#[cfg(key=foo bar baz)]
//~^ ERROR expected unsuffixed literal, found `foo`
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
//~| HELP surround the identifier with quotation marks to make it into a string literal
println!();
}

View file

@ -1,4 +1,4 @@
error: expected unsuffixed literal, found `foo`
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
--> $DIR/attr-unquoted-ident.rs:6:15
|
LL | #[cfg(key=foo)]
@ -9,7 +9,7 @@ help: surround the identifier with quotation marks to make it into a string lite
LL | #[cfg(key="foo")]
| + +
error: expected unsuffixed literal, found `foo`
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
--> $DIR/attr-unquoted-ident.rs:12:15
|
LL | #[cfg(key=foo bar baz)]

View file

@ -10,32 +10,12 @@ error: suffixes on string literals are invalid
LL | "C"suffix
| ^^^^^^^^^ invalid suffix `suffix`
error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:30:17
|
LL | #[rustc_dummy = "string"suffix]
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:34:14
|
LL | #[must_use = "string"suffix]
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:39:15
|
LL | #[link(name = "string"suffix)]
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
error: invalid suffix `suffix` for number literal
--> $DIR/bad-lit-suffixes.rs:43:41
|
LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
| ^^^^^^^ invalid suffix `suffix`
|
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
warning: `extern` declarations without an explicit ABI are deprecated
--> $DIR/bad-lit-suffixes.rs:3:1
|
@ -150,6 +130,18 @@ LL | 1.0e10suffix;
|
= help: valid suffixes are `f32` and `f64`
error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:30:17
|
LL | #[rustc_dummy = "string"suffix]
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:34:14
|
LL | #[must_use = "string"suffix]
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
error[E0539]: malformed `must_use` attribute input
--> $DIR/bad-lit-suffixes.rs:34:1
|
@ -168,16 +160,23 @@ LL - #[must_use = "string"suffix]
LL + #[must_use]
|
error[E0805]: malformed `rustc_layout_scalar_valid_range_start` attribute input
error: invalid suffix `suffix` for number literal
--> $DIR/bad-lit-suffixes.rs:43:41
|
LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
| ^^^^^^^ invalid suffix `suffix`
|
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
--> $DIR/bad-lit-suffixes.rs:43:1
|
LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^
| | |
| | expected a single argument here
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^
| | |
| | expected an integer literal here
| help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
error: aborting due to 22 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0539, E0805.
For more information about an error, try `rustc --explain E0539`.
For more information about this error, try `rustc --explain E0539`.

View file

@ -5,6 +5,5 @@ fn main() {
const {
#![path = foo!()]
//~^ ERROR: cannot find macro `foo` in this scope
//~| ERROR malformed `path` attribute input
}
}

View file

@ -4,17 +4,5 @@ error: cannot find macro `foo` in this scope
LL | #![path = foo!()]
| ^^^
error[E0539]: malformed `path` attribute input
--> $DIR/path-attr-in-const-block.rs:6:9
|
LL | #![path = foo!()]
| ^^^^^^^^^^------^
| | |
| | expected a string literal here
| help: must be of the form: `#![path = "file"]`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute>
error: aborting due to 1 previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0539`.