Skip to content

"malformed attribute" for should_panic missing closing quotes #100563

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
ChayimFriedman2 opened this issue Aug 15, 2022 · 1 comment · Fixed by #100567
Closed

"malformed attribute" for should_panic missing closing quotes #100563

ChayimFriedman2 opened this issue Aug 15, 2022 · 1 comment · Fixed by #100567
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Aug 15, 2022

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f5f8842e55751ce384c7d40390bde7e1

#[should_panic = 1]
fn test() {}

The current output is:

error: malformed `should_panic` attribute input
 --> src/lib.rs:1:1
  |
1 | #[should_panic = 1]
  | ^^^^^^^^^^^^^^^^^^^
  |
help: the following are the possible correct uses
  |
1 | #[should_panic = "reason"]
  |
1 | #[should_panic(expected = "reason)]
  |
1 | #[should_panic]
  |

Note that in #[should_panic(expected = "reason)] we miss the closing quotes.

This is because the attribute template is missing it:

ungated!(
should_panic, Normal,
template!(Word, List: r#"expected = "reason"#, NameValueStr: "reason"), FutureWarnFollowing,
),

Fixing that should be simple as introducing it there.

@ChayimFriedman2 ChayimFriedman2 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 15, 2022
@Rageking8
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 16, 2022
@bors bors closed this as completed in ba2c2a6 Aug 16, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants