66#![ feature( never_type) ]
77#![ allow( deprecated, invalid_value) ]
88
9- use std:: { mem, panic} ;
10- use std:: ptr:: NonNull ;
9+ use std:: {
10+ mem:: { self , MaybeUninit } ,
11+ panic,
12+ ptr:: NonNull ,
13+ } ;
1114
1215#[ allow( dead_code) ]
1316struct Foo {
@@ -40,7 +43,7 @@ fn main() {
4043 "attempted to instantiate uninhabited type `!`"
4144 ) ;
4245 test_panic_msg (
43- || mem :: MaybeUninit :: < !> :: uninit ( ) . assume_init ( ) ,
46+ || MaybeUninit :: < !> :: uninit ( ) . assume_init ( ) ,
4447 "attempted to instantiate uninhabited type `!`"
4548 ) ;
4649
@@ -53,7 +56,7 @@ fn main() {
5356 "attempted to instantiate uninhabited type `Foo`"
5457 ) ;
5558 test_panic_msg (
56- || mem :: MaybeUninit :: < Foo > :: uninit ( ) . assume_init ( ) ,
59+ || MaybeUninit :: < Foo > :: uninit ( ) . assume_init ( ) ,
5760 "attempted to instantiate uninhabited type `Foo`"
5861 ) ;
5962
@@ -66,7 +69,7 @@ fn main() {
6669 "attempted to instantiate uninhabited type `Bar`"
6770 ) ;
6871 test_panic_msg (
69- || mem :: MaybeUninit :: < Bar > :: uninit ( ) . assume_init ( ) ,
72+ || MaybeUninit :: < Bar > :: uninit ( ) . assume_init ( ) ,
7073 "attempted to instantiate uninhabited type `Bar`"
7174 ) ;
7275
@@ -109,5 +112,11 @@ fn main() {
109112 let _val = mem:: zeroed :: < bool > ( ) ;
110113 let _val = mem:: zeroed :: < OneVariant > ( ) ;
111114 let _val = mem:: zeroed :: < Option < & ' static i32 > > ( ) ;
115+ let _val = mem:: zeroed :: < MaybeUninit < NonNull < u32 > > > ( ) ;
116+ let _val = mem:: uninitialized :: < MaybeUninit < bool > > ( ) ;
117+
118+ // We don't panic for these just to be conservative. They are UB as of now (2019-11-09).
119+ let _val = mem:: uninitialized :: < i32 > ( ) ;
120+ let _val = mem:: uninitialized :: < * const ( ) > ( ) ;
112121 }
113122}
0 commit comments