about summary refs log tree commit diff
path: root/compiler/rustc_mir
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2021-06-03 02:16:56 -0400
committerJacob Pratt <jacob@jhpratt.dev>2021-07-27 16:03:33 -0400
commit7bf791d162705447b97819c16d286dec2a3f34f1 (patch)
tree1abc5e1bd9283ff169896d964ff72213b921964e /compiler/rustc_mir
parent36f02f352392f216d778808818d0e4ed56714f3c (diff)
downloadrust-7bf791d162705447b97819c16d286dec2a3f34f1.tar.gz
rust-7bf791d162705447b97819c16d286dec2a3f34f1.zip
Stabilize `const_fn_union`
Diffstat (limited to 'compiler/rustc_mir')
-rw-r--r--compiler/rustc_mir/src/transform/check_consts/check.rs7
-rw-r--r--compiler/rustc_mir/src/transform/check_consts/ops.rs22
2 files changed, 1 insertions, 28 deletions
diff --git a/compiler/rustc_mir/src/transform/check_consts/check.rs b/compiler/rustc_mir/src/transform/check_consts/check.rs
index 106b7e67776..109da59aa43 100644
--- a/compiler/rustc_mir/src/transform/check_consts/check.rs
+++ b/compiler/rustc_mir/src/transform/check_consts/check.rs
@@ -748,12 +748,7 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
             | ProjectionElem::Downcast(..)
             | ProjectionElem::Subslice { .. }
             | ProjectionElem::Field(..)
-            | ProjectionElem::Index(_) => {
-                let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty;
-                if base_ty.is_union() {
-                    self.check_op(ops::UnionAccess);
-                }
-            }
+            | ProjectionElem::Index(_) => {}
         }
     }
 
diff --git a/compiler/rustc_mir/src/transform/check_consts/ops.rs b/compiler/rustc_mir/src/transform/check_consts/ops.rs
index 9a03b5e4867..8de11fda7d7 100644
--- a/compiler/rustc_mir/src/transform/check_consts/ops.rs
+++ b/compiler/rustc_mir/src/transform/check_consts/ops.rs
@@ -501,28 +501,6 @@ impl NonConstOp for ThreadLocalAccess {
     }
 }
 
-#[derive(Debug)]
-pub struct UnionAccess;
-impl NonConstOp for UnionAccess {
-    fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
-        // Union accesses are stable in all contexts except `const fn`.
-        if ccx.const_kind() != hir::ConstContext::ConstFn {
-            Status::Allowed
-        } else {
-            Status::Unstable(sym::const_fn_union)
-        }
-    }
-
-    fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
-        feature_err(
-            &ccx.tcx.sess.parse_sess,
-            sym::const_fn_union,
-            span,
-            "unions in const fn are unstable",
-        )
-    }
-}
-
 // Types that cannot appear in the signature or locals of a `const fn`.
 pub mod ty {
     use super::*;