@@ -168,12 +168,6 @@ pub fn unsize_thin_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
168
168
let ptr_ty = bx. cx ( ) . type_ptr_to ( bx. cx ( ) . backend_type ( bx. cx ( ) . layout_of ( b) ) ) ;
169
169
( bx. pointercast ( src, ptr_ty) , unsized_info ( bx. cx ( ) , a, b, None ) )
170
170
}
171
- ( & ty:: Adt ( def_a, _) , & ty:: Adt ( def_b, _) ) if def_a. is_box ( ) && def_b. is_box ( ) => {
172
- let ( a, b) = ( src_ty. boxed_ty ( ) , dst_ty. boxed_ty ( ) ) ;
173
- assert ! ( bx. cx( ) . type_is_sized( a) ) ;
174
- let ptr_ty = bx. cx ( ) . type_ptr_to ( bx. cx ( ) . backend_type ( bx. cx ( ) . layout_of ( b) ) ) ;
175
- ( bx. pointercast ( src, ptr_ty) , unsized_info ( bx. cx ( ) , a, b, None ) )
176
- }
177
171
( & ty:: Adt ( def_a, _) , & ty:: Adt ( def_b, _) ) => {
178
172
assert_eq ! ( def_a, def_b) ;
179
173
@@ -196,6 +190,8 @@ pub fn unsize_thin_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
196
190
}
197
191
let ( lldata, llextra) = result. unwrap ( ) ;
198
192
// HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
193
+ // FIXME(eddyb) move these out of this `match` arm, so they're always
194
+ // applied, uniformly, no matter the source/destination types.
199
195
( bx. bitcast ( lldata, bx. cx ( ) . scalar_pair_element_backend_type ( dst_layout, 0 , true ) ) ,
200
196
bx. bitcast ( llextra, bx. cx ( ) . scalar_pair_element_backend_type ( dst_layout, 1 , true ) ) )
201
197
}
@@ -212,31 +208,27 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
212
208
) {
213
209
let src_ty = src. layout . ty ;
214
210
let dst_ty = dst. layout . ty ;
215
- let mut coerce_ptr = || {
216
- let ( base, info) = match bx. load_operand ( src) . val {
217
- OperandValue :: Pair ( base, info) => {
218
- // fat-ptr to fat-ptr unsize preserves the vtable
219
- // i.e., &'a fmt::Debug+Send => &'a fmt::Debug
220
- // So we need to pointercast the base to ensure
221
- // the types match up.
222
- let thin_ptr = dst. layout . field ( bx. cx ( ) , FAT_PTR_ADDR ) ;
223
- ( bx. pointercast ( base, bx. cx ( ) . backend_type ( thin_ptr) ) , info)
224
- }
225
- OperandValue :: Immediate ( base) => {
226
- unsize_thin_ptr ( bx, base, src_ty, dst_ty)
227
- }
228
- OperandValue :: Ref ( ..) => bug ! ( )
229
- } ;
230
- OperandValue :: Pair ( base, info) . store ( bx, dst) ;
231
- } ;
232
211
match ( & src_ty. kind , & dst_ty. kind ) {
233
212
( & ty:: Ref ( ..) , & ty:: Ref ( ..) ) |
234
213
( & ty:: Ref ( ..) , & ty:: RawPtr ( ..) ) |
235
214
( & ty:: RawPtr ( ..) , & ty:: RawPtr ( ..) ) => {
236
- coerce_ptr ( )
237
- }
238
- ( & ty:: Adt ( def_a, _) , & ty:: Adt ( def_b, _) ) if def_a. is_box ( ) && def_b. is_box ( ) => {
239
- coerce_ptr ( )
215
+ let ( base, info) = match bx. load_operand ( src) . val {
216
+ OperandValue :: Pair ( base, info) => {
217
+ // fat-ptr to fat-ptr unsize preserves the vtable
218
+ // i.e., &'a fmt::Debug+Send => &'a fmt::Debug
219
+ // So we need to pointercast the base to ensure
220
+ // the types match up.
221
+ // FIXME(eddyb) use `scalar_pair_element_backend_type` here,
222
+ // like `unsize_thin_ptr` does.
223
+ let thin_ptr = dst. layout . field ( bx. cx ( ) , FAT_PTR_ADDR ) ;
224
+ ( bx. pointercast ( base, bx. cx ( ) . backend_type ( thin_ptr) ) , info)
225
+ }
226
+ OperandValue :: Immediate ( base) => {
227
+ unsize_thin_ptr ( bx, base, src_ty, dst_ty)
228
+ }
229
+ OperandValue :: Ref ( ..) => bug ! ( )
230
+ } ;
231
+ OperandValue :: Pair ( base, info) . store ( bx, dst) ;
240
232
}
241
233
242
234
( & ty:: Adt ( def_a, _) , & ty:: Adt ( def_b, _) ) => {
0 commit comments