@@ -33,12 +33,10 @@ use std::rc::Rc;
3333use syntax:: ast;
3434use syntax:: codemap;
3535use syntax:: codemap:: Span ;
36- use util:: common:: indent;
3736use util:: nodemap:: FnvHashMap ;
3837use util:: ppaux:: { ty_to_string} ;
3938use util:: ppaux:: { Repr , UserString } ;
4039
41- use self :: coercion:: Coerce ;
4240use self :: combine:: { Combine , Combineable , CombineFields } ;
4341use self :: region_inference:: { RegionVarBindings , RegionSnapshot } ;
4442use self :: equate:: Equate ;
@@ -47,7 +45,6 @@ use self::lub::Lub;
4745use self :: unify:: { UnificationTable , InferCtxtMethodsForSimplyUnifiableTypes } ;
4846use self :: error_reporting:: ErrorReporting ;
4947
50- pub mod coercion;
5148pub mod combine;
5249pub mod doc;
5350pub mod equate;
@@ -68,7 +65,6 @@ pub type Bound<T> = Option<T>;
6865pub type cres < ' tcx , T > = Result < T , ty:: type_err < ' tcx > > ; // "combine result"
6966pub type ures < ' tcx > = cres < ' tcx , ( ) > ; // "unify result"
7067pub type fres < T > = Result < T , fixup_err > ; // "fixup result"
71- pub type CoerceResult < ' tcx > = cres < ' tcx , Option < ty:: AutoAdjustment < ' tcx > > > ;
7268
7369pub struct InferCtxt < ' a , ' tcx : ' a > {
7470 pub tcx : & ' a ty:: ctxt < ' tcx > ,
@@ -409,24 +405,6 @@ fn expected_found<T>(a_is_expected: bool,
409405 }
410406}
411407
412- pub fn mk_coercety < ' a , ' tcx > ( cx : & InferCtxt < ' a , ' tcx > ,
413- a_is_expected : bool ,
414- origin : TypeOrigin ,
415- a : Ty < ' tcx > ,
416- b : Ty < ' tcx > )
417- -> CoerceResult < ' tcx > {
418- debug ! ( "mk_coercety({} -> {})" , a. repr( cx. tcx) , b. repr( cx. tcx) ) ;
419- indent ( || {
420- cx. commit_if_ok ( || {
421- let trace = TypeTrace {
422- origin : origin,
423- values : Types ( expected_found ( a_is_expected, a, b) )
424- } ;
425- Coerce ( cx. combine_fields ( a_is_expected, trace) ) . tys ( a, b)
426- } )
427- } )
428- }
429-
430408trait then < ' tcx > {
431409 fn then < T , F > ( & self , f : F ) -> Result < T , ty:: type_err < ' tcx > > where
432410 T : Clone ,
@@ -689,10 +667,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
689667 {
690668 debug ! ( "sub_types({} <: {})" , a. repr( self . tcx) , b. repr( self . tcx) ) ;
691669 self . commit_if_ok ( || {
692- let trace = TypeTrace {
693- origin : origin,
694- values : Types ( expected_found ( a_is_expected, a, b) )
695- } ;
670+ let trace = TypeTrace :: types ( origin, a_is_expected, a, b) ;
696671 self . sub ( a_is_expected, trace) . tys ( a, b) . to_ures ( )
697672 } )
698673 }
@@ -705,10 +680,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
705680 -> ures < ' tcx >
706681 {
707682 self . commit_if_ok ( || {
708- let trace = TypeTrace {
709- origin : origin,
710- values : Types ( expected_found ( a_is_expected, a, b) )
711- } ;
683+ let trace = TypeTrace :: types ( origin, a_is_expected, a, b) ;
712684 self . equate ( a_is_expected, trace) . tys ( a, b) . to_ures ( )
713685 } )
714686 }
@@ -1118,6 +1090,17 @@ impl<'tcx> TypeTrace<'tcx> {
11181090 self . origin . span ( )
11191091 }
11201092
1093+ pub fn types ( origin : TypeOrigin ,
1094+ a_is_expected : bool ,
1095+ a : Ty < ' tcx > ,
1096+ b : Ty < ' tcx > )
1097+ -> TypeTrace < ' tcx > {
1098+ TypeTrace {
1099+ origin : origin,
1100+ values : Types ( expected_found ( a_is_expected, a, b) )
1101+ }
1102+ }
1103+
11211104 pub fn dummy ( tcx : & ty:: ctxt < ' tcx > ) -> TypeTrace < ' tcx > {
11221105 TypeTrace {
11231106 origin : Misc ( codemap:: DUMMY_SP ) ,
0 commit comments