@@ -1023,19 +1023,8 @@ where
10231023 let typing_env = cx. typing_env ( ) ;
10241024
10251025 let pointee_info = match * this. ty . kind ( ) {
1026- ty:: RawPtr ( p_ty, _) if offset. bytes ( ) == 0 => {
1027- tcx. layout_of ( typing_env. as_query_input ( p_ty) ) . ok ( ) . map ( |layout| PointeeInfo {
1028- size : layout. size ,
1029- align : layout. align . abi ,
1030- safe : None ,
1031- } )
1032- }
1033- ty:: FnPtr ( ..) if offset. bytes ( ) == 0 => {
1034- tcx. layout_of ( typing_env. as_query_input ( this. ty ) ) . ok ( ) . map ( |layout| PointeeInfo {
1035- size : layout. size ,
1036- align : layout. align . abi ,
1037- safe : None ,
1038- } )
1026+ ty:: RawPtr ( _, _) | ty:: FnPtr ( ..) if offset. bytes ( ) == 0 => {
1027+ Some ( PointeeInfo { size : Size :: ZERO , align : None , safe : None } )
10391028 }
10401029 ty:: Ref ( _, ty, mt) if offset. bytes ( ) == 0 => {
10411030 // Use conservative pointer kind if not optimizing. This saves us the
@@ -1055,15 +1044,23 @@ where
10551044
10561045 tcx. layout_of ( typing_env. as_query_input ( ty) ) . ok ( ) . map ( |layout| PointeeInfo {
10571046 size : layout. size ,
1058- align : layout. align . abi ,
1047+ align : Some ( layout. align . abi ) ,
10591048 safe : Some ( kind) ,
10601049 } )
10611050 }
10621051
10631052 ty:: Adt ( adt_def, ..) if adt_def. is_maybe_dangling ( ) => {
1064- // FIXME: what is the exact effect of maybe dangling?
1065- Self :: ty_and_layout_pointee_info_at ( this. field ( cx, 0 ) , cx, offset)
1066- . map ( |info| PointeeInfo { safe : None , ..info } )
1053+ Self :: ty_and_layout_pointee_info_at ( this. field ( cx, 0 ) , cx, offset) . map ( |info| {
1054+ PointeeInfo {
1055+ // Downgrade references to pointers (in llvm this strips noalias)
1056+ safe : None ,
1057+ // Make sure we don't assert dereferenceability of the pointer.
1058+ // That is also implied by `safe: None`, but set this explicitly to be sure.
1059+ size : Size :: ZERO ,
1060+ // Keep the alignment info
1061+ align : info. align ,
1062+ }
1063+ } )
10671064 }
10681065
10691066 _ => {
0 commit comments