Skip to content

non_fmt_panic warning on Rust 2015  #85674

@pravic

Description

@pravic
Contributor

I tried this code:

[package]
# ...
edition = "2015"
let message = "message";
panic!(message);

I expected to see this happen: No warnings when compiling Rust 2015.

Instead, this happened:

   |
25 |             panic!(message);
   |                    ^^^^^^^
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
25 |             panic!("{}", message);
   |                    ^^^^^
help: or use std::panic::panic_any instead
   |
25 |             std::panic::panic_any(message);
   |             ^^^^^^^^^^^^^^^^^^^^^

warning: 1 warning emitted

Meta

rustc --version --verbose:

rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: x86_64-pc-windows-msvc
release: 1.52.1
LLVM version: 12.0.0

cc #80162. #81645

Activity

jonas-schievink

jonas-schievink commented on May 25, 2021

@jonas-schievink
Contributor

This behavior matches the plan outlined in RFC 3007. Why do you think the the lint should not warn here?

pravic

pravic commented on May 25, 2021

@pravic
ContributorAuthor

Because we explicitly set the 2015 edition and won't be switching to a higher one. Why would our code break with a future compiler update?

JohnTitor

JohnTitor commented on Jun 15, 2021

@JohnTitor
Member

We don't have a way to know whether the users consider switching the edition or not. This warning is for users considering it and if you don't, you can simply ignore/suppress it. I'm going to close as it works as intended, thanks for reporting anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @pravic@jonas-schievink@JohnTitor

        Issue actions

          non_fmt_panic warning on Rust 2015 · Issue #85674 · rust-lang/rust