@@ -386,33 +386,6 @@ pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>,
386386 infcx
387387}
388388
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-
416389pub fn mk_subty < ' a , ' tcx > ( cx : & InferCtxt < ' a , ' tcx > ,
417390 a_is_expected : bool ,
418391 origin : TypeOrigin ,
@@ -434,7 +407,7 @@ pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
434407 origin : TypeOrigin :: Misc ( codemap:: DUMMY_SP ) ,
435408 values : Types ( expected_found ( true , a, b) )
436409 } ;
437- cx. sub ( true , trace) . relate ( & a, & b) . map ( |_| ( ) )
410+ cx. sub ( true , trace, & a, & b) . map ( |_| ( ) )
438411 } )
439412}
440413
@@ -695,32 +668,32 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
695668 cause : None }
696669 }
697670
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 >
701674 {
702- self . combine_fields ( a_is_expected, trace) . equate ( )
675+ self . combine_fields ( a_is_expected, trace) . equate ( ) . relate ( a , b )
703676 }
704677
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 >
708681 {
709- self . combine_fields ( a_is_expected, trace) . sub ( )
682+ self . combine_fields ( a_is_expected, trace) . sub ( ) . relate ( a , b )
710683 }
711684
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 >
715688 {
716- self . combine_fields ( a_is_expected, trace) . lub ( )
689+ self . combine_fields ( a_is_expected, trace) . lub ( ) . relate ( a , b )
717690 }
718691
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 >
722695 {
723- self . combine_fields ( a_is_expected, trace) . glb ( )
696+ self . combine_fields ( a_is_expected, trace) . glb ( ) . relate ( a , b )
724697 }
725698
726699 fn start_snapshot ( & self ) -> CombinedSnapshot {
@@ -861,7 +834,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
861834 debug ! ( "sub_types({:?} <: {:?})" , a, b) ;
862835 self . commit_if_ok ( |_| {
863836 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 ( |_| ( ) )
865838 } )
866839 }
867840
@@ -874,7 +847,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
874847 {
875848 self . commit_if_ok ( |_| {
876849 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 ( |_| ( ) )
878851 } )
879852 }
880853
@@ -893,7 +866,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
893866 origin : origin,
894867 values : TraitRefs ( expected_found ( a_is_expected, a. clone ( ) , b. clone ( ) ) )
895868 } ;
896- self . equate ( a_is_expected, trace) . relate ( & a, & b) . map ( |_| ( ) )
869+ self . equate ( a_is_expected, trace, & a, & b) . map ( |_| ( ) )
897870 } )
898871 }
899872
@@ -912,7 +885,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
912885 origin : origin,
913886 values : PolyTraitRefs ( expected_found ( a_is_expected, a. clone ( ) , b. clone ( ) ) )
914887 } ;
915- self . sub ( a_is_expected, trace) . relate ( & a, & b) . map ( |_| ( ) )
888+ self . sub ( a_is_expected, trace, & a, & b) . map ( |_| ( ) )
916889 } )
917890 }
918891
@@ -1461,7 +1434,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14611434 origin : TypeOrigin :: Misc ( codemap:: DUMMY_SP ) ,
14621435 values : Types ( expected_found ( true , e, e) )
14631436 } ;
1464- self . equate ( true , trace) . relate ( a, b)
1437+ self . equate ( true , trace, a, b)
14651438 } ) . map ( |_| ( ) )
14661439 }
14671440
0 commit comments