Skip to content

Commit 4f9fd2a

Browse files
committed
Undo fn -> const fn for all intrinsics but assert_inhabited
1 parent f311db1 commit 4f9fd2a

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

compiler/rustc_mir/src/interpret/intrinsics.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -407,29 +407,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
407407
sym::transmute => {
408408
self.copy_op_transmute(args[0], dest)?;
409409
}
410-
sym::assert_inhabited | sym::assert_zero_valid | sym::assert_uninit_valid => {
410+
sym::assert_inhabited => {
411411
let ty = instance.substs.type_at(0);
412412
let layout = self.layout_of(ty)?;
413413

414414
if layout.abi.is_uninhabited() {
415415
throw_ub_format!("attempted to instantiate uninhabited type `{}`", ty);
416416
}
417-
if intrinsic_name == sym::assert_zero_valid
418-
&& !layout.might_permit_raw_init(self, /*zero:*/ true).unwrap()
419-
{
420-
throw_ub_format!(
421-
"attempted to zero-initialize type `{}`, which is invalid",
422-
ty
423-
);
424-
}
425-
if intrinsic_name == sym::assert_uninit_valid
426-
&& !layout.might_permit_raw_init(self, /*zero:*/ false).unwrap()
427-
{
428-
throw_ub_format!(
429-
"attempted to leave type `{}` uninitialized, which is invalid",
430-
ty
431-
);
432-
}
433417
}
434418
sym::simd_insert => {
435419
let index = u64::from(self.read_scalar(args[1])?.to_u32()?);

library/core/src/intrinsics.rs

-2
Original file line numberDiff line numberDiff line change
@@ -822,14 +822,12 @@ extern "rust-intrinsic" {
822822
/// zero-initialization: This will statically either panic, or do nothing.
823823
///
824824
/// This intrinsic does not have a stable counterpart.
825-
#[rustc_const_unstable(feature = "const_assert_type", issue = "none")]
826825
pub fn assert_zero_valid<T>();
827826

828827
/// A guard for unsafe functions that cannot ever be executed if `T` has invalid
829828
/// bit patterns: This will statically either panic, or do nothing.
830829
///
831830
/// This intrinsic does not have a stable counterpart.
832-
#[rustc_const_unstable(feature = "const_assert_type", issue = "none")]
833831
pub fn assert_uninit_valid<T>();
834832

835833
/// Gets a reference to a static `Location` indicating where it was called.

0 commit comments

Comments
 (0)