rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
10.97k stars 1.47k forks source link

`missing_panics_doc` shouldn't be triggered in constant environments #12760

Closed c410-f3r closed 3 weeks ago

c410-f3r commented 1 month ago

IFAICT, documentation around panic! is about runtime behavior. rustc will automatically point to the panic message at compile-time when working with constants.

#![deny(clippy::missing_panics_doc)]

pub fn foo<const N: usize>() {
    const {
        if N == 0 {
            panic!();
        }
    }
}

pub fn main() {
    foo::<0>();
}