Skip to content

"malformed attribute" for should_panic missing closing quotes #100563

Closed
@ChayimFriedman2

Description

@ChayimFriedman2

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.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions