File tree Expand file tree Collapse file tree 1 file changed +34
-4
lines changed Expand file tree Collapse file tree 1 file changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,40 @@ struct Foo {
2222
2323fn main ( ) {
2424 unsafe {
25- panic:: catch_unwind ( || mem:: uninitialized :: < !> ( ) ) . is_err ( ) ;
26- panic:: catch_unwind ( || mem:: zeroed :: < !> ( ) ) . is_err ( ) ;
25+ assert_eq ! (
26+ panic:: catch_unwind( || {
27+ mem:: uninitialized:: <!>( )
28+ } ) . err( ) . and_then( |a| a. downcast_ref:: <String >( ) . map( |s| {
29+ s == "Attempted to instantiate uninhabited type ! using mem::uninitialized"
30+ } ) ) ,
31+ Some ( true )
32+ ) ;
2733
28- panic:: catch_unwind ( || mem:: uninitialized :: < Foo > ( ) ) . is_err ( ) ;
29- panic:: catch_unwind ( || mem:: zeroed :: < Foo > ( ) ) . is_err ( ) ;
34+ assert_eq ! (
35+ panic:: catch_unwind( || {
36+ mem:: zeroed:: <!>( )
37+ } ) . err( ) . and_then( |a| a. downcast_ref:: <String >( ) . map( |s| {
38+ s == "Attempted to instantiate uninhabited type ! using mem::zeroed"
39+ } ) ) ,
40+ Some ( true )
41+ ) ;
42+
43+ assert_eq ! (
44+ panic:: catch_unwind( || {
45+ mem:: uninitialized:: <Foo >( )
46+ } ) . err( ) . and_then( |a| a. downcast_ref:: <String >( ) . map( |s| {
47+ s == "Attempted to instantiate uninhabited type Foo using mem::uninitialized"
48+ } ) ) ,
49+ Some ( true )
50+ ) ;
51+
52+ assert_eq ! (
53+ panic:: catch_unwind( || {
54+ mem:: zeroed:: <Foo >( )
55+ } ) . err( ) . and_then( |a| a. downcast_ref:: <String >( ) . map( |s| {
56+ s == "Attempted to instantiate uninhabited type Foo using mem::zeroed"
57+ } ) ) ,
58+ Some ( true )
59+ ) ;
3060 }
3161}
You can’t perform that action at this time.
0 commit comments