From c5114549d74f6092517af6ea630ec5a26317ae93 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Fri, 31 Jul 2020 18:04:13 +0800 Subject: [PATCH] Add the proper tests --- src/test/ui/statics/static-promotion.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/ui/statics/static-promotion.rs b/src/test/ui/statics/static-promotion.rs index 500af1e15e12..bd8910bdb3f3 100644 --- a/src/test/ui/statics/static-promotion.rs +++ b/src/test/ui/statics/static-promotion.rs @@ -12,12 +12,23 @@ struct A(&'static T); struct B { x: &'static T, } +static STR: &'static [u8] = b"hi"; static C: A>> = { 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); }