@@ -9,7 +9,7 @@ use rustc_middle::mir;
99use rustc_middle:: mir:: tcx:: PlaceTy ;
1010use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , TyAndLayout } ;
1111use 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 } ;
1313use rustc_target:: abi:: { VariantIdx , Variants } ;
1414
1515#[ derive( Copy , Clone , Debug ) ]
@@ -102,34 +102,10 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
102102 // `simple` is called when we don't need to adjust the offset to
103103 // the dynamic alignment of the field.
104104 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 ( ) ) ] )
133109 } ;
134110 PlaceRef {
135111 llval,
0 commit comments