aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-23 11:38:30 +0100
committerGitHub <[email protected]>2020-10-23 11:38:30 +0100
commit81609960fa30ea92e37b23dc7b025d1939626812 (patch)
tree835866b358bd597e1a2c481b93641418c2562c86 /crates/hir_def/src/nameres/tests
parent8b3c851dd37f39f79e7e8807378f45fdde7f6411 (diff)
parenta246d4f599dcf2612fa99720fb4ca98101ed93fb (diff)
Merge #6324
6324: Improve #[cfg] diagnostics r=jonas-schievink a=jonas-schievink Unfortunately I ran into https://github.com/rust-analyzer/rust-analyzer/issues/4058 while testing this on https://github.com/nrf-rs/nrf-hal/, so I didn't see much of it in action yet, but it does seem to work. Co-authored-by: Jonas Schievink <[email protected]> Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/tests')
-rw-r--r--crates/hir_def/src/nameres/tests/diagnostics.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs
index 576b813d2..5972248de 100644
--- a/crates/hir_def/src/nameres/tests/diagnostics.rs
+++ b/crates/hir_def/src/nameres/tests/diagnostics.rs
@@ -129,3 +129,25 @@ fn unresolved_module() {
129 ", 129 ",
130 ); 130 );
131} 131}
132
133#[test]
134fn inactive_item() {
135 // Additional tests in `cfg` crate. This only tests disabled cfgs.
136
137 check_diagnostics(
138 r#"
139 //- /lib.rs
140 #[cfg(no)] pub fn f() {}
141 //^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
142
143 #[cfg(no)] #[cfg(no2)] mod m;
144 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no and no2 are disabled
145
146 #[cfg(all(not(a), b))] enum E {}
147 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: b is disabled
148
149 #[cfg(feature = "std")] use std;
150 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: feature = "std" is disabled
151 "#,
152 );
153}