Skip to content

Commit 1ea88a8

Browse files
committed
Add tests
1 parent ab949fd commit 1ea88a8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// run-pass
2+
3+
#[repr(align(4))]
4+
struct Foo;
5+
6+
static FOO: Foo = Foo;
7+
8+
fn main() {
9+
let x: &'static () = &();
10+
assert_eq!(x as *const () as usize, 1);
11+
let x: &'static Foo = &Foo;
12+
assert_eq!(x as *const Foo as usize, 4);
13+
14+
// statics must have a unique address
15+
assert_ne!(&FOO as *const Foo as usize, 4);
16+
17+
assert_eq!(<Vec<i32>>::new().as_ptr(), <&[i32]>::default().as_ptr());
18+
assert_eq!(<Box<[i32]>>::default().as_ptr(), (&[]).as_ptr());
19+
}

0 commit comments

Comments
 (0)