Open RalfJung opened 1 year ago
This is probably related to the fact that the function calling uint
is itself dead code? But the warning as-is is very confusing. If anything it should point at the first unused function at the top of the call chain, not the last one at the bottom.
Here's a self-contained reproducer:
pub fn lib() {}
trait Ext {
fn unused(&self) { unused2() }
}
fn unused2() {}
The warning is technically correct, as the method is indeed never called and the dead_code
lint is transitive (it works correctly when only free functions are involved here).
I think it should also complain that fn unused
in the trait isn't used here. As long as the trait is private and the method is truly never called, it should be safe to mark it as dead code as well. I think that would fix the issue here.
To reproduce, check out this branch, do
./rustup-toolchain && ./miri check
:However, that warning is just wrong! Indeed, removing this function leads to a build error: