Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/diagnostics/unsafe_check.rs')
-rw-r--r--crates/hir-ty/src/diagnostics/unsafe_check.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/hir-ty/src/diagnostics/unsafe_check.rs b/crates/hir-ty/src/diagnostics/unsafe_check.rs
index f655692429..2aca99c93b 100644
--- a/crates/hir-ty/src/diagnostics/unsafe_check.rs
+++ b/crates/hir-ty/src/diagnostics/unsafe_check.rs
@@ -240,9 +240,15 @@ impl<'a> UnsafeVisitor<'a> {
let inside_assignment = mem::replace(&mut self.inside_assignment, false);
match expr {
&Expr::Call { callee, .. } => {
- if let Some(func) = self.infer[callee].as_fn_def(self.db) {
+ let callee = &self.infer[callee];
+ if let Some(func) = callee.as_fn_def(self.db) {
self.check_call(current, func);
}
+ if let TyKind::Function(fn_ptr) = callee.kind(Interner) {
+ if fn_ptr.sig.safety == chalk_ir::Safety::Unsafe {
+ self.on_unsafe_op(current.into(), UnsafetyReason::UnsafeFnCall);
+ }
+ }
}
Expr::Path(path) => {
let guard =