Skip to content

Commit cb0d15b

Browse files
committed
test const size_of_val_raw on big value
1 parent a417911 commit cb0d15b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/test/ui/consts/const-size_of_val-align_of_val.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
#![feature(const_size_of_val, const_align_of_val)]
44
#![feature(const_size_of_val_raw, const_align_of_val_raw, layout_for_ptr)]
5+
#![feature(const_slice_from_raw_parts)]
56

6-
use std::mem;
7+
use std::{mem, ptr};
78

89
struct Foo(u32);
910

@@ -34,6 +35,8 @@ const ALIGN_OF_UGH: usize = mem::align_of_val(&UGH);
3435
const SIZE_OF_SLICE: usize = mem::size_of_val("foobar".as_bytes());
3536

3637
const SIZE_OF_DANGLING: usize = unsafe { mem::size_of_val_raw(0x100 as *const i32) };
38+
const SIZE_OF_BIG: usize =
39+
unsafe { mem::size_of_val_raw(ptr::slice_from_raw_parts(0 as *const u8, isize::MAX as usize)) };
3740
const ALIGN_OF_DANGLING: usize = unsafe { mem::align_of_val_raw(0x100 as *const i16) };
3841

3942
fn main() {
@@ -46,6 +49,7 @@ fn main() {
4649
assert_eq!(ALIGN_OF_UGH, mem::align_of::<Ugh>());
4750

4851
assert_eq!(SIZE_OF_DANGLING, mem::size_of::<i32>());
52+
assert_eq!(SIZE_OF_BIG, isize::MAX as usize);
4953
assert_eq!(ALIGN_OF_DANGLING, mem::align_of::<i16>());
5054

5155
assert_eq!(SIZE_OF_SLICE, "foobar".len());

0 commit comments

Comments
 (0)