@@ -16,6 +16,10 @@ trait Foo {
1616 fn foo ( self : * const Self ) -> & ' static str ;
1717
1818 unsafe fn bar ( self : * const Self ) -> i64 ;
19+
20+ unsafe fn complicated ( self : * const * const Self ) -> i64 where Self : Sized {
21+ ( * self ) . bar ( )
22+ }
1923}
2024
2125impl Foo for i32 {
@@ -39,21 +43,28 @@ impl Foo for u32 {
3943}
4044
4145fn main ( ) {
42- let foo_i32 = ptr:: null :: < i32 > ( ) as * const Foo ;
43- let foo_u32 = ptr:: null :: < u32 > ( ) as * const Foo ;
46+ let null_i32 = ptr:: null :: < i32 > ( ) as * const Foo ;
47+ let null_u32 = ptr:: null :: < u32 > ( ) as * const Foo ;
4448
45- assert_eq ! ( "I'm an i32!" , foo_i32 . foo( ) ) ;
46- assert_eq ! ( "I'm a u32!" , foo_u32 . foo( ) ) ;
49+ assert_eq ! ( "I'm an i32!" , null_i32 . foo( ) ) ;
50+ assert_eq ! ( "I'm a u32!" , null_u32 . foo( ) ) ;
4751
4852 let bar_i32 = 5i32 ;
4953 let bar_i32_thin = & bar_i32 as * const i32 ;
54+ assert_eq ! ( "I'm an i32!" , bar_i32_thin. foo( ) ) ;
5055 assert_eq ! ( 5 , unsafe { bar_i32_thin. bar( ) } ) ;
56+ assert_eq ! ( 5 , unsafe { ( & bar_i32_thin as * const * const i32 ) . complicated( ) } ) ;
5157 let bar_i32_fat = bar_i32_thin as * const Foo ;
58+ assert_eq ! ( "I'm an i32!" , bar_i32_fat. foo( ) ) ;
5259 assert_eq ! ( 5 , unsafe { bar_i32_fat. bar( ) } ) ;
5360
5461 let bar_u32 = 18u32 ;
5562 let bar_u32_thin = & bar_u32 as * const u32 ;
63+ assert_eq ! ( "I'm a u32!" , bar_u32_thin. foo( ) ) ;
5664 assert_eq ! ( 18 , unsafe { bar_u32_thin. bar( ) } ) ;
65+ assert_eq ! ( 18 , unsafe { ( & bar_u32_thin as * const * const u32 ) . complicated( ) } ) ;
5766 let bar_u32_fat = bar_u32_thin as * const Foo ;
67+ assert_eq ! ( "I'm a u32!" , bar_u32_fat. foo( ) ) ;
5868 assert_eq ! ( 18 , unsafe { bar_u32_fat. bar( ) } ) ;
69+
5970}
0 commit comments