Skip to content

Commit 2e19c48

Browse files
authored
Rollup merge of rust-lang#80491 - RalfJung:dangling-of-val, r=oli-obk
Miri: make size/align_of_val work for dangling raw ptrs This is needed for rust-lang#80365 (comment). r? `@oli-obk`
2 parents be6d6e4 + 36c7d6d commit 2e19c48

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/mem/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
379379
/// ```
380380
#[inline]
381381
#[unstable(feature = "layout_for_ptr", issue = "69835")]
382-
pub unsafe fn size_of_val_raw<T: ?Sized>(val: *const T) -> usize {
382+
#[rustc_const_unstable(feature = "const_size_of_val_raw", issue = "46571")]
383+
pub const unsafe fn size_of_val_raw<T: ?Sized>(val: *const T) -> usize {
383384
intrinsics::size_of_val(val)
384385
}
385386

@@ -510,7 +511,8 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
510511
/// ```
511512
#[inline]
512513
#[unstable(feature = "layout_for_ptr", issue = "69835")]
513-
pub unsafe fn align_of_val_raw<T: ?Sized>(val: *const T) -> usize {
514+
#[rustc_const_unstable(feature = "const_align_of_val_raw", issue = "46571")]
515+
pub const unsafe fn align_of_val_raw<T: ?Sized>(val: *const T) -> usize {
514516
intrinsics::min_align_of_val(val)
515517
}
516518

0 commit comments

Comments
 (0)