@@ -363,28 +363,6 @@ pub fn super_fn_sigs<'tcx, C: Combine<'tcx>>(this: &C,
363
363
364
364
pub fn super_tys < ' tcx , C : Combine < ' tcx > > ( this : & C , a : ty:: t , b : ty:: t ) -> cres < ty:: t > {
365
365
366
- // This is a horrible hack - historically, [T] was not treated as a type,
367
- // so, for example, &T and &[U] should not unify. In fact the only thing
368
- // &[U] should unify with is &[T]. We preserve that behaviour with this
369
- // check.
370
- fn check_ptr_to_unsized < ' tcx , C : Combine < ' tcx > > ( this : & C ,
371
- a : ty:: t ,
372
- b : ty:: t ,
373
- a_inner : ty:: t ,
374
- b_inner : ty:: t ,
375
- result : ty:: t ) -> cres < ty:: t > {
376
- match ( & ty:: get ( a_inner) . sty , & ty:: get ( b_inner) . sty ) {
377
- ( & ty:: ty_vec( _, None ) , & ty:: ty_vec( _, None ) ) |
378
- ( & ty:: ty_str, & ty:: ty_str) |
379
- ( & ty:: ty_trait( ..) , & ty:: ty_trait( ..) ) => Ok ( result) ,
380
- ( & ty:: ty_vec( _, None ) , _) | ( _, & ty:: ty_vec( _, None ) ) |
381
- ( & ty:: ty_str, _) | ( _, & ty:: ty_str) |
382
- ( & ty:: ty_trait( ..) , _) | ( _, & ty:: ty_trait( ..) )
383
- => Err ( ty:: terr_sorts ( expected_found ( this, a, b) ) ) ,
384
- _ => Ok ( result) ,
385
- }
386
- }
387
-
388
366
let tcx = this. infcx ( ) . tcx ;
389
367
let a_sty = & ty:: get ( a) . sty ;
390
368
let b_sty = & ty:: get ( b) . sty ;
@@ -402,6 +380,10 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t
402
380
b. repr( this. infcx( ) . tcx) ) . as_slice ( ) ) ;
403
381
}
404
382
383
+ ( & ty:: ty_err, _) | ( _, & ty:: ty_err) => {
384
+ Ok ( ty:: mk_err ( ) )
385
+ }
386
+
405
387
// Relate integral variables to other types
406
388
( & ty:: ty_infer( IntVar ( a_id) ) , & ty:: ty_infer( IntVar ( b_id) ) ) => {
407
389
try!( this. infcx ( ) . simple_vars ( this. a_is_expected ( ) ,
@@ -442,8 +424,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t
442
424
( & ty:: ty_bool, _) |
443
425
( & ty:: ty_int( _) , _) |
444
426
( & ty:: ty_uint( _) , _) |
445
- ( & ty:: ty_float( _) , _) |
446
- ( & ty:: ty_err, _) => {
427
+ ( & ty:: ty_float( _) , _) => {
447
428
if ty:: get ( a) . sty == ty:: get ( b) . sty {
448
429
Ok ( a)
449
430
} else {
@@ -494,13 +475,13 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t
494
475
}
495
476
496
477
( & ty:: ty_uniq( a_inner) , & ty:: ty_uniq( b_inner) ) => {
497
- let typ = try!( this. tys ( a_inner, b_inner) ) ;
498
- check_ptr_to_unsized ( this , a , b , a_inner , b_inner , ty:: mk_uniq ( tcx, typ) )
478
+ let typ = try!( this. tys ( a_inner, b_inner) ) ;
479
+ Ok ( ty:: mk_uniq ( tcx, typ) )
499
480
}
500
481
501
482
( & ty:: ty_ptr( ref a_mt) , & ty:: ty_ptr( ref b_mt) ) => {
502
- let mt = try!( this. mts ( a_mt, b_mt) ) ;
503
- check_ptr_to_unsized ( this , a , b , a_mt . ty , b_mt . ty , ty:: mk_ptr ( tcx, mt) )
483
+ let mt = try!( this. mts ( a_mt, b_mt) ) ;
484
+ Ok ( ty:: mk_ptr ( tcx, mt) )
504
485
}
505
486
506
487
( & ty:: ty_rptr( a_r, ref a_mt) , & ty:: ty_rptr( b_r, ref b_mt) ) => {
@@ -516,7 +497,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t
516
497
}
517
498
_ => try!( this. mts ( a_mt, b_mt) )
518
499
} ;
519
- check_ptr_to_unsized ( this , a , b , a_mt . ty , b_mt . ty , ty:: mk_rptr ( tcx, r, mt) )
500
+ Ok ( ty:: mk_rptr ( tcx, r, mt) )
520
501
}
521
502
522
503
( & ty:: ty_vec( a_t, sz_a) , & ty:: ty_vec( b_t, sz_b) ) => {
0 commit comments