]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir/src/transform/check_unsafety.rs
Remove some last remants of {push,pop}_unsafe!
[rust.git] / compiler / rustc_mir / src / transform / check_unsafety.rs
index 955be8cc81e18285502b650f541130e7db5375b6..324a5257f5dfa446a261824b4a3870d03189a1c4 100644 (file)
@@ -221,7 +221,7 @@ fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location:
             }
 
             let base_ty = base.ty(self.body, self.tcx).ty;
-            if base_ty.ty_adt_def().map_or(false, |adt| adt.is_union()) {
+            if base_ty.is_union() {
                 // If we did not hit a `Deref` yet and the overall place use is an assignment, the
                 // rules are different.
                 let assign_to_field = !saw_deref
@@ -321,7 +321,6 @@ fn register_violations(
                 }
                 false
             }
-            Safety::BuiltinUnsafe => true,
             Safety::ExplicitUnsafe(hir_id) => {
                 // mark unsafe block as used if there are any unsafe operations inside
                 if !violations.is_empty() {
@@ -376,6 +375,12 @@ fn check_mut_borrowing_layout_constrained_field(
     /// Checks whether calling `func_did` needs an `unsafe` context or not, i.e. whether
     /// the called function has target features the calling function hasn't.
     fn check_target_features(&mut self, func_did: DefId) {
+        // Unsafety isn't required on wasm targets. For more information see
+        // the corresponding check in typeck/src/collect.rs
+        if self.tcx.sess.target.options.is_like_wasm {
+            return;
+        }
+
         let callee_features = &self.tcx.codegen_fn_attrs(func_did).target_features;
         let self_features = &self.tcx.codegen_fn_attrs(self.body_did).target_features;