Skip to content

Support clippy::panic for const contexts #15564

@YohDeadfall

Description

@YohDeadfall

Summary

Constant functions in Rust doesn't mean that they are always interpreted during compile time. It just applies some restrictions to make compile time execution possible.

It seems that it was made 3 years ago according to blame of:

https://github.com/rust-lang/rust-clippy/blame/c4acbce75735f98870a9f6cc818c62471876cc29/clippy_lints/src/panic_unimplemented.rs#L102

Lint Name

cargo::clippy

Reproducer

I tried this code:

#[expect(clippy::panic)]
const fn main() {
    panic!("don't")
}

I expected to see no errors emitted.

Instead, this happened:

    Checking playground v0.0.1 (/playground)
warning: this lint expectation is unfulfilled
 --> src/main.rs:1:10
  |
1 | #[expect(clippy::panic)]
  |          ^^^^^^^^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: `playground` (bin "playground") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.48s

Version

rustc 1.91.0-nightly (6ba0ce409 2025-08-21)
binary: rustc
commit-hash: 6ba0ce40941eee1ca02e9ba49c791ada5158747a
commit-date: 2025-08-21
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions