@@ -9,7 +9,7 @@ use rustc_middle::mir;
9
9
use rustc_middle:: mir:: tcx:: PlaceTy ;
10
10
use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , TyAndLayout } ;
11
11
use rustc_middle:: ty:: { self , Ty } ;
12
- use rustc_target:: abi:: { Abi , Align , FieldsShape , Int , Pointer , TagEncoding } ;
12
+ use rustc_target:: abi:: { Align , FieldsShape , Int , Pointer , TagEncoding } ;
13
13
use rustc_target:: abi:: { VariantIdx , Variants } ;
14
14
15
15
#[ derive( Copy , Clone , Debug ) ]
@@ -102,34 +102,10 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
102
102
// `simple` is called when we don't need to adjust the offset to
103
103
// the dynamic alignment of the field.
104
104
let mut simple = || {
105
- let llval = match self . layout . abi {
106
- _ if offset. bytes ( ) == 0 => {
107
- // Unions and newtypes only use an offset of 0.
108
- // Also handles the first field of Scalar, ScalarPair, and Vector layouts.
109
- self . llval
110
- }
111
- Abi :: ScalarPair ( ..) => {
112
- // FIXME(nikic): Generate this for all ABIs.
113
- bx. inbounds_gep ( bx. type_i8 ( ) , self . llval , & [ bx. const_usize ( offset. bytes ( ) ) ] )
114
- }
115
- Abi :: Scalar ( _) | Abi :: Vector { .. } if field. is_zst ( ) => {
116
- // ZST fields (even some that require alignment) are not included in Scalar,
117
- // ScalarPair, and Vector layouts, so manually offset the pointer.
118
- bx. gep ( bx. cx ( ) . type_i8 ( ) , self . llval , & [ bx. const_usize ( offset. bytes ( ) ) ] )
119
- }
120
- Abi :: Scalar ( _) => {
121
- // All fields of Scalar layouts must have been handled by this point.
122
- // Vector layouts have additional fields for each element of the vector, so don't panic in that case.
123
- bug ! (
124
- "offset of non-ZST field `{:?}` does not match layout `{:#?}`" ,
125
- field,
126
- self . layout
127
- ) ;
128
- }
129
- _ => {
130
- let ty = bx. backend_type ( self . layout ) ;
131
- bx. struct_gep ( ty, self . llval , bx. cx ( ) . backend_field_index ( self . layout , ix) )
132
- }
105
+ let llval = if offset. bytes ( ) == 0 {
106
+ self . llval
107
+ } else {
108
+ bx. inbounds_gep ( bx. type_i8 ( ) , self . llval , & [ bx. const_usize ( offset. bytes ( ) ) ] )
133
109
} ;
134
110
PlaceRef {
135
111
llval,
0 commit comments