Closed
Description
I tried this code: playground link
const fn is_nonzero(x: u8) -> bool {
x != 0
}
const _: () = {
assert!(is_nonzero(2));
};
I expected to compile without any warnings.
Instead, it indicates that is_nonzero
is dead code:
warning: function `is_nonzero` is never used
--> src/lib.rs:1:10
|
1 | const fn is_nonzero(x: u8) -> bool {
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (5d707b07e 2025-06-02)
binary: rustc
commit-hash: 5d707b07e42766c080c5012869c9988a18dcbb83
commit-date: 2025-06-02
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5