@@ -386,33 +386,6 @@ pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>,
386
386
infcx
387
387
}
388
388
389
- /// Computes the least upper-bound of `a` and `b`. If this is not possible, reports an error and
390
- /// returns ty::err.
391
- pub fn common_supertype < ' a , ' tcx > ( cx : & InferCtxt < ' a , ' tcx > ,
392
- origin : TypeOrigin ,
393
- a_is_expected : bool ,
394
- a : Ty < ' tcx > ,
395
- b : Ty < ' tcx > )
396
- -> Ty < ' tcx >
397
- {
398
- debug ! ( "common_supertype({:?}, {:?})" ,
399
- a, b) ;
400
-
401
- let trace = TypeTrace {
402
- origin : origin,
403
- values : Types ( expected_found ( a_is_expected, a, b) )
404
- } ;
405
-
406
- let result = cx. commit_if_ok ( |_| cx. lub ( a_is_expected, trace. clone ( ) ) . relate ( & a, & b) ) ;
407
- match result {
408
- Ok ( t) => t,
409
- Err ( ref err) => {
410
- cx. report_and_explain_type_error ( trace, err) . emit ( ) ;
411
- cx. tcx . types . err
412
- }
413
- }
414
- }
415
-
416
389
pub fn mk_subty < ' a , ' tcx > ( cx : & InferCtxt < ' a , ' tcx > ,
417
390
a_is_expected : bool ,
418
391
origin : TypeOrigin ,
@@ -434,7 +407,7 @@ pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
434
407
origin : TypeOrigin :: Misc ( codemap:: DUMMY_SP ) ,
435
408
values : Types ( expected_found ( true , a, b) )
436
409
} ;
437
- cx. sub ( true , trace) . relate ( & a, & b) . map ( |_| ( ) )
410
+ cx. sub ( true , trace, & a, & b) . map ( |_| ( ) )
438
411
} )
439
412
}
440
413
@@ -695,32 +668,32 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
695
668
cause : None }
696
669
}
697
670
698
- // public so that it can be used from the rustc_driver unit tests
699
- pub fn equate ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > )
700
- -> equate :: Equate < ' a , ' tcx >
671
+ pub fn equate < T > ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > , a : & T , b : & T )
672
+ -> RelateResult < ' tcx , T >
673
+ where T : Relate < ' a , ' tcx >
701
674
{
702
- self . combine_fields ( a_is_expected, trace) . equate ( )
675
+ self . combine_fields ( a_is_expected, trace) . equate ( ) . relate ( a , b )
703
676
}
704
677
705
- // public so that it can be used from the rustc_driver unit tests
706
- pub fn sub ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > )
707
- -> sub :: Sub < ' a , ' tcx >
678
+ pub fn sub < T > ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > , a : & T , b : & T )
679
+ -> RelateResult < ' tcx , T >
680
+ where T : Relate < ' a , ' tcx >
708
681
{
709
- self . combine_fields ( a_is_expected, trace) . sub ( )
682
+ self . combine_fields ( a_is_expected, trace) . sub ( ) . relate ( a , b )
710
683
}
711
684
712
- // public so that it can be used from the rustc_driver unit tests
713
- pub fn lub ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > )
714
- -> lub :: Lub < ' a , ' tcx >
685
+ pub fn lub < T > ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > , a : & T , b : & T )
686
+ -> RelateResult < ' tcx , T >
687
+ where T : Relate < ' a , ' tcx >
715
688
{
716
- self . combine_fields ( a_is_expected, trace) . lub ( )
689
+ self . combine_fields ( a_is_expected, trace) . lub ( ) . relate ( a , b )
717
690
}
718
691
719
- // public so that it can be used from the rustc_driver unit tests
720
- pub fn glb ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > )
721
- -> glb :: Glb < ' a , ' tcx >
692
+ pub fn glb < T > ( & ' a self , a_is_expected : bool , trace : TypeTrace < ' tcx > , a : & T , b : & T )
693
+ -> RelateResult < ' tcx , T >
694
+ where T : Relate < ' a , ' tcx >
722
695
{
723
- self . combine_fields ( a_is_expected, trace) . glb ( )
696
+ self . combine_fields ( a_is_expected, trace) . glb ( ) . relate ( a , b )
724
697
}
725
698
726
699
fn start_snapshot ( & self ) -> CombinedSnapshot {
@@ -861,7 +834,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
861
834
debug ! ( "sub_types({:?} <: {:?})" , a, b) ;
862
835
self . commit_if_ok ( |_| {
863
836
let trace = TypeTrace :: types ( origin, a_is_expected, a, b) ;
864
- self . sub ( a_is_expected, trace) . relate ( & a, & b) . map ( |_| ( ) )
837
+ self . sub ( a_is_expected, trace, & a, & b) . map ( |_| ( ) )
865
838
} )
866
839
}
867
840
@@ -874,7 +847,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
874
847
{
875
848
self . commit_if_ok ( |_| {
876
849
let trace = TypeTrace :: types ( origin, a_is_expected, a, b) ;
877
- self . equate ( a_is_expected, trace) . relate ( & a, & b) . map ( |_| ( ) )
850
+ self . equate ( a_is_expected, trace, & a, & b) . map ( |_| ( ) )
878
851
} )
879
852
}
880
853
@@ -893,7 +866,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
893
866
origin : origin,
894
867
values : TraitRefs ( expected_found ( a_is_expected, a. clone ( ) , b. clone ( ) ) )
895
868
} ;
896
- self . equate ( a_is_expected, trace) . relate ( & a, & b) . map ( |_| ( ) )
869
+ self . equate ( a_is_expected, trace, & a, & b) . map ( |_| ( ) )
897
870
} )
898
871
}
899
872
@@ -912,7 +885,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
912
885
origin : origin,
913
886
values : PolyTraitRefs ( expected_found ( a_is_expected, a. clone ( ) , b. clone ( ) ) )
914
887
} ;
915
- self . sub ( a_is_expected, trace) . relate ( & a, & b) . map ( |_| ( ) )
888
+ self . sub ( a_is_expected, trace, & a, & b) . map ( |_| ( ) )
916
889
} )
917
890
}
918
891
@@ -1461,7 +1434,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1461
1434
origin : TypeOrigin :: Misc ( codemap:: DUMMY_SP ) ,
1462
1435
values : Types ( expected_found ( true , e, e) )
1463
1436
} ;
1464
- self . equate ( true , trace) . relate ( a, b)
1437
+ self . equate ( true , trace, a, b)
1465
1438
} ) . map ( |_| ( ) )
1466
1439
}
1467
1440
0 commit comments