Code
// Marked as dead code despite being used as main
fn different_main() {
println!("Hello from different_main");
}
use different_main as main;
Current output
warning: function `different_main` is never used
--> src/main.rs:2:4
|
2 | fn different_main() {
| ^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
Desired output
Rationale and extra context
I am not sure exactly why, but the warning shows up when checking via cargo check --all-targets and not with cargo check.
Other cases
Rust Version
rustc 1.96.0 (ac68faa20 2026-05-25)
binary: rustc
commit-hash: ac68faa20c58cbccd01ee7208bf3b6e93a7d7f96
commit-date: 2026-05-25
host: aarch64-apple-darwin
release: 1.96.0
LLVM version: 22.1.2
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
I am not sure exactly why, but the warning shows up when checking via
cargo check --all-targetsand not withcargo check.Other cases
Rust Version
Anything else?
No response