Skip to content

Rust 2021 (seemingly) mistakenly warns 'panic message contains braces' #87621

Closed
@mocsy

Description

@mocsy

Later versions of rust mistake macros like https://crates.io/crates/contracts requires as a panic message.

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=babeae07316ceb37dd7291ff889e9ea3

<code>

The current output is:

warning: panic message contains braces
  --> src/main.rs:4:16
   |
4 |     #[requires(key.starts_with('{'))]
   |                ^^^
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this message is not used as a format string, but will be in Rust 2021
help: add a "{}" format string to use the message literally
   |
4 |     #[requires("{}", key.starts_with('{'))]
   |                ^^^^^

Ideally the output should look like:
Nothing, it's not a panic message, it's an expression.

<proposed output>

Metadata

Metadata

Assignees

Labels

A-edition-2021Area: The 2021 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-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