Stabilize const_fn_union
This commit is contained in:
parent
36f02f3523
commit
7bf791d162
6 changed files with 5 additions and 33 deletions
|
@ -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(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue