aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/diagnostics.rs21
-rw-r--r--crates/ide/src/diagnostics/field_shorthand.rs10
-rw-r--r--crates/ide/src/diagnostics/fixes/change_case.rs4
-rw-r--r--crates/ide/src/diagnostics/fixes/wrap_tail_expr.rs6
-rw-r--r--crates/ide/src/diagnostics/macro_error.rs6
-rw-r--r--crates/ide/src/diagnostics/missing_fields.rs6
6 files changed, 18 insertions, 35 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs
index fb956d5ee..aeccf1164 100644
--- a/crates/ide/src/diagnostics.rs
+++ b/crates/ide/src/diagnostics.rs
@@ -416,21 +416,6 @@ mod tests {
416 assert!(diagnostic.fixes.is_none(), "got a fix when none was expected: {:?}", diagnostic); 416 assert!(diagnostic.fixes.is_none(), "got a fix when none was expected: {:?}", diagnostic);
417 } 417 }
418 418
419 /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics
420 /// apply to the file containing the cursor.
421 pub(crate) fn check_no_diagnostics(ra_fixture: &str) {
422 let (analysis, files) = fixture::files(ra_fixture);
423 let diagnostics = files
424 .into_iter()
425 .flat_map(|file_id| {
426 analysis
427 .diagnostics(&DiagnosticsConfig::default(), AssistResolveStrategy::All, file_id)
428 .unwrap()
429 })
430 .collect::<Vec<_>>();
431 assert_eq!(diagnostics.len(), 0, "unexpected diagnostics:\n{:#?}", diagnostics);
432 }
433
434 pub(crate) fn check_expect(ra_fixture: &str, expect: Expect) { 419 pub(crate) fn check_expect(ra_fixture: &str, expect: Expect) {
435 let (analysis, file_id) = fixture::file(ra_fixture); 420 let (analysis, file_id) = fixture::file(ra_fixture);
436 let diagnostics = analysis 421 let diagnostics = analysis
@@ -496,7 +481,7 @@ pub struct Foo { pub a: i32, pub b: i32 }
496 481
497 #[test] 482 #[test]
498 fn test_check_unnecessary_braces_in_use_statement() { 483 fn test_check_unnecessary_braces_in_use_statement() {
499 check_no_diagnostics( 484 check_diagnostics(
500 r#" 485 r#"
501use a; 486use a;
502use a::{c, d::e}; 487use a::{c, d::e};
@@ -509,7 +494,7 @@ mod a {
509} 494}
510"#, 495"#,
511 ); 496 );
512 check_no_diagnostics( 497 check_diagnostics(
513 r#" 498 r#"
514use a; 499use a;
515use a::{ 500use a::{
@@ -719,7 +704,7 @@ $0
719 704
720 #[test] 705 #[test]
721 fn unlinked_file_with_cfg_on() { 706 fn unlinked_file_with_cfg_on() {
722 check_no_diagnostics( 707 check_diagnostics(
723 r#" 708 r#"
724//- /main.rs 709//- /main.rs
725#[cfg(not(never))] 710#[cfg(not(never))]
diff --git a/crates/ide/src/diagnostics/field_shorthand.rs b/crates/ide/src/diagnostics/field_shorthand.rs
index 01bd2dba6..e885a398e 100644
--- a/crates/ide/src/diagnostics/field_shorthand.rs
+++ b/crates/ide/src/diagnostics/field_shorthand.rs
@@ -98,17 +98,17 @@ fn check_pat_field_shorthand(
98 98
99#[cfg(test)] 99#[cfg(test)]
100mod tests { 100mod tests {
101 use crate::diagnostics::tests::{check_fix, check_no_diagnostics}; 101 use crate::diagnostics::tests::{check_diagnostics, check_fix};
102 102
103 #[test] 103 #[test]
104 fn test_check_expr_field_shorthand() { 104 fn test_check_expr_field_shorthand() {
105 check_no_diagnostics( 105 check_diagnostics(
106 r#" 106 r#"
107struct A { a: &'static str } 107struct A { a: &'static str }
108fn main() { A { a: "hello" } } 108fn main() { A { a: "hello" } }
109"#, 109"#,
110 ); 110 );
111 check_no_diagnostics( 111 check_diagnostics(
112 r#" 112 r#"
113struct A(usize); 113struct A(usize);
114fn main() { A { 0: 0 } } 114fn main() { A { 0: 0 } }
@@ -154,13 +154,13 @@ fn main() {
154 154
155 #[test] 155 #[test]
156 fn test_check_pat_field_shorthand() { 156 fn test_check_pat_field_shorthand() {
157 check_no_diagnostics( 157 check_diagnostics(
158 r#" 158 r#"
159struct A { a: &'static str } 159struct A { a: &'static str }
160fn f(a: A) { let A { a: hello } = a; } 160fn f(a: A) { let A { a: hello } = a; }
161"#, 161"#,
162 ); 162 );
163 check_no_diagnostics( 163 check_diagnostics(
164 r#" 164 r#"
165struct A(usize); 165struct A(usize);
166fn f(a: A) { let A { 0: 0 } = a; } 166fn f(a: A) { let A { 0: 0 } = a; }
diff --git a/crates/ide/src/diagnostics/fixes/change_case.rs b/crates/ide/src/diagnostics/fixes/change_case.rs
index 42be3375f..db1a37cd6 100644
--- a/crates/ide/src/diagnostics/fixes/change_case.rs
+++ b/crates/ide/src/diagnostics/fixes/change_case.rs
@@ -35,7 +35,7 @@ impl DiagnosticWithFixes for IncorrectCase {
35#[cfg(test)] 35#[cfg(test)]
36mod change_case { 36mod change_case {
37 use crate::{ 37 use crate::{
38 diagnostics::tests::{check_fix, check_no_diagnostics}, 38 diagnostics::tests::{check_diagnostics, check_fix},
39 fixture, AssistResolveStrategy, DiagnosticsConfig, 39 fixture, AssistResolveStrategy, DiagnosticsConfig,
40 }; 40 };
41 41
@@ -102,7 +102,7 @@ fn some_fn() {
102 102
103 #[test] 103 #[test]
104 fn test_uppercase_const_no_diagnostics() { 104 fn test_uppercase_const_no_diagnostics() {
105 check_no_diagnostics( 105 check_diagnostics(
106 r#" 106 r#"
107fn foo() { 107fn foo() {
108 const ANOTHER_ITEM$0: &str = "some_item"; 108 const ANOTHER_ITEM$0: &str = "some_item";
diff --git a/crates/ide/src/diagnostics/fixes/wrap_tail_expr.rs b/crates/ide/src/diagnostics/fixes/wrap_tail_expr.rs
index 715a403b9..dcb21e037 100644
--- a/crates/ide/src/diagnostics/fixes/wrap_tail_expr.rs
+++ b/crates/ide/src/diagnostics/fixes/wrap_tail_expr.rs
@@ -25,7 +25,7 @@ impl DiagnosticWithFixes for MissingOkOrSomeInTailExpr {
25 25
26#[cfg(test)] 26#[cfg(test)]
27mod tests { 27mod tests {
28 use crate::diagnostics::tests::{check_fix, check_no_diagnostics}; 28 use crate::diagnostics::tests::{check_diagnostics, check_fix};
29 29
30 #[test] 30 #[test]
31 fn test_wrap_return_type_option() { 31 fn test_wrap_return_type_option() {
@@ -169,7 +169,7 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
169 169
170 #[test] 170 #[test]
171 fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() { 171 fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() {
172 check_no_diagnostics( 172 check_diagnostics(
173 r#" 173 r#"
174//- /main.rs crate:main deps:core 174//- /main.rs crate:main deps:core
175use core::result::Result::{self, Ok, Err}; 175use core::result::Result::{self, Ok, Err};
@@ -189,7 +189,7 @@ pub mod option {
189 189
190 #[test] 190 #[test]
191 fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() { 191 fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() {
192 check_no_diagnostics( 192 check_diagnostics(
193 r#" 193 r#"
194//- /main.rs crate:main deps:core 194//- /main.rs crate:main deps:core
195use core::result::Result::{self, Ok, Err}; 195use core::result::Result::{self, Ok, Err};
diff --git a/crates/ide/src/diagnostics/macro_error.rs b/crates/ide/src/diagnostics/macro_error.rs
index d76a3a094..5f97f190d 100644
--- a/crates/ide/src/diagnostics/macro_error.rs
+++ b/crates/ide/src/diagnostics/macro_error.rs
@@ -15,9 +15,7 @@ pub(super) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) ->
15#[cfg(test)] 15#[cfg(test)]
16mod tests { 16mod tests {
17 use crate::{ 17 use crate::{
18 diagnostics::tests::{ 18 diagnostics::tests::{check_diagnostics, check_diagnostics_with_config},
19 check_diagnostics, check_diagnostics_with_config, check_no_diagnostics,
20 },
21 DiagnosticsConfig, 19 DiagnosticsConfig,
22 }; 20 };
23 21
@@ -77,7 +75,7 @@ macro_rules! concat { () => {} }
77 fn register_attr_and_tool() { 75 fn register_attr_and_tool() {
78 cov_mark::check!(register_attr); 76 cov_mark::check!(register_attr);
79 cov_mark::check!(register_tool); 77 cov_mark::check!(register_tool);
80 check_no_diagnostics( 78 check_diagnostics(
81 r#" 79 r#"
82#![register_tool(tool)] 80#![register_tool(tool)]
83#![register_attr(attr)] 81#![register_attr(attr)]
diff --git a/crates/ide/src/diagnostics/missing_fields.rs b/crates/ide/src/diagnostics/missing_fields.rs
index 66575f713..95cd64956 100644
--- a/crates/ide/src/diagnostics/missing_fields.rs
+++ b/crates/ide/src/diagnostics/missing_fields.rs
@@ -77,7 +77,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
77 77
78#[cfg(test)] 78#[cfg(test)]
79mod tests { 79mod tests {
80 use crate::diagnostics::tests::{check_diagnostics, check_fix, check_no_diagnostics}; 80 use crate::diagnostics::tests::{check_diagnostics, check_fix};
81 81
82 #[test] 82 #[test]
83 fn missing_record_pat_field_diagnostic() { 83 fn missing_record_pat_field_diagnostic() {
@@ -203,7 +203,7 @@ fn test_fn() {
203 203
204 #[test] 204 #[test]
205 fn test_fill_struct_fields_no_diagnostic() { 205 fn test_fill_struct_fields_no_diagnostic() {
206 check_no_diagnostics( 206 check_diagnostics(
207 r#" 207 r#"
208struct TestStruct { one: i32, two: i64 } 208struct TestStruct { one: i32, two: i64 }
209 209
@@ -217,7 +217,7 @@ fn test_fn() {
217 217
218 #[test] 218 #[test]
219 fn test_fill_struct_fields_no_diagnostic_on_spread() { 219 fn test_fill_struct_fields_no_diagnostic_on_spread() {
220 check_no_diagnostics( 220 check_diagnostics(
221 r#" 221 r#"
222struct TestStruct { one: i32, two: i64 } 222struct TestStruct { one: i32, two: i64 }
223 223