diff options
author | Kirill Bulatov <[email protected]> | 2020-08-10 20:53:10 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-08-11 13:09:08 +0100 |
commit | 936861993935d5b2c78b953e2f4b719e1992bd73 (patch) | |
tree | 93f3e8392946b8cb7df98faeb96088dcf82c0db8 /crates/ra_hir_ty/src | |
parent | 9963f43d51071ea02f8f6d490b9c49882034b42c (diff) |
Make the fix AST source Optional
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/diagnostics.rs | 26 |
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; | |||
6 | use std::any::Any; | 6 | use std::any::Any; |
7 | 7 | ||
8 | use hir_def::DefWithBodyId; | 8 | use hir_def::DefWithBodyId; |
9 | use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; | 9 | use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticWithFix}; |
10 | use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; | 10 | use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; |
11 | use ra_prof::profile; | 11 | use ra_prof::profile; |
12 | use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; | 12 | use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; |
@@ -46,12 +46,12 @@ impl Diagnostic for NoSuchField { | |||
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | impl AstDiagnostic for NoSuchField { | 49 | impl 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 | ||
91 | impl AstDiagnostic for MissingFields { | 91 | impl 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 | ||
166 | impl AstDiagnostic for MissingOkInTailExpr { | 166 | impl 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 | ||