@@ -93,27 +93,6 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
93
93
a. repr( self . get_ref( ) . infcx. tcx) ,
94
94
b. repr( self . get_ref( ) . infcx. tcx) ) ;
95
95
96
- // Special case: if the subtype is a sized array literal (`[T, ..n]`),
97
- // then it would get auto-borrowed to `&[T, ..n]` and then DST-ified
98
- // to `&[T]`. Doing it all at once makes the target code a bit more
99
- // efficient and spares us from having to handle multiple coercions.
100
- match ty:: get ( b) . sty {
101
- ty:: ty_ptr( mt_b) | ty:: ty_rptr( _, mt_b) => {
102
- match ty:: get ( mt_b. ty ) . sty {
103
- ty:: ty_vec( _, None ) => {
104
- let unsize_and_ref = self . unpack_actual_value ( a, |sty_a| {
105
- self . coerce_unsized_with_borrow ( a, sty_a, b, mt_b. mutbl )
106
- } ) ;
107
- if unsize_and_ref. is_ok ( ) {
108
- return unsize_and_ref;
109
- }
110
- }
111
- _ => { }
112
- }
113
- }
114
- _ => { }
115
- }
116
-
117
96
// Consider coercing the subtype to a DST
118
97
let unsize = self . unpack_actual_value ( a, |sty_a| {
119
98
self . coerce_unsized ( a, sty_a, b)
@@ -274,35 +253,6 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
274
253
} ) ) )
275
254
}
276
255
277
- // [T, ..n] -> &[T] or &mut [T]
278
- fn coerce_unsized_with_borrow ( & self ,
279
- a : ty:: t ,
280
- sty_a : & ty:: sty ,
281
- b : ty:: t ,
282
- mutbl_b : ast:: Mutability )
283
- -> CoerceResult {
284
- debug ! ( "coerce_unsized_with_borrow(a={}, sty_a={}, b={})" ,
285
- a. repr( self . get_ref( ) . infcx. tcx) , sty_a,
286
- b. repr( self . get_ref( ) . infcx. tcx) ) ;
287
-
288
- match * sty_a {
289
- ty:: ty_vec( t_a, Some ( len) ) => {
290
- let sub = Sub ( self . get_ref ( ) . clone ( ) ) ;
291
- let coercion = Coercion ( self . get_ref ( ) . trace . clone ( ) ) ;
292
- let r_borrow = self . get_ref ( ) . infcx . next_region_var ( coercion) ;
293
- let unsized_ty = ty:: mk_slice ( self . get_ref ( ) . infcx . tcx , r_borrow,
294
- mt { ty : t_a, mutbl : mutbl_b} ) ;
295
- try!( self . get_ref ( ) . infcx . try ( || sub. tys ( unsized_ty, b) ) ) ;
296
- Ok ( Some ( AdjustDerefRef ( AutoDerefRef {
297
- autoderefs : 0 ,
298
- autoref : Some ( ty:: AutoPtr ( r_borrow,
299
- mutbl_b,
300
- Some ( box AutoUnsize ( ty:: UnsizeLength ( len) ) ) ) )
301
- } ) ) )
302
- }
303
- _ => Err ( ty:: terr_mismatch)
304
- }
305
- }
306
256
307
257
// &[T, ..n] or &mut [T, ..n] -> &[T]
308
258
// or &mut [T, ..n] -> &mut [T]
0 commit comments