aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/diagnostics')
-rw-r--r--crates/ide/src/diagnostics/field_shorthand.rs23
-rw-r--r--crates/ide/src/diagnostics/unresolved_module.rs12
2 files changed, 18 insertions, 17 deletions
diff --git a/crates/ide/src/diagnostics/field_shorthand.rs b/crates/ide/src/diagnostics/field_shorthand.rs
index e885a398e..c7f4dab8e 100644
--- a/crates/ide/src/diagnostics/field_shorthand.rs
+++ b/crates/ide/src/diagnostics/field_shorthand.rs
@@ -5,7 +5,7 @@ use ide_db::{base_db::FileId, source_change::SourceChange};
5use syntax::{ast, match_ast, AstNode, SyntaxNode}; 5use syntax::{ast, match_ast, AstNode, SyntaxNode};
6use text_edit::TextEdit; 6use text_edit::TextEdit;
7 7
8use crate::{diagnostics::fix, Diagnostic}; 8use crate::{diagnostics::fix, Diagnostic, Severity};
9 9
10pub(super) fn check(acc: &mut Vec<Diagnostic>, file_id: FileId, node: &SyntaxNode) { 10pub(super) fn check(acc: &mut Vec<Diagnostic>, file_id: FileId, node: &SyntaxNode) {
11 match_ast! { 11 match_ast! {
@@ -46,7 +46,8 @@ fn check_expr_field_shorthand(
46 46
47 let field_range = record_field.syntax().text_range(); 47 let field_range = record_field.syntax().text_range();
48 acc.push( 48 acc.push(
49 Diagnostic::hint(field_range, "Shorthand struct initialization".to_string()) 49 Diagnostic::new("use-field-shorthand", "Shorthand struct initialization", field_range)
50 .severity(Severity::WeakWarning)
50 .with_fixes(Some(vec![fix( 51 .with_fixes(Some(vec![fix(
51 "use_expr_field_shorthand", 52 "use_expr_field_shorthand",
52 "Use struct shorthand initialization", 53 "Use struct shorthand initialization",
@@ -85,14 +86,16 @@ fn check_pat_field_shorthand(
85 let edit = edit_builder.finish(); 86 let edit = edit_builder.finish();
86 87
87 let field_range = record_pat_field.syntax().text_range(); 88 let field_range = record_pat_field.syntax().text_range();
88 acc.push(Diagnostic::hint(field_range, "Shorthand struct pattern".to_string()).with_fixes( 89 acc.push(
89 Some(vec![fix( 90 Diagnostic::new("use-field-shorthand", "Shorthand struct pattern", field_range)
90 "use_pat_field_shorthand", 91 .severity(Severity::WeakWarning)
91 "Use struct field shorthand", 92 .with_fixes(Some(vec![fix(
92 SourceChange::from_text_edit(file_id, edit), 93 "use_pat_field_shorthand",
93 field_range, 94 "Use struct field shorthand",
94 )]), 95 SourceChange::from_text_edit(file_id, edit),
95 )); 96 field_range,
97 )])),
98 );
96 } 99 }
97} 100}
98 101
diff --git a/crates/ide/src/diagnostics/unresolved_module.rs b/crates/ide/src/diagnostics/unresolved_module.rs
index b1da8f0e1..977b46414 100644
--- a/crates/ide/src/diagnostics/unresolved_module.rs
+++ b/crates/ide/src/diagnostics/unresolved_module.rs
@@ -65,9 +65,14 @@ mod baz {}
65 expect![[r#" 65 expect![[r#"
66 [ 66 [
67 Diagnostic { 67 Diagnostic {
68 code: DiagnosticCode(
69 "unresolved-module",
70 ),
68 message: "unresolved module", 71 message: "unresolved module",
69 range: 0..8, 72 range: 0..8,
70 severity: Error, 73 severity: Error,
74 unused: false,
75 experimental: false,
71 fixes: Some( 76 fixes: Some(
72 [ 77 [
73 Assist { 78 Assist {
@@ -98,13 +103,6 @@ mod baz {}
98 }, 103 },
99 ], 104 ],
100 ), 105 ),
101 unused: false,
102 code: Some(
103 DiagnosticCode(
104 "unresolved-module",
105 ),
106 ),
107 experimental: false,
108 }, 106 },
109 ] 107 ]
110 "#]], 108 "#]],