mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
minor: simplify
This commit is contained in:
parent
a1940d8c75
commit
dec207f56a
6 changed files with 18 additions and 35 deletions
|
@ -416,21 +416,6 @@ mod tests {
|
|||
assert!(diagnostic.fixes.is_none(), "got a fix when none was expected: {:?}", diagnostic);
|
||||
}
|
||||
|
||||
/// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics
|
||||
/// apply to the file containing the cursor.
|
||||
pub(crate) fn check_no_diagnostics(ra_fixture: &str) {
|
||||
let (analysis, files) = fixture::files(ra_fixture);
|
||||
let diagnostics = files
|
||||
.into_iter()
|
||||
.flat_map(|file_id| {
|
||||
analysis
|
||||
.diagnostics(&DiagnosticsConfig::default(), AssistResolveStrategy::All, file_id)
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(diagnostics.len(), 0, "unexpected diagnostics:\n{:#?}", diagnostics);
|
||||
}
|
||||
|
||||
pub(crate) fn check_expect(ra_fixture: &str, expect: Expect) {
|
||||
let (analysis, file_id) = fixture::file(ra_fixture);
|
||||
let diagnostics = analysis
|
||||
|
@ -496,7 +481,7 @@ pub struct Foo { pub a: i32, pub b: i32 }
|
|||
|
||||
#[test]
|
||||
fn test_check_unnecessary_braces_in_use_statement() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
use a;
|
||||
use a::{c, d::e};
|
||||
|
@ -509,7 +494,7 @@ mod a {
|
|||
}
|
||||
"#,
|
||||
);
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
use a;
|
||||
use a::{
|
||||
|
@ -719,7 +704,7 @@ $0
|
|||
|
||||
#[test]
|
||||
fn unlinked_file_with_cfg_on() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- /main.rs
|
||||
#[cfg(not(never))]
|
||||
|
|
|
@ -98,17 +98,17 @@ fn check_pat_field_shorthand(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::diagnostics::tests::{check_fix, check_no_diagnostics};
|
||||
use crate::diagnostics::tests::{check_diagnostics, check_fix};
|
||||
|
||||
#[test]
|
||||
fn test_check_expr_field_shorthand() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
struct A { a: &'static str }
|
||||
fn main() { A { a: "hello" } }
|
||||
"#,
|
||||
);
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
struct A(usize);
|
||||
fn main() { A { 0: 0 } }
|
||||
|
@ -154,13 +154,13 @@ fn main() {
|
|||
|
||||
#[test]
|
||||
fn test_check_pat_field_shorthand() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
struct A { a: &'static str }
|
||||
fn f(a: A) { let A { a: hello } = a; }
|
||||
"#,
|
||||
);
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
struct A(usize);
|
||||
fn f(a: A) { let A { 0: 0 } = a; }
|
||||
|
|
|
@ -35,7 +35,7 @@ impl DiagnosticWithFixes for IncorrectCase {
|
|||
#[cfg(test)]
|
||||
mod change_case {
|
||||
use crate::{
|
||||
diagnostics::tests::{check_fix, check_no_diagnostics},
|
||||
diagnostics::tests::{check_diagnostics, check_fix},
|
||||
fixture, AssistResolveStrategy, DiagnosticsConfig,
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,7 @@ fn some_fn() {
|
|||
|
||||
#[test]
|
||||
fn test_uppercase_const_no_diagnostics() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
fn foo() {
|
||||
const ANOTHER_ITEM$0: &str = "some_item";
|
||||
|
|
|
@ -25,7 +25,7 @@ impl DiagnosticWithFixes for MissingOkOrSomeInTailExpr {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::diagnostics::tests::{check_fix, check_no_diagnostics};
|
||||
use crate::diagnostics::tests::{check_diagnostics, check_fix};
|
||||
|
||||
#[test]
|
||||
fn test_wrap_return_type_option() {
|
||||
|
@ -169,7 +169,7 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
|
|||
|
||||
#[test]
|
||||
fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:core
|
||||
use core::result::Result::{self, Ok, Err};
|
||||
|
@ -189,7 +189,7 @@ pub mod option {
|
|||
|
||||
#[test]
|
||||
fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:core
|
||||
use core::result::Result::{self, Ok, Err};
|
||||
|
|
|
@ -15,9 +15,7 @@ pub(super) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) ->
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
diagnostics::tests::{
|
||||
check_diagnostics, check_diagnostics_with_config, check_no_diagnostics,
|
||||
},
|
||||
diagnostics::tests::{check_diagnostics, check_diagnostics_with_config},
|
||||
DiagnosticsConfig,
|
||||
};
|
||||
|
||||
|
@ -77,7 +75,7 @@ macro_rules! concat { () => {} }
|
|||
fn register_attr_and_tool() {
|
||||
cov_mark::check!(register_attr);
|
||||
cov_mark::check!(register_tool);
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
#![register_tool(tool)]
|
||||
#![register_attr(attr)]
|
||||
|
|
|
@ -77,7 +77,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::diagnostics::tests::{check_diagnostics, check_fix, check_no_diagnostics};
|
||||
use crate::diagnostics::tests::{check_diagnostics, check_fix};
|
||||
|
||||
#[test]
|
||||
fn missing_record_pat_field_diagnostic() {
|
||||
|
@ -203,7 +203,7 @@ fn test_fn() {
|
|||
|
||||
#[test]
|
||||
fn test_fill_struct_fields_no_diagnostic() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
struct TestStruct { one: i32, two: i64 }
|
||||
|
||||
|
@ -217,7 +217,7 @@ fn test_fn() {
|
|||
|
||||
#[test]
|
||||
fn test_fill_struct_fields_no_diagnostic_on_spread() {
|
||||
check_no_diagnostics(
|
||||
check_diagnostics(
|
||||
r#"
|
||||
struct TestStruct { one: i32, two: i64 }
|
||||
|
||||
|
|
Loading…
Reference in a new issue