make it even more conservative, and note some FIXMEs
This commit is contained in:
parent
df6a3a0ed2
commit
b133d6776f
@ -526,6 +526,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum PanicIntrinsic { IfUninhabited, IfZeroInvalid, IfAnyInvalid };
|
||||
let panic_intrinsic = intrinsic.and_then(|i| match i {
|
||||
// FIXME: Move to symbols instead of strings.
|
||||
"panic_if_uninhabited" => Some(PanicIntrinsic::IfUninhabited),
|
||||
"panic_if_zero_invalid" => Some(PanicIntrinsic::IfZeroInvalid),
|
||||
"panic_if_any_invalid" => Some(PanicIntrinsic::IfAnyInvalid),
|
||||
@ -555,6 +556,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
let location = self.get_caller_location(&mut bx, span).immediate();
|
||||
|
||||
// Obtain the panic entry point.
|
||||
// FIXME: dedup this with `codegen_assert_terminator` above.
|
||||
let def_id =
|
||||
common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem);
|
||||
let instance = ty::Instance::mono(bx.tcx(), def_id);
|
||||
|
@ -1043,6 +1043,10 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
/// `zero` indicates if the memory is zero-initialized, or alternatively
|
||||
/// left entirely uninitialized.
|
||||
/// This is conservative: in doubt, it will answer `true`.
|
||||
///
|
||||
/// FIXME: Once we removed all the conservatism, we could alternatively
|
||||
/// create an all-0/all-undef constant and run the vonst value validator to see if
|
||||
/// this is a valid value for the given type.
|
||||
pub fn might_permit_raw_init<C, E>(
|
||||
self,
|
||||
cx: &C,
|
||||
@ -1095,11 +1099,14 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
FieldPlacement::Array { .. } =>
|
||||
// FIXME(#66151): The widely use smallvec 0.6 creates uninit arrays
|
||||
// with any element type, so let us not (yet) complain about that.
|
||||
// count == 0 ||
|
||||
// self.field(cx, 0).to_result()?.might_permit_raw_init(cx, zero)?
|
||||
/* count == 0 ||
|
||||
self.field(cx, 0).to_result()?.might_permit_raw_init(cx, zero)? */
|
||||
true,
|
||||
FieldPlacement::Arbitrary { ref offsets, .. } => {
|
||||
let mut res = true;
|
||||
FieldPlacement::Arbitrary { .. } => {
|
||||
// FIXME(#66151) cargo depends on sized-chunks 0.3.0 which
|
||||
// has some illegal zero-initialization, so let us not (yet)
|
||||
// complain about aggregates either.
|
||||
/* let mut res = true;
|
||||
// Check that all fields accept zero-init.
|
||||
for idx in 0..offsets.len() {
|
||||
let field = self.field(cx, idx).to_result()?;
|
||||
@ -1108,7 +1115,8 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
res
|
||||
res */
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ fn main() {
|
||||
"attempted to zero-initialize type `*const dyn std::marker::Send`, which is invalid"
|
||||
);
|
||||
|
||||
/* FIXME(#66151) we conservatively do not error here yet.
|
||||
test_panic_msg(
|
||||
|| mem::uninitialized::<(NonNull<u32>, u32, u32)>(),
|
||||
"attempted to leave type `(std::ptr::NonNull<u32>, u32, u32)` uninitialized, \
|
||||
@ -102,6 +103,7 @@ fn main() {
|
||||
"attempted to zero-initialize type `(std::ptr::NonNull<u32>, u32, u32)`, \
|
||||
which is invalid"
|
||||
);
|
||||
*/
|
||||
|
||||
test_panic_msg(
|
||||
|| mem::uninitialized::<bool>(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user