aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/diagnostics.rs')
-rw-r--r--crates/ra_hir_ty/src/diagnostics.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 1e3a44637..b34ba5bfc 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -6,7 +6,7 @@ mod unsafe_check;
6use std::any::Any; 6use std::any::Any;
7 7
8use hir_def::DefWithBodyId; 8use hir_def::DefWithBodyId;
9use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; 9use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticWithFix};
10use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; 10use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile};
11use ra_prof::profile; 11use ra_prof::profile;
12use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; 12use ra_syntax::{ast, AstPtr, SyntaxNodePtr};
@@ -46,12 +46,12 @@ impl Diagnostic for NoSuchField {
46 } 46 }
47} 47}
48 48
49impl AstDiagnostic for NoSuchField { 49impl DiagnosticWithFix for NoSuchField {
50 type AST = ast::RecordExprField; 50 type AST = ast::RecordExprField;
51 51
52 fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { 52 fn fix_source(&self, db: &dyn AstDatabase) -> Option<Self::AST> {
53 let root = db.parse_or_expand(self.file).unwrap(); 53 let root = db.parse_or_expand(self.file)?;
54 self.field.to_node(&root) 54 Some(self.field.to_node(&root))
55 } 55 }
56} 56}
57 57
@@ -88,12 +88,12 @@ impl Diagnostic for MissingFields {
88 } 88 }
89} 89}
90 90
91impl AstDiagnostic for MissingFields { 91impl DiagnosticWithFix for MissingFields {
92 type AST = ast::RecordExpr; 92 type AST = ast::RecordExpr;
93 93
94 fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { 94 fn fix_source(&self, db: &dyn AstDatabase) -> Option<Self::AST> {
95 let root = db.parse_or_expand(self.file).unwrap(); 95 let root = db.parse_or_expand(self.file)?;
96 self.field_list_parent.to_node(&root) 96 Some(self.field_list_parent.to_node(&root))
97 } 97 }
98} 98}
99 99
@@ -163,12 +163,12 @@ impl Diagnostic for MissingOkInTailExpr {
163 } 163 }
164} 164}
165 165
166impl AstDiagnostic for MissingOkInTailExpr { 166impl DiagnosticWithFix for MissingOkInTailExpr {
167 type AST = ast::Expr; 167 type AST = ast::Expr;
168 168
169 fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { 169 fn fix_source(&self, db: &dyn AstDatabase) -> Option<Self::AST> {
170 let root = db.parse_or_expand(self.file).unwrap(); 170 let root = db.parse_or_expand(self.file)?;
171 self.expr.to_node(&root) 171 Some(self.expr.to_node(&root))
172 } 172 }
173} 173}
174 174