diff options
| author | bors <bors@rust-lang.org> | 2024-01-14 04:37:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-14 04:37:45 +0000 |
| commit | aa5f781bd42340fe4f2eb4d68d2984454f600b78 (patch) | |
| tree | 6166eaf013996c8d153a24edb0e347de16e7d26a /tests/ui/parser | |
| parent | 3deb9bbf84f6431ebcbb7cbdbe3d89bc2636bc1b (diff) | |
| parent | aa8ecd0652afbecd6549d2f6e53c0a5f6aa76d8f (diff) | |
| download | rust-aa5f781bd42340fe4f2eb4d68d2984454f600b78.tar.gz rust-aa5f781bd42340fe4f2eb4d68d2984454f600b78.zip | |
Auto merge of #119341 - sjwang05:issue-58462, r=WaffleLapkin
Suggest quoting unquoted idents in attrs Closes #58462
Diffstat (limited to 'tests/ui/parser')
| -rw-r--r-- | tests/ui/parser/attribute/attr-unquoted-ident.fixed | 15 | ||||
| -rw-r--r-- | tests/ui/parser/attribute/attr-unquoted-ident.rs | 15 | ||||
| -rw-r--r-- | tests/ui/parser/attribute/attr-unquoted-ident.stderr | 24 |
3 files changed, 54 insertions, 0 deletions
diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.fixed b/tests/ui/parser/attribute/attr-unquoted-ident.fixed new file mode 100644 index 00000000000..6cdf22f7ec0 --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.fixed @@ -0,0 +1,15 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes +// run-rustfix + +fn main() { + #[cfg(key="foo")] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); + #[cfg(key="bar")] + println!(); + #[cfg(key="foo bar baz")] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); +} diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.rs b/tests/ui/parser/attribute/attr-unquoted-ident.rs new file mode 100644 index 00000000000..75af015c9fe --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.rs @@ -0,0 +1,15 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes +// run-rustfix + +fn main() { + #[cfg(key=foo)] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); + #[cfg(key="bar")] + println!(); + #[cfg(key=foo bar baz)] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); +} diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.stderr b/tests/ui/parser/attribute/attr-unquoted-ident.stderr new file mode 100644 index 00000000000..bc028f39be6 --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.stderr @@ -0,0 +1,24 @@ +error: expected unsuffixed literal, found `foo` + --> $DIR/attr-unquoted-ident.rs:5:15 + | +LL | #[cfg(key=foo)] + | ^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[cfg(key="foo")] + | + + + +error: expected unsuffixed literal, found `foo` + --> $DIR/attr-unquoted-ident.rs:11:15 + | +LL | #[cfg(key=foo bar baz)] + | ^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[cfg(key="foo bar baz")] + | + + + +error: aborting due to 2 previous errors + |
