Skip to content

Commit ab4a80e

Browse files
committed
Adjust docs on old might_permit_raw_init, cleanup
1 parent c84cfa4 commit ab4a80e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
549549
use AssertIntrinsic::*;
550550
let ty = instance.unwrap().substs.type_at(0);
551551
let layout = bx.layout_of(ty);
552-
let do_panic = match &intrinsic {
552+
let do_panic = match intrinsic {
553553
Inhabited => layout.abi.is_uninhabited(),
554554
ZeroValid => !rustc_const_eval::might_permit_raw_init(
555555
bx.tcx(),

compiler/rustc_target/src/abi/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,13 +1487,17 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
14871487
///
14881488
/// `init_kind` indicates if the memory is zero-initialized or left uninitialized.
14891489
///
1490-
/// `strict` is an opt-in debugging flag added in #97323 that enables more checks.
1490+
/// This code is intentionally conservative, and will not detect
1491+
/// * zero init of an enum whose 0 variant does not allow zero initialization
1492+
/// * making uninitialized types who have a full valid range (ints, floats, raw pointers)
1493+
/// * Any form of invalid value being made inside an array (unless the value is uninhabited)
14911494
///
1492-
/// This is conservative: in doubt, it will answer `true`.
1495+
/// A strict form of these checks that uses const evaluation exists in
1496+
/// [`rustc_const_eval::might_permit_raw_init`], and a tracking issue for making these checks
1497+
/// stricter is <https://github.com/rust-lang/rust/issues/66151>.
14931498
///
1494-
/// FIXME: Once we removed all the conservatism, we could alternatively
1495-
/// create an all-0/all-undef constant and run the const value validator to see if
1496-
/// this is a valid value for the given type.
1499+
/// FIXME: Once all the conservatism is removed from here, and the checks are ran by default,
1500+
/// we can use the const evaluation checks always instead.
14971501
pub fn might_permit_raw_init<C>(self, cx: &C, init_kind: InitKind) -> bool
14981502
where
14991503
Self: Copy,

0 commit comments

Comments
 (0)