aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-13 18:20:58 +0100
committerAleksey Kladov <[email protected]>2021-06-13 18:20:58 +0100
commit24262f9ff6ae9ea326fa35d238704d18e99d52a1 (patch)
tree4072b940cd1081c404dabe6026b14b4ca0141c2d /crates/ide
parent949a6ec469507db5e79578da94e17cb63cb54d19 (diff)
minor
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/diagnostics.rs43
-rw-r--r--crates/ide/src/diagnostics/missing_fields.rs33
-rw-r--r--crates/ide/src/diagnostics/missing_ok_or_some_in_tail_expr.rs2
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(
251 res 251 res
252} 252}
253 253
254fn diagnostic_with_fix<D: DiagnosticWithFixes>(
255 d: &D,
256 sema: &Semantics<RootDatabase>,
257 resolve: &AssistResolveStrategy,
258) -> Diagnostic {
259 Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message())
260 .with_fixes(d.fixes(sema, resolve))
261 .with_code(Some(d.code()))
262}
263
264fn warning_with_fix<D: DiagnosticWithFixes>( 254fn warning_with_fix<D: DiagnosticWithFixes>(
265 d: &D, 255 d: &D,
266 sema: &Semantics<RootDatabase>, 256 sema: &Semantics<RootDatabase>,
@@ -447,39 +437,6 @@ mod tests {
447 } 437 }
448 438
449 #[test] 439 #[test]
450 fn range_mapping_out_of_macros() {
451 // FIXME: this is very wrong, but somewhat tricky to fix.
452 check_fix(
453 r#"
454fn some() {}
455fn items() {}
456fn here() {}
457
458macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
459
460fn main() {
461 let _x = id![Foo { a: $042 }];
462}
463
464pub struct Foo { pub a: i32, pub b: i32 }
465"#,
466 r#"
467fn some(, b: () ) {}
468fn items() {}
469fn here() {}
470
471macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
472
473fn main() {
474 let _x = id![Foo { a: 42 }];
475}
476
477pub struct Foo { pub a: i32, pub b: i32 }
478"#,
479 );
480 }
481
482 #[test]
483 fn test_check_unnecessary_braces_in_use_statement() { 440 fn test_check_unnecessary_braces_in_use_statement() {
484 check_diagnostics( 441 check_diagnostics(
485 r#" 442 r#"
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
@@ -94,6 +94,39 @@ fn baz(s: S) {
94 } 94 }
95 95
96 #[test] 96 #[test]
97 fn range_mapping_out_of_macros() {
98 // FIXME: this is very wrong, but somewhat tricky to fix.
99 check_fix(
100 r#"
101fn some() {}
102fn items() {}
103fn here() {}
104
105macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
106
107fn main() {
108 let _x = id![Foo { a: $042 }];
109}
110
111pub struct Foo { pub a: i32, pub b: i32 }
112"#,
113 r#"
114fn some(, b: () ) {}
115fn items() {}
116fn here() {}
117
118macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
119
120fn main() {
121 let _x = id![Foo { a: 42 }];
122}
123
124pub struct Foo { pub a: i32, pub b: i32 }
125"#,
126 );
127 }
128
129 #[test]
97 fn test_fill_struct_fields_empty() { 130 fn test_fill_struct_fields_empty() {
98 check_fix( 131 check_fix(
99 r#" 132 r#"
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 @@
1use hir::{db::AstDatabase, Semantics}; 1use hir::db::AstDatabase;
2use ide_assists::Assist; 2use ide_assists::Assist;
3use ide_db::source_change::SourceChange; 3use ide_db::source_change::SourceChange;
4use syntax::AstNode; 4use syntax::AstNode;