Skip to content

Commit

Permalink
Add the proper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiangfei2009 committed Jul 31, 2020
1 parent 4631579 commit c511454
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/test/ui/statics/static-promotion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@ struct A<T: 'static>(&'static T);
struct B<T: 'static + ?Sized> {
x: &'static T,
}
static STR: &'static [u8] = b"hi";
static C: A<B<B<[u8]>>> = {
A(&B {
x: &B { x: b"hi" as &[u8] },
x: &B { x: STR },
})
};

pub struct Slice(&'static [i32]);

static CONTENT: i32 = 42;
pub static CONTENT_MAP: Slice = Slice(&[CONTENT]);

pub static FOO: (i32, i32) = (42, 43);
pub static CONTENT_MAP2: Slice = Slice(&[FOO.0]);

fn main() {
assert_eq!(b"hi", C.0.x.x);
assert_eq!(&[42], CONTENT_MAP.0);
assert_eq!(&[42], CONTENT_MAP2.0);
}

0 comments on commit c511454

Please sign in to comment.