Files
rust/tests/ui/cfg_not_test.rs

38 lines
663 B
Rust
Raw Normal View History

2024-06-12 18:11:01 +02:00
#![allow(unused)]
#![warn(clippy::cfg_not_test)]
fn important_check() {}
fn main() {
// Statement
#[cfg(not(test))]
2025-02-11 17:57:08 +01:00
//~^ cfg_not_test
2024-06-12 18:11:01 +02:00
let answer = 42;
// Expression
#[cfg(not(test))]
2025-02-11 17:57:08 +01:00
//~^ cfg_not_test
2024-06-12 18:11:01 +02:00
important_check();
// Make sure only not(test) are checked, not other attributes
#[cfg(not(foo))]
important_check();
}
#[cfg(not(not(test)))]
struct CfgNotTest;
// Deeply nested `not(test)`
#[cfg(not(test))]
2025-02-11 17:57:08 +01:00
//~^ cfg_not_test
2024-06-12 18:11:01 +02:00
fn foo() {}
#[cfg(all(debug_assertions, not(test)))]
2025-02-11 17:57:08 +01:00
//~^ cfg_not_test
2024-06-12 18:11:01 +02:00
fn bar() {}
#[cfg(not(any(not(debug_assertions), test)))]
2025-02-11 17:57:08 +01:00
//~^ cfg_not_test
2024-06-12 18:11:01 +02:00
fn baz() {}
#[cfg(test)]
mod tests {}