-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#[tracing::instrument] swallows lints such as dead_code
#1366
Comments
dead_code
This is particularly confusing if combined with a dead code warning inside the function. This only seems to happens if the traced function is inside a implementation block. struct Test;
impl Test {
#[tracing::instrument]
fn never_used(var: i32) {
const IS_USED: &str = "I get a dead code warning";
if IS_USED == "" {
println!("");
}
}
}
fn main() {
let _test = Test;
} If one comments out the constant I brought this specific case up with the compiler to see if there is anything they can do about this especially confusing case. |
Closes (partially?) tokio-rs#1366
Closes (partially?) tokio-rs#1366
Closes (partially?) tokio-rs#1366
Closes (partially?) tokio-rs#1366
Bug Report
Version
0.1.25
Platform
Windows 10 64-bit
Crates
Description
Functions wrapped in
#[tracing::instrument]
will not trigger lints such asdead_code
. See andrewhickman/fn-error-context#3 for a very similar issue (in a much simpler macro) which was caused by dropping some spans on the macro tokens.Minimal example to reproduce:
Without the instrument attribute, we get a
dead_code
lint warning, but with it applied the warning is suppressed.The text was updated successfully, but these errors were encountered: