From 24262f9ff6ae9ea326fa35d238704d18e99d52a1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 20:20:58 +0300 Subject: minor --- crates/ide/src/diagnostics.rs | 43 ---------------------- crates/ide/src/diagnostics/missing_fields.rs | 33 +++++++++++++++++ .../diagnostics/missing_ok_or_some_in_tail_expr.rs | 2 +- 3 files changed, 34 insertions(+), 44 deletions(-) diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index af282db0c..e3974e1ae 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -251,16 +251,6 @@ pub(crate) fn diagnostics( res } -fn diagnostic_with_fix( - d: &D, - sema: &Semantics, - resolve: &AssistResolveStrategy, -) -> Diagnostic { - Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message()) - .with_fixes(d.fixes(sema, resolve)) - .with_code(Some(d.code())) -} - fn warning_with_fix( d: &D, sema: &Semantics, @@ -446,39 +436,6 @@ mod tests { } } - #[test] - fn range_mapping_out_of_macros() { - // FIXME: this is very wrong, but somewhat tricky to fix. - check_fix( - r#" -fn some() {} -fn items() {} -fn here() {} - -macro_rules! id { ($($tt:tt)*) => { $($tt)*}; } - -fn main() { - let _x = id![Foo { a: $042 }]; -} - -pub struct Foo { pub a: i32, pub b: i32 } -"#, - r#" -fn some(, b: () ) {} -fn items() {} -fn here() {} - -macro_rules! id { ($($tt:tt)*) => { $($tt)*}; } - -fn main() { - let _x = id![Foo { a: 42 }]; -} - -pub struct Foo { pub a: i32, pub b: i32 } -"#, - ); - } - #[test] fn test_check_unnecessary_braces_in_use_statement() { check_diagnostics( diff --git a/crates/ide/src/diagnostics/missing_fields.rs b/crates/ide/src/diagnostics/missing_fields.rs index 95cd64956..c4b6a3679 100644 --- a/crates/ide/src/diagnostics/missing_fields.rs +++ b/crates/ide/src/diagnostics/missing_fields.rs @@ -93,6 +93,39 @@ fn baz(s: S) { ); } + #[test] + fn range_mapping_out_of_macros() { + // FIXME: this is very wrong, but somewhat tricky to fix. + check_fix( + r#" +fn some() {} +fn items() {} +fn here() {} + +macro_rules! id { ($($tt:tt)*) => { $($tt)*}; } + +fn main() { + let _x = id![Foo { a: $042 }]; +} + +pub struct Foo { pub a: i32, pub b: i32 } +"#, + r#" +fn some(, b: () ) {} +fn items() {} +fn here() {} + +macro_rules! id { ($($tt:tt)*) => { $($tt)*}; } + +fn main() { + let _x = id![Foo { a: 42 }]; +} + +pub struct Foo { pub a: i32, pub b: i32 } +"#, + ); + } + #[test] fn test_fill_struct_fields_empty() { check_fix( diff --git a/crates/ide/src/diagnostics/missing_ok_or_some_in_tail_expr.rs b/crates/ide/src/diagnostics/missing_ok_or_some_in_tail_expr.rs index e27b54e66..06005d156 100644 --- a/crates/ide/src/diagnostics/missing_ok_or_some_in_tail_expr.rs +++ b/crates/ide/src/diagnostics/missing_ok_or_some_in_tail_expr.rs @@ -1,4 +1,4 @@ -use hir::{db::AstDatabase, Semantics}; +use hir::db::AstDatabase; use ide_assists::Assist; use ide_db::source_change::SourceChange; use syntax::AstNode; -- cgit v1.2.3