aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-08-10 20:53:10 +0100
committerKirill Bulatov <[email protected]>2020-08-11 13:09:08 +0100
commit936861993935d5b2c78b953e2f4b719e1992bd73 (patch)
tree93f3e8392946b8cb7df98faeb96088dcf82c0db8 /crates/ra_hir_ty
parent9963f43d51071ea02f8f6d490b9c49882034b42c (diff)
Make the fix AST source Optional
Diffstat (limited to 'crates/ra_hir_ty')
-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