According to this answer, #[allow(dead_code)] should work, but it doesn't
fn main() {
    #[allow(dead_code)]
    let x = 0;
}
According to this answer, #[allow(dead_code)] should work, but it doesn't
fn main() {
    #[allow(dead_code)]
    let x = 0;
}
 
    
     
    
    These are different lints. dead_code refers to unused code at the item level, e.g. imports, functions and types. unused_variables refers to variables that are never accessed.
You can also cover both cases with #[allow(unused)].
 
    
    The correct is
fn main() {
    #[allow(unused_variables)]
    let x = 0;
}
 
    
    