Last active
August 29, 2015 14:21
-
-
Save cbiffle/0864f7c804095e33bf7a to your computer and use it in GitHub Desktop.
Possible misbehavior in rustc cfg_attr(test, allow(dead_code))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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