-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix parse error message for meta items #124778
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
macro_rules! mac { | ||
($attr_item: meta) => { | ||
#[cfg($attr_item)] | ||
//~^ ERROR expected unsuffixed literal or identifier, found `an(arbitrary token stream)` | ||
//~| ERROR expected unsuffixed literal or identifier, found `an(arbitrary token stream)` | ||
//~^ ERROR expected unsuffixed literal, found `an(arbitrary token stream)` | ||
//~| ERROR expected unsuffixed literal, found `an(arbitrary token stream)` | ||
struct S; | ||
} | ||
} | ||
|
||
mac!(an(arbitrary token stream)); | ||
|
||
#[cfg(feature = -1)] | ||
//~^ ERROR expected unsuffixed literal, found `-` | ||
//~| ERROR expected unsuffixed literal, found `-` | ||
fn handler() {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
//@ compile-flags: -Zdeduplicate-diagnostics=yes | ||
//@ run-rustfix | ||
|
||
#![allow(unexpected_cfgs)] | ||
|
||
fn main() { | ||
#[cfg(key=foo)] | ||
//~^ ERROR expected unsuffixed literal, found `foo` | ||
//~| HELP surround the identifier with quotation marks to parse it as a string | ||
//~| 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` | ||
//~| HELP surround the identifier with quotation marks to parse it as a string | ||
//~| HELP surround the identifier with quotation marks to make it into a string literal | ||
println!(); | ||
} | ||
|
||
// Don't suggest surrounding `$name` or `nickname` with quotes: | ||
|
||
macro_rules! make { | ||
($name:ident) => { #[doc(alias = $name)] pub struct S; } | ||
//~^ ERROR expected unsuffixed literal, found `nickname` | ||
} | ||
|
||
make!(nickname); //~ NOTE in this expansion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,35 @@ | ||
error: expected unsuffixed literal, found `foo` | ||
--> $DIR/attr-unquoted-ident.rs:7:15 | ||
--> $DIR/attr-unquoted-ident.rs:6:15 | ||
| | ||
LL | #[cfg(key=foo)] | ||
| ^^^ | ||
| | ||
help: surround the identifier with quotation marks to parse it as a string | ||
help: surround the identifier with quotation marks to make it into a string literal | ||
| | ||
LL | #[cfg(key="foo")] | ||
| + + | ||
|
||
error: expected unsuffixed literal, found `foo` | ||
--> $DIR/attr-unquoted-ident.rs:13:15 | ||
--> $DIR/attr-unquoted-ident.rs:12:15 | ||
| | ||
LL | #[cfg(key=foo bar baz)] | ||
| ^^^ | ||
| | ||
help: surround the identifier with quotation marks to parse it as a string | ||
help: surround the identifier with quotation marks to make it into a string literal | ||
| | ||
LL | #[cfg(key="foo bar baz")] | ||
| + + | ||
|
||
error: aborting due to 2 previous errors | ||
error: expected unsuffixed literal, found `nickname` | ||
--> $DIR/attr-unquoted-ident.rs:21:38 | ||
| | ||
LL | ($name:ident) => { #[doc(alias = $name)] pub struct S; } | ||
| ^^^^^ | ||
... | ||
LL | make!(nickname); | ||
| --------------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `make` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 3 previous errors | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the rustfix directive since I've added a negative test case and didn't want to add revisions (do they work in combination with rustfix?) or a separate test file.