diff options
Diffstat (limited to 'compiler/rustc_mir')
| -rw-r--r-- | compiler/rustc_mir/src/transform/check_consts/check.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/transform/check_consts/ops.rs | 45 |
2 files changed, 1 insertions, 60 deletions
diff --git a/compiler/rustc_mir/src/transform/check_consts/check.rs b/compiler/rustc_mir/src/transform/check_consts/check.rs index cff386f776b..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(_) => {} } } @@ -876,15 +871,6 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> { let is_intrinsic = tcx.fn_sig(callee).abi() == RustIntrinsic; - // HACK: This is to "unstabilize" the `transmute` intrinsic - // within const fns. `transmute` is allowed in all other const contexts. - // This won't really scale to more intrinsics or functions. Let's allow const - // transmutes in const fn before we add more hacks to this. - if is_intrinsic && tcx.item_name(callee) == sym::transmute { - self.check_op(ops::Transmute); - return; - } - if !tcx.is_const_fn_raw(callee) { let mut permitted = false; diff --git a/compiler/rustc_mir/src/transform/check_consts/ops.rs b/compiler/rustc_mir/src/transform/check_consts/ops.rs index fd72ec4340f..8de11fda7d7 100644 --- a/compiler/rustc_mir/src/transform/check_consts/ops.rs +++ b/compiler/rustc_mir/src/transform/check_consts/ops.rs @@ -501,51 +501,6 @@ impl NonConstOp for ThreadLocalAccess { } } -#[derive(Debug)] -pub struct Transmute; -impl NonConstOp for Transmute { - fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status { - if ccx.const_kind() != hir::ConstContext::ConstFn { - Status::Allowed - } else { - Status::Unstable(sym::const_fn_transmute) - } - } - - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { - let mut err = feature_err( - &ccx.tcx.sess.parse_sess, - sym::const_fn_transmute, - span, - &format!("`transmute` is not allowed in {}s", ccx.const_kind()), - ); - err.note("`transmute` is only allowed in constants and statics for now"); - err - } -} - -#[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::*; |
