@@ -96,7 +96,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
96
96
let llval = match self . layout . abi {
97
97
_ if offset. bytes ( ) == 0 => {
98
98
// 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.
100
100
self . llval
101
101
}
102
102
Abi :: ScalarPair ( ref a, ref b)
@@ -105,16 +105,20 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
105
105
// Offset matches second field.
106
106
bx. struct_gep ( self . llval , 1 )
107
107
}
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.
115
110
let byte_ptr = bx. pointercast ( self . llval , bx. cx ( ) . type_i8p ( ) ) ;
116
111
bx. gep ( byte_ptr, & [ bx. const_usize ( offset. bytes ( ) ) ] )
117
112
}
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
+ }
118
122
_ => bx. struct_gep ( self . llval , bx. cx ( ) . backend_field_index ( self . layout , ix) ) ,
119
123
} ;
120
124
PlaceRef {
0 commit comments