@@ -3496,6 +3496,9 @@ fn make_thin_self_ptr<'tcx>(
34963496/// Determines if this type permits "raw" initialization by just transmuting some
34973497/// memory into an instance of `T`.
34983498///
3499+ /// If called with InitKind::Uninit, this function must always panic if a 0x01 filled buffer would
3500+ /// cause LLVM UB.
3501+ ///
34993502/// This code is intentionally conservative, and will not detect
35003503/// * making uninitialized types who have a full valid range (ints, floats, raw pointers)
35013504/// * uninit `&T` where T has align 1 size 0 (only inside arrays).
@@ -3547,11 +3550,18 @@ where
35473550 // See: https://github.com/rust-lang/rust/pull/99389
35483551 if inside_array {
35493552 match init_kind {
3550- // FIXME(#66151) We need to ignore uninit references with an alignment of 1 and
3551- // size 0
3552- // (as in, &[u8] and &str)
3553- // Since if we do not, old versions of `hyper` with no semver compatible fix
3554- // (0.11, 0.12, 0.13) break.
3553+ // We panic if creating this type with all 0x01 bytes would
3554+ // cause LLVM UB.
3555+ //
3556+ // Therefore, in order for us to not panic,
3557+ // * the alignment of the pointer must be 1
3558+ // (or we would have an unaligned pointer)
3559+ //
3560+ // * the statically known size of the pointee must be 0.
3561+ // (or we would emit dereferenceable)
3562+ //
3563+ // If this bypass didn't exist, old versions of `hyper` with no semver compatible
3564+ // fix (0.11, 0.12, 0.13) would panic, as they make uninit &[u8] and &str.
35553565 InitKind :: Uninit => {
35563566 if let ty:: Ref ( _, inner, _) = this. ty . kind ( ) {
35573567 let penv = ty:: ParamEnv :: reveal_all ( ) . and ( * inner) ;
0 commit comments