aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-12 15:39:46 +0100
committerAleksey Kladov <[email protected]>2021-06-12 15:39:46 +0100
commit0413d51317a2470c94f82d93e66a3d009fce41a3 (patch)
tree0b9ddf5c2e51d3c7ffde16c9869714d8ec47bbd1 /crates/hir_ty/src/diagnostics.rs
parentf8009666beaedb34197da9c87cc54d8ca65203b8 (diff)
internal: move missing unsafe diagnostic to hir
Diffstat (limited to 'crates/hir_ty/src/diagnostics.rs')
-rw-r--r--crates/hir_ty/src/diagnostics.rs31
1 files changed, 4 insertions, 27 deletions
diff --git a/crates/hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs
index 28d6ca567..12131d9bc 100644
--- a/crates/hir_ty/src/diagnostics.rs
+++ b/crates/hir_ty/src/diagnostics.rs
@@ -17,7 +17,10 @@ use crate::{
17 diagnostics_sink::{Diagnostic, DiagnosticCode, DiagnosticSink}, 17 diagnostics_sink::{Diagnostic, DiagnosticCode, DiagnosticSink},
18}; 18};
19 19
20pub use crate::diagnostics::expr::{record_literal_missing_fields, record_pattern_missing_fields}; 20pub use crate::diagnostics::{
21 expr::{record_literal_missing_fields, record_pattern_missing_fields},
22 unsafe_check::missing_unsafe,
23};
21 24
22pub fn validate_module_item( 25pub fn validate_module_item(
23 db: &dyn HirDatabase, 26 db: &dyn HirDatabase,
@@ -35,8 +38,6 @@ pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut Diag
35 let infer = db.infer(owner); 38 let infer = db.infer(owner);
36 let mut validator = expr::ExprValidator::new(owner, infer.clone(), sink); 39 let mut validator = expr::ExprValidator::new(owner, infer.clone(), sink);
37 validator.validate_body(db); 40 validator.validate_body(db);
38 let mut validator = unsafe_check::UnsafeValidator::new(owner, infer, sink);
39 validator.validate_body(db);
40} 41}
41 42
42// Diagnostic: missing-structure-fields 43// Diagnostic: missing-structure-fields
@@ -219,30 +220,6 @@ impl Diagnostic for RemoveThisSemicolon {
219 } 220 }
220} 221}
221 222
222// Diagnostic: missing-unsafe
223//
224// This diagnostic is triggered if an operation marked as `unsafe` is used outside of an `unsafe` function or block.
225#[derive(Debug)]
226pub struct MissingUnsafe {
227 pub file: HirFileId,
228 pub expr: AstPtr<ast::Expr>,
229}
230
231impl Diagnostic for MissingUnsafe {
232 fn code(&self) -> DiagnosticCode {
233 DiagnosticCode("missing-unsafe")
234 }
235 fn message(&self) -> String {
236 format!("This operation is unsafe and requires an unsafe function or block")
237 }
238 fn display_source(&self) -> InFile<SyntaxNodePtr> {
239 InFile { file_id: self.file, value: self.expr.clone().into() }
240 }
241 fn as_any(&self) -> &(dyn Any + Send + 'static) {
242 self
243 }
244}
245
246// Diagnostic: mismatched-arg-count 223// Diagnostic: mismatched-arg-count
247// 224//
248// This diagnostic is triggered if a function is invoked with an incorrect amount of arguments. 225// This diagnostic is triggered if a function is invoked with an incorrect amount of arguments.