@@ -33,12 +33,10 @@ use std::rc::Rc;
33
33
use syntax:: ast;
34
34
use syntax:: codemap;
35
35
use syntax:: codemap:: Span ;
36
- use util:: common:: indent;
37
36
use util:: nodemap:: FnvHashMap ;
38
37
use util:: ppaux:: { ty_to_string} ;
39
38
use util:: ppaux:: { Repr , UserString } ;
40
39
41
- use self :: coercion:: Coerce ;
42
40
use self :: combine:: { Combine , Combineable , CombineFields } ;
43
41
use self :: region_inference:: { RegionVarBindings , RegionSnapshot } ;
44
42
use self :: equate:: Equate ;
@@ -47,7 +45,6 @@ use self::lub::Lub;
47
45
use self :: unify:: { UnificationTable , InferCtxtMethodsForSimplyUnifiableTypes } ;
48
46
use self :: error_reporting:: ErrorReporting ;
49
47
50
- pub mod coercion;
51
48
pub mod combine;
52
49
pub mod doc;
53
50
pub mod equate;
@@ -68,7 +65,6 @@ pub type Bound<T> = Option<T>;
68
65
pub type cres < ' tcx , T > = Result < T , ty:: type_err < ' tcx > > ; // "combine result"
69
66
pub type ures < ' tcx > = cres < ' tcx , ( ) > ; // "unify result"
70
67
pub type fres < T > = Result < T , fixup_err > ; // "fixup result"
71
- pub type CoerceResult < ' tcx > = cres < ' tcx , Option < ty:: AutoAdjustment < ' tcx > > > ;
72
68
73
69
pub struct InferCtxt < ' a , ' tcx : ' a > {
74
70
pub tcx : & ' a ty:: ctxt < ' tcx > ,
@@ -409,24 +405,6 @@ fn expected_found<T>(a_is_expected: bool,
409
405
}
410
406
}
411
407
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
-
430
408
trait then < ' tcx > {
431
409
fn then < T , F > ( & self , f : F ) -> Result < T , ty:: type_err < ' tcx > > where
432
410
T : Clone ,
@@ -689,10 +667,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
689
667
{
690
668
debug ! ( "sub_types({} <: {})" , a. repr( self . tcx) , b. repr( self . tcx) ) ;
691
669
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) ;
696
671
self . sub ( a_is_expected, trace) . tys ( a, b) . to_ures ( )
697
672
} )
698
673
}
@@ -705,10 +680,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
705
680
-> ures < ' tcx >
706
681
{
707
682
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) ;
712
684
self . equate ( a_is_expected, trace) . tys ( a, b) . to_ures ( )
713
685
} )
714
686
}
@@ -1118,6 +1090,17 @@ impl<'tcx> TypeTrace<'tcx> {
1118
1090
self . origin . span ( )
1119
1091
}
1120
1092
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
+
1121
1104
pub fn dummy ( tcx : & ty:: ctxt < ' tcx > ) -> TypeTrace < ' tcx > {
1122
1105
TypeTrace {
1123
1106
origin : Misc ( codemap:: DUMMY_SP ) ,
0 commit comments