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.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 3469cc680..c6ca322fa 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -3,7 +3,7 @@
3use std::any::Any; 3use std::any::Any;
4 4
5use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; 5use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile};
6use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; 6use ra_syntax::{ast::{self, NameOwner}, AstNode, AstPtr, SyntaxNodePtr};
7use stdx::format_to; 7use stdx::format_to;
8 8
9pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm, path::Path}; 9pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm, path::Path};
@@ -174,12 +174,11 @@ impl AstDiagnostic for BreakOutsideOfLoop {
174pub struct MissingUnsafe { 174pub struct MissingUnsafe {
175 pub file: HirFileId, 175 pub file: HirFileId,
176 pub fn_def: AstPtr<ast::FnDef>, 176 pub fn_def: AstPtr<ast::FnDef>,
177 pub fn_name: Name,
178} 177}
179 178
180impl Diagnostic for MissingUnsafe { 179impl Diagnostic for MissingUnsafe {
181 fn message(&self) -> String { 180 fn message(&self) -> String {
182 format!("Missing unsafe marker on fn `{}`", self.fn_name) 181 format!("Missing unsafe keyword on fn")
183 } 182 }
184 fn source(&self) -> InFile<SyntaxNodePtr> { 183 fn source(&self) -> InFile<SyntaxNodePtr> {
185 InFile { file_id: self.file, value: self.fn_def.clone().into() } 184 InFile { file_id: self.file, value: self.fn_def.clone().into() }
@@ -190,12 +189,12 @@ impl Diagnostic for MissingUnsafe {
190} 189}
191 190
192impl AstDiagnostic for MissingUnsafe { 191impl AstDiagnostic for MissingUnsafe {
193 type AST = ast::FnDef; 192 type AST = ast::Name;
194 193
195 fn ast(&self, db: &impl AstDatabase) -> Self::AST { 194 fn ast(&self, db: &impl AstDatabase) -> Self::AST {
196 let root = db.parse_or_expand(self.source().file_id).unwrap(); 195 let root = db.parse_or_expand(self.source().file_id).unwrap();
197 let node = self.source().value.to_node(&root); 196 let node = self.source().value.to_node(&root);
198 ast::FnDef::cast(node).unwrap() 197 ast::FnDef::cast(node).unwrap().name().unwrap()
199 } 198 }
200} 199}
201 200
@@ -203,12 +202,11 @@ impl AstDiagnostic for MissingUnsafe {
203pub struct UnnecessaryUnsafe { 202pub struct UnnecessaryUnsafe {
204 pub file: HirFileId, 203 pub file: HirFileId,
205 pub fn_def: AstPtr<ast::FnDef>, 204 pub fn_def: AstPtr<ast::FnDef>,
206 pub fn_name: Name,
207} 205}
208 206
209impl Diagnostic for UnnecessaryUnsafe { 207impl Diagnostic for UnnecessaryUnsafe {
210 fn message(&self) -> String { 208 fn message(&self) -> String {
211 format!("Unnecessary unsafe marker on fn `{}`", self.fn_name) 209 format!("Unnecessary unsafe keyword on fn")
212 } 210 }
213 fn source(&self) -> InFile<SyntaxNodePtr> { 211 fn source(&self) -> InFile<SyntaxNodePtr> {
214 InFile { file_id: self.file, value: self.fn_def.clone().into() } 212 InFile { file_id: self.file, value: self.fn_def.clone().into() }
@@ -219,11 +217,11 @@ impl Diagnostic for UnnecessaryUnsafe {
219} 217}
220 218
221impl AstDiagnostic for UnnecessaryUnsafe { 219impl AstDiagnostic for UnnecessaryUnsafe {
222 type AST = ast::FnDef; 220 type AST = ast::Name;
223 221
224 fn ast(&self, db: &impl AstDatabase) -> Self::AST { 222 fn ast(&self, db: &impl AstDatabase) -> Self::AST {
225 let root = db.parse_or_expand(self.source().file_id).unwrap(); 223 let root = db.parse_or_expand(self.source().file_id).unwrap();
226 let node = self.source().value.to_node(&root); 224 let node = self.source().value.to_node(&root);
227 ast::FnDef::cast(node).unwrap() 225 ast::FnDef::cast(node).unwrap().name().unwrap()
228 } 226 }
229} 227}