@@ -96,7 +96,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
9696 let llval = match self . layout . abi {
9797 _ if offset. bytes ( ) == 0 => {
9898 // Unions and newtypes only use an offset of 0.
99- // Also handles the first field of Scalar and ScalarPair layouts.
99+ // Also handles the first field of Scalar, ScalarPair, and Vector layouts.
100100 self . llval
101101 }
102102 Abi :: ScalarPair ( ref a, ref b)
@@ -105,16 +105,20 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
105105 // Offset matches second field.
106106 bx. struct_gep ( self . llval , 1 )
107107 }
108- Abi :: ScalarPair ( ..) | Abi :: Scalar ( _) => {
109- // ZST fields are not included in Scalar and ScalarPair layouts, so manually offset the pointer.
110- assert ! (
111- field. is_zst( ) ,
112- "non-ZST field offset does not match layout: {:?}" ,
113- field
114- ) ;
108+ Abi :: Scalar ( _) | Abi :: ScalarPair ( ..) | Abi :: Vector { .. } if field. is_zst ( ) => {
109+ // ZST fields are not included in Scalar, ScalarPair, and Vector layouts, so manually offset the pointer.
115110 let byte_ptr = bx. pointercast ( self . llval , bx. cx ( ) . type_i8p ( ) ) ;
116111 bx. gep ( byte_ptr, & [ bx. const_usize ( offset. bytes ( ) ) ] )
117112 }
113+ Abi :: Scalar ( _) | Abi :: ScalarPair ( ..) => {
114+ // All fields of Scalar and ScalarPair layouts must have been handled by this point.
115+ // Vector layouts have additional fields for each element of the vector, so don't panic in that case.
116+ bug ! (
117+ "offset of non-ZST field `{:?}` does not match layout `{:#?}`" ,
118+ field,
119+ self . layout
120+ ) ;
121+ }
118122 _ => bx. struct_gep ( self . llval , bx. cx ( ) . backend_field_index ( self . layout , ix) ) ,
119123 } ;
120124 PlaceRef {
0 commit comments