1
Fork 0

Stabilize const_fn_union

This commit is contained in:
Jacob Pratt 2021-06-03 02:16:56 -04:00
parent 36f02f3523
commit 7bf791d162
No known key found for this signature in database
GPG key ID: B80E19E4662B5AA4
6 changed files with 5 additions and 33 deletions

View file

@ -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(_) => {}
}
}

View file

@ -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::*;