aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-13 15:29:25 +0100
committerAleksey Kladov <[email protected]>2021-06-13 15:29:25 +0100
commitf85e383b94376d55bb5ee6be375ef3dc0006590f (patch)
tree03e3c3685a893891c7b9f144597362a5e57c02ca /crates/hir_def/src
parentfa9ed4e0ce633e51d1411951bf044719e6837457 (diff)
internal: refactor inactive code diagnostics
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/body/tests.rs33
-rw-r--r--crates/hir_def/src/nameres/tests/diagnostics.rs42
2 files changed, 0 insertions, 75 deletions
diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs
index d4fae05a6..075dcc6d2 100644
--- a/crates/hir_def/src/body/tests.rs
+++ b/crates/hir_def/src/body/tests.rs
@@ -89,39 +89,6 @@ mod m {
89} 89}
90 90
91#[test] 91#[test]
92fn cfg_diagnostics() {
93 check_diagnostics(
94 r"
95fn f() {
96 // The three g̶e̶n̶d̶e̶r̶s̶ statements:
97
98 #[cfg(a)] fn f() {} // Item statement
99 //^^^^^^^^^^^^^^^^^^^ InactiveCode
100 #[cfg(a)] {} // Expression statement
101 //^^^^^^^^^^^^ InactiveCode
102 #[cfg(a)] let x = 0; // let statement
103 //^^^^^^^^^^^^^^^^^^^^ InactiveCode
104
105 abc(#[cfg(a)] 0);
106 //^^^^^^^^^^^ InactiveCode
107 let x = Struct {
108 #[cfg(a)] f: 0,
109 //^^^^^^^^^^^^^^ InactiveCode
110 };
111 match () {
112 () => (),
113 #[cfg(a)] () => (),
114 //^^^^^^^^^^^^^^^^^^ InactiveCode
115 }
116
117 #[cfg(a)] 0 // Trailing expression of block
118 //^^^^^^^^^^^ InactiveCode
119}
120 ",
121 );
122}
123
124#[test]
125fn macro_diag_builtin() { 92fn macro_diag_builtin() {
126 check_diagnostics( 93 check_diagnostics(
127 r#" 94 r#"
diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs
index 5a088b6e5..f1ee03d4d 100644
--- a/crates/hir_def/src/nameres/tests/diagnostics.rs
+++ b/crates/hir_def/src/nameres/tests/diagnostics.rs
@@ -13,48 +13,6 @@ fn check_no_diagnostics(ra_fixture: &str) {
13} 13}
14 14
15#[test] 15#[test]
16fn inactive_item() {
17 // Additional tests in `cfg` crate. This only tests disabled cfgs.
18
19 check_diagnostics(
20 r#"
21 //- /lib.rs
22 #[cfg(no)] pub fn f() {}
23 //^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
24
25 #[cfg(no)] #[cfg(no2)] mod m;
26 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
27
28 #[cfg(all(not(a), b))] enum E {}
29 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
30
31 #[cfg(feature = "std")] use std;
32 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
33 "#,
34 );
35}
36
37/// Tests that `cfg` attributes behind `cfg_attr` is handled properly.
38#[test]
39fn inactive_via_cfg_attr() {
40 cov_mark::check!(cfg_attr_active);
41 check_diagnostics(
42 r#"
43 //- /lib.rs
44 #[cfg_attr(not(never), cfg(no))] fn f() {}
45 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
46
47 #[cfg_attr(not(never), cfg(not(no)))] fn f() {}
48
49 #[cfg_attr(never, cfg(no))] fn g() {}
50
51 #[cfg_attr(not(never), inline, cfg(no))] fn h() {}
52 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnconfiguredCode
53 "#,
54 );
55}
56
57#[test]
58fn builtin_macro_fails_expansion() { 16fn builtin_macro_fails_expansion() {
59 check_diagnostics( 17 check_diagnostics(
60 r#" 18 r#"