Skip to content

Instantly share code, notes, and snippets.

@cbiffle
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbiffle/0864f7c804095e33bf7a to your computer and use it in GitHub Desktop.
Save cbiffle/0864f7c804095e33bf7a to your computer and use it in GitHub Desktop.
Possible misbehavior in rustc cfg_attr(test, allow(dead_code))
Compiling warn v0.1.0 (file:///home/cbiffle/proj/rs/warn)
src/lib.rs:2:3: 2:31 warning: function is never used: `tested`, #[warn(dead_code)] on by default
src/lib.rs:2 pub fn tested() -> i32 { 0 }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib.rs:5:3: 5:33 warning: function is never used: `untested`, #[warn(dead_code)] on by default
src/lib.rs:5 pub fn untested() -> i32 { 0 }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running target/debug/warn-fef74f9367799b2e
running 1 test
test sub::tests::test ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
Doc-tests warn
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
mod sub {
pub fn tested() -> i32 { 0 }
#[cfg_attr(test, allow(dead_code))]
pub fn untested() -> i32 { 0 }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test() {
assert_eq!(0, tested())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment