-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-dead_codeLint: dead_codeLint: dead_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-dead_codeLint: dead_codeLint: dead_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.