about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorLeSeulArtichaut <leseulartichaut@gmail.com>2021-05-14 23:19:59 +0200
committerLeSeulArtichaut <leseulartichaut@gmail.com>2021-05-20 00:01:05 +0200
commit27fe959c2c99207828cedfe19dbf96debd3be591 (patch)
tree032331ed30cfa08471cd2a400b3f47fb618dd4a4 /compiler
parentf94942d8421dc4b1da86d07069571ddb43127235 (diff)
downloadrust-27fe959c2c99207828cedfe19dbf96debd3be591.tar.gz
rust-27fe959c2c99207828cedfe19dbf96debd3be591.zip
Check for raw pointer dereference in THIR unsafeck
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_build/src/check_unsafety.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs
index 8c2c81c8628..c1866b9a437 100644
--- a/compiler/rustc_mir_build/src/check_unsafety.rs
+++ b/compiler/rustc_mir_build/src/check_unsafety.rs
@@ -153,6 +153,11 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
             ExprKind::InlineAsm { .. } | ExprKind::LlvmInlineAsm { .. } => {
                 self.requires_unsafe(expr.span, UseOfInlineAssembly);
             }
+            ExprKind::Deref { arg } => {
+                if self.thir[arg].ty.is_unsafe_ptr() {
+                    self.requires_unsafe(expr.span, DerefOfRawPointer);
+                }
+            }
             _ => {}
         }
 
@@ -203,7 +208,6 @@ enum UnsafeOpKind {
     UseOfMutableStatic,
     #[allow(dead_code)] // FIXME
     UseOfExternStatic,
-    #[allow(dead_code)] // FIXME
     DerefOfRawPointer,
     #[allow(dead_code)] // FIXME
     AssignToDroppingUnionField,