about summary refs log tree commit diff
path: root/compiler/rustc_mir_build
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2022-05-09 17:47:02 +0200
committerlcnr <rust@lcnr.de>2022-05-09 18:40:18 +0200
commit32b13ac9280d15273ef17ee474c0f0a738bb5f5a (patch)
tree5275e02b4329ea296b542fba2eabea9acbd12542 /compiler/rustc_mir_build
parentd371ebe117419b9815bd8743f981d8fa67a876d8 (diff)
downloadrust-32b13ac9280d15273ef17ee474c0f0a738bb5f5a.tar.gz
rust-32b13ac9280d15273ef17ee474c0f0a738bb5f5a.zip
review
Diffstat (limited to 'compiler/rustc_mir_build')
-rw-r--r--compiler/rustc_mir_build/src/check_unsafety.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs
index b90eecefc0c..6c14f207a7d 100644
--- a/compiler/rustc_mir_build/src/check_unsafety.rs
+++ b/compiler/rustc_mir_build/src/check_unsafety.rs
@@ -643,9 +643,8 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD
         return;
     }
 
-    let (thir, expr) = match tcx.thir_body(def) {
-        Ok(body) => body,
-        Err(_) => return,
+    let Ok((thir, expr)) = tcx.thir_body(def) else {
+        return
     };
     let thir = &thir.borrow();
     // If `thir` is empty, a type error occurred, skip this body.
@@ -661,11 +660,7 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD
             BodyUnsafety::Safe
         }
     });
-    let body_target_features: &[_] = if tcx.has_codegen_attrs(tcx.def_kind(def.did)) {
-        &tcx.codegen_fn_attrs(def.did).target_features
-    } else {
-        &[]
-    };
+    let body_target_features = &tcx.body_codegen_attrs(def.did.to_def_id()).target_features;
     let safety_context =
         if body_unsafety.is_unsafe() { SafetyContext::UnsafeFn } else { SafetyContext::Safe };
     let mut visitor = UnsafetyVisitor {