aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/inactive_code.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/diagnostics/inactive_code.rs')
-rw-r--r--crates/ide/src/diagnostics/inactive_code.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/ide/src/diagnostics/inactive_code.rs b/crates/ide/src/diagnostics/inactive_code.rs
index afe333204..d9d3e88c1 100644
--- a/crates/ide/src/diagnostics/inactive_code.rs
+++ b/crates/ide/src/diagnostics/inactive_code.rs
@@ -37,11 +37,16 @@ pub(super) fn inactive_code(
37 37
38#[cfg(test)] 38#[cfg(test)]
39mod tests { 39mod tests {
40 use crate::diagnostics::tests::check_diagnostics_with_inactive_code; 40 use crate::{diagnostics::tests::check_diagnostics_with_config, DiagnosticsConfig};
41
42 pub(crate) fn check(ra_fixture: &str) {
43 let config = DiagnosticsConfig::default();
44 check_diagnostics_with_config(config, ra_fixture)
45 }
41 46
42 #[test] 47 #[test]
43 fn cfg_diagnostics() { 48 fn cfg_diagnostics() {
44 check_diagnostics_with_inactive_code( 49 check(
45 r#" 50 r#"
46fn f() { 51fn f() {
47 // The three g̶e̶n̶d̶e̶r̶s̶ statements: 52 // The three g̶e̶n̶d̶e̶r̶s̶ statements:
@@ -69,7 +74,6 @@ fn f() {
69 //^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled 74 //^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
70} 75}
71 "#, 76 "#,
72 true,
73 ); 77 );
74 } 78 }
75 79
@@ -77,7 +81,7 @@ fn f() {
77 fn inactive_item() { 81 fn inactive_item() {
78 // Additional tests in `cfg` crate. This only tests disabled cfgs. 82 // Additional tests in `cfg` crate. This only tests disabled cfgs.
79 83
80 check_diagnostics_with_inactive_code( 84 check(
81 r#" 85 r#"
82 #[cfg(no)] pub fn f() {} 86 #[cfg(no)] pub fn f() {}
83 //^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled 87 //^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
@@ -91,7 +95,6 @@ fn f() {
91 #[cfg(feature = "std")] use std; 95 #[cfg(feature = "std")] use std;
92 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: feature = "std" is disabled 96 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: feature = "std" is disabled
93"#, 97"#,
94 true,
95 ); 98 );
96 } 99 }
97 100
@@ -99,7 +102,7 @@ fn f() {
99 #[test] 102 #[test]
100 fn inactive_via_cfg_attr() { 103 fn inactive_via_cfg_attr() {
101 cov_mark::check!(cfg_attr_active); 104 cov_mark::check!(cfg_attr_active);
102 check_diagnostics_with_inactive_code( 105 check(
103 r#" 106 r#"
104 #[cfg_attr(not(never), cfg(no))] fn f() {} 107 #[cfg_attr(not(never), cfg(no))] fn f() {}
105 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled 108 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
@@ -111,7 +114,6 @@ fn f() {
111 #[cfg_attr(not(never), inline, cfg(no))] fn h() {} 114 #[cfg_attr(not(never), inline, cfg(no))] fn h() {}
112 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled 115 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
113"#, 116"#,
114 true,
115 ); 117 );
116 } 118 }
117} 119}