aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-13 17:23:37 +0100
committerAleksey Kladov <[email protected]>2021-06-13 17:23:37 +0100
commita1940d8c75bee8c319e7e7f19607bdc4b01c28d4 (patch)
tree9286c07c119c3d7bbf95a9b4aa7047944cbb1990 /crates/ide/src/diagnostics
parent7bff76d8ae1e8c3fbada1ade9ccf5111a1c0547e (diff)
internal: check diagnostics in all files and not just the first one
Diffstat (limited to 'crates/ide/src/diagnostics')
-rw-r--r--crates/ide/src/diagnostics/inactive_code.rs16
-rw-r--r--crates/ide/src/diagnostics/macro_error.rs16
2 files changed, 23 insertions, 9 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}
diff --git a/crates/ide/src/diagnostics/macro_error.rs b/crates/ide/src/diagnostics/macro_error.rs
index 8cc8cfb48..d76a3a094 100644
--- a/crates/ide/src/diagnostics/macro_error.rs
+++ b/crates/ide/src/diagnostics/macro_error.rs
@@ -14,7 +14,12 @@ pub(super) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) ->
14 14
15#[cfg(test)] 15#[cfg(test)]
16mod tests { 16mod tests {
17 use crate::diagnostics::tests::{check_diagnostics, check_no_diagnostics}; 17 use crate::{
18 diagnostics::tests::{
19 check_diagnostics, check_diagnostics_with_config, check_no_diagnostics,
20 },
21 DiagnosticsConfig,
22 };
18 23
19 #[test] 24 #[test]
20 fn builtin_macro_fails_expansion() { 25 fn builtin_macro_fails_expansion() {
@@ -31,7 +36,14 @@ macro_rules! include { () => {} }
31 36
32 #[test] 37 #[test]
33 fn include_macro_should_allow_empty_content() { 38 fn include_macro_should_allow_empty_content() {
34 check_diagnostics( 39 let mut config = DiagnosticsConfig::default();
40
41 // FIXME: This is a false-positive, the file is actually linked in via
42 // `include!` macro
43 config.disabled.insert("unlinked-file".to_string());
44
45 check_diagnostics_with_config(
46 config,
35 r#" 47 r#"
36//- /lib.rs 48//- /lib.rs
37#[rustc_builtin_macro] 49#[rustc_builtin_macro]