How to disable unused code warnings in Rust?

You can either:

  • Add an allow attribute on a struct, module, function, etc.:

    #[allow(dead_code)]
    struct SemanticDirection;
    
  • Add a crate-level allow attribute; notice the !:

    #![allow(dead_code)]
    
  • Pass it to rustc:

    rustc -A dead_code main.rs
    
  • Pass it using cargo via the RUSTFLAGS environment variable:

    RUSTFLAGS="$RUSTFLAGS -A dead_code" cargo build
    

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)