Skip to content

Commit dec207f

Browse files
committed
minor: simplify
1 parent a1940d8 commit dec207f

File tree

6 files changed

+18
-35
lines changed

6 files changed

+18
-35
lines changed

crates/ide/src/diagnostics.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -416,21 +416,6 @@ mod tests {
416416
assert!(diagnostic.fixes.is_none(), "got a fix when none was expected: {:?}", diagnostic);
417417
}
418418

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-
434419
pub(crate) fn check_expect(ra_fixture: &str, expect: Expect) {
435420
let (analysis, file_id) = fixture::file(ra_fixture);
436421
let diagnostics = analysis
@@ -496,7 +481,7 @@ pub struct Foo { pub a: i32, pub b: i32 }
496481

497482
#[test]
498483
fn test_check_unnecessary_braces_in_use_statement() {
499-
check_no_diagnostics(
484+
check_diagnostics(
500485
r#"
501486
use a;
502487
use a::{c, d::e};
@@ -509,7 +494,7 @@ mod a {
509494
}
510495
"#,
511496
);
512-
check_no_diagnostics(
497+
check_diagnostics(
513498
r#"
514499
use a;
515500
use a::{
@@ -719,7 +704,7 @@ $0
719704

720705
#[test]
721706
fn unlinked_file_with_cfg_on() {
722-
check_no_diagnostics(
707+
check_diagnostics(
723708
r#"
724709
//- /main.rs
725710
#[cfg(not(never))]

crates/ide/src/diagnostics/field_shorthand.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ fn check_pat_field_shorthand(
9898

9999
#[cfg(test)]
100100
mod tests {
101-
use crate::diagnostics::tests::{check_fix, check_no_diagnostics};
101+
use crate::diagnostics::tests::{check_diagnostics, check_fix};
102102

103103
#[test]
104104
fn test_check_expr_field_shorthand() {
105-
check_no_diagnostics(
105+
check_diagnostics(
106106
r#"
107107
struct A { a: &'static str }
108108
fn main() { A { a: "hello" } }
109109
"#,
110110
);
111-
check_no_diagnostics(
111+
check_diagnostics(
112112
r#"
113113
struct A(usize);
114114
fn main() { A { 0: 0 } }
@@ -154,13 +154,13 @@ fn main() {
154154

155155
#[test]
156156
fn test_check_pat_field_shorthand() {
157-
check_no_diagnostics(
157+
check_diagnostics(
158158
r#"
159159
struct A { a: &'static str }
160160
fn f(a: A) { let A { a: hello } = a; }
161161
"#,
162162
);
163-
check_no_diagnostics(
163+
check_diagnostics(
164164
r#"
165165
struct A(usize);
166166
fn f(a: A) { let A { 0: 0 } = a; }

crates/ide/src/diagnostics/fixes/change_case.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl DiagnosticWithFixes for IncorrectCase {
3535
#[cfg(test)]
3636
mod change_case {
3737
use crate::{
38-
diagnostics::tests::{check_fix, check_no_diagnostics},
38+
diagnostics::tests::{check_diagnostics, check_fix},
3939
fixture, AssistResolveStrategy, DiagnosticsConfig,
4040
};
4141

@@ -102,7 +102,7 @@ fn some_fn() {
102102

103103
#[test]
104104
fn test_uppercase_const_no_diagnostics() {
105-
check_no_diagnostics(
105+
check_diagnostics(
106106
r#"
107107
fn foo() {
108108
const ANOTHER_ITEM$0: &str = "some_item";

crates/ide/src/diagnostics/fixes/wrap_tail_expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl DiagnosticWithFixes for MissingOkOrSomeInTailExpr {
2525

2626
#[cfg(test)]
2727
mod tests {
28-
use crate::diagnostics::tests::{check_fix, check_no_diagnostics};
28+
use crate::diagnostics::tests::{check_diagnostics, check_fix};
2929

3030
#[test]
3131
fn test_wrap_return_type_option() {
@@ -169,7 +169,7 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
169169

170170
#[test]
171171
fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() {
172-
check_no_diagnostics(
172+
check_diagnostics(
173173
r#"
174174
//- /main.rs crate:main deps:core
175175
use core::result::Result::{self, Ok, Err};
@@ -189,7 +189,7 @@ pub mod option {
189189

190190
#[test]
191191
fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() {
192-
check_no_diagnostics(
192+
check_diagnostics(
193193
r#"
194194
//- /main.rs crate:main deps:core
195195
use core::result::Result::{self, Ok, Err};

crates/ide/src/diagnostics/macro_error.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ pub(super) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) ->
1515
#[cfg(test)]
1616
mod tests {
1717
use crate::{
18-
diagnostics::tests::{
19-
check_diagnostics, check_diagnostics_with_config, check_no_diagnostics,
20-
},
18+
diagnostics::tests::{check_diagnostics, check_diagnostics_with_config},
2119
DiagnosticsConfig,
2220
};
2321

@@ -77,7 +75,7 @@ macro_rules! concat { () => {} }
7775
fn register_attr_and_tool() {
7876
cov_mark::check!(register_attr);
7977
cov_mark::check!(register_tool);
80-
check_no_diagnostics(
78+
check_diagnostics(
8179
r#"
8280
#![register_tool(tool)]
8381
#![register_attr(attr)]

crates/ide/src/diagnostics/missing_fields.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
7777

7878
#[cfg(test)]
7979
mod tests {
80-
use crate::diagnostics::tests::{check_diagnostics, check_fix, check_no_diagnostics};
80+
use crate::diagnostics::tests::{check_diagnostics, check_fix};
8181

8282
#[test]
8383
fn missing_record_pat_field_diagnostic() {
@@ -203,7 +203,7 @@ fn test_fn() {
203203

204204
#[test]
205205
fn test_fill_struct_fields_no_diagnostic() {
206-
check_no_diagnostics(
206+
check_diagnostics(
207207
r#"
208208
struct TestStruct { one: i32, two: i64 }
209209
@@ -217,7 +217,7 @@ fn test_fn() {
217217

218218
#[test]
219219
fn test_fill_struct_fields_no_diagnostic_on_spread() {
220-
check_no_diagnostics(
220+
check_diagnostics(
221221
r#"
222222
struct TestStruct { one: i32, two: i64 }
223223

0 commit comments

Comments
 (0)