Skip to content

Commit c511454

Browse files
Add the proper tests
1 parent 4631579 commit c511454

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/test/ui/statics/static-promotion.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@ struct A<T: 'static>(&'static T);
1212
struct B<T: 'static + ?Sized> {
1313
x: &'static T,
1414
}
15+
static STR: &'static [u8] = b"hi";
1516
static C: A<B<B<[u8]>>> = {
1617
A(&B {
17-
x: &B { x: b"hi" as &[u8] },
18+
x: &B { x: STR },
1819
})
1920
};
2021

22+
pub struct Slice(&'static [i32]);
23+
24+
static CONTENT: i32 = 42;
25+
pub static CONTENT_MAP: Slice = Slice(&[CONTENT]);
26+
27+
pub static FOO: (i32, i32) = (42, 43);
28+
pub static CONTENT_MAP2: Slice = Slice(&[FOO.0]);
29+
2130
fn main() {
2231
assert_eq!(b"hi", C.0.x.x);
32+
assert_eq!(&[42], CONTENT_MAP.0);
33+
assert_eq!(&[42], CONTENT_MAP2.0);
2334
}

0 commit comments

Comments
 (0)