@@ -61,93 +61,93 @@ pub struct CombineFields<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
6161}
6262
6363impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
64- pub fn super_combine_tys < R > ( & self ,
65- relation : & mut R ,
66- a : Ty < ' tcx > ,
67- b : Ty < ' tcx > )
68- -> RelateResult < ' tcx , Ty < ' tcx > >
69- where R : TypeRelation < ' a , ' gcx , ' tcx >
70- {
71- let a_is_expected = relation. a_is_expected ( ) ;
72-
73- match ( & a. sty , & b. sty ) {
74- // Relate integral variables to other types
75- ( & ty:: TyInfer ( ty:: IntVar ( a_id) ) , & ty:: TyInfer ( ty:: IntVar ( b_id) ) ) => {
76- self . int_unification_table
77- . borrow_mut ( )
78- . unify_var_var ( a_id, b_id)
79- . map_err ( |e| int_unification_error ( a_is_expected, e) ) ?;
80- Ok ( a)
81- }
82- ( & ty:: TyInfer ( ty:: IntVar ( v_id) ) , & ty:: TyInt ( v) ) => {
83- self . unify_integral_variable ( a_is_expected, v_id, IntType ( v) )
84- }
85- ( & ty:: TyInt ( v) , & ty:: TyInfer ( ty:: IntVar ( v_id) ) ) => {
86- self . unify_integral_variable ( !a_is_expected, v_id, IntType ( v) )
87- }
88- ( & ty:: TyInfer ( ty:: IntVar ( v_id) ) , & ty:: TyUint ( v) ) => {
89- self . unify_integral_variable ( a_is_expected, v_id, UintType ( v) )
90- }
91- ( & ty:: TyUint ( v) , & ty:: TyInfer ( ty:: IntVar ( v_id) ) ) => {
92- self . unify_integral_variable ( !a_is_expected, v_id, UintType ( v) )
93- }
64+ pub fn super_combine_tys < R > ( & self ,
65+ relation : & mut R ,
66+ a : Ty < ' tcx > ,
67+ b : Ty < ' tcx > )
68+ -> RelateResult < ' tcx , Ty < ' tcx > >
69+ where R : TypeRelation < ' a , ' gcx , ' tcx >
70+ {
71+ let a_is_expected = relation. a_is_expected ( ) ;
72+
73+ match ( & a. sty , & b. sty ) {
74+ // Relate integral variables to other types
75+ ( & ty:: TyInfer ( ty:: IntVar ( a_id) ) , & ty:: TyInfer ( ty:: IntVar ( b_id) ) ) => {
76+ self . int_unification_table
77+ . borrow_mut ( )
78+ . unify_var_var ( a_id, b_id)
79+ . map_err ( |e| int_unification_error ( a_is_expected, e) ) ?;
80+ Ok ( a)
81+ }
82+ ( & ty:: TyInfer ( ty:: IntVar ( v_id) ) , & ty:: TyInt ( v) ) => {
83+ self . unify_integral_variable ( a_is_expected, v_id, IntType ( v) )
84+ }
85+ ( & ty:: TyInt ( v) , & ty:: TyInfer ( ty:: IntVar ( v_id) ) ) => {
86+ self . unify_integral_variable ( !a_is_expected, v_id, IntType ( v) )
87+ }
88+ ( & ty:: TyInfer ( ty:: IntVar ( v_id) ) , & ty:: TyUint ( v) ) => {
89+ self . unify_integral_variable ( a_is_expected, v_id, UintType ( v) )
90+ }
91+ ( & ty:: TyUint ( v) , & ty:: TyInfer ( ty:: IntVar ( v_id) ) ) => {
92+ self . unify_integral_variable ( !a_is_expected, v_id, UintType ( v) )
93+ }
9494
95- // Relate floating-point variables to other types
96- ( & ty:: TyInfer ( ty:: FloatVar ( a_id) ) , & ty:: TyInfer ( ty:: FloatVar ( b_id) ) ) => {
97- self . float_unification_table
98- . borrow_mut ( )
99- . unify_var_var ( a_id, b_id)
100- . map_err ( |e| float_unification_error ( relation. a_is_expected ( ) , e) ) ?;
101- Ok ( a)
102- }
103- ( & ty:: TyInfer ( ty:: FloatVar ( v_id) ) , & ty:: TyFloat ( v) ) => {
104- self . unify_float_variable ( a_is_expected, v_id, v)
105- }
106- ( & ty:: TyFloat ( v) , & ty:: TyInfer ( ty:: FloatVar ( v_id) ) ) => {
107- self . unify_float_variable ( !a_is_expected, v_id, v)
108- }
95+ // Relate floating-point variables to other types
96+ ( & ty:: TyInfer ( ty:: FloatVar ( a_id) ) , & ty:: TyInfer ( ty:: FloatVar ( b_id) ) ) => {
97+ self . float_unification_table
98+ . borrow_mut ( )
99+ . unify_var_var ( a_id, b_id)
100+ . map_err ( |e| float_unification_error ( relation. a_is_expected ( ) , e) ) ?;
101+ Ok ( a)
102+ }
103+ ( & ty:: TyInfer ( ty:: FloatVar ( v_id) ) , & ty:: TyFloat ( v) ) => {
104+ self . unify_float_variable ( a_is_expected, v_id, v)
105+ }
106+ ( & ty:: TyFloat ( v) , & ty:: TyInfer ( ty:: FloatVar ( v_id) ) ) => {
107+ self . unify_float_variable ( !a_is_expected, v_id, v)
108+ }
109109
110- // All other cases of inference are errors
111- ( & ty:: TyInfer ( _) , _) |
112- ( _, & ty:: TyInfer ( _) ) => {
113- Err ( TypeError :: Sorts ( ty:: relate:: expected_found ( relation, & a, & b) ) )
114- }
110+ // All other cases of inference are errors
111+ ( & ty:: TyInfer ( _) , _) |
112+ ( _, & ty:: TyInfer ( _) ) => {
113+ Err ( TypeError :: Sorts ( ty:: relate:: expected_found ( relation, & a, & b) ) )
114+ }
115115
116116
117- _ => {
118- ty:: relate:: super_relate_tys ( relation, a, b)
117+ _ => {
118+ ty:: relate:: super_relate_tys ( relation, a, b)
119+ }
119120 }
120121 }
121- }
122122
123- fn unify_integral_variable ( & self ,
124- vid_is_expected : bool ,
125- vid : ty:: IntVid ,
126- val : ty:: IntVarValue )
127- -> RelateResult < ' tcx , Ty < ' tcx > >
128- {
129- self . int_unification_table
130- . borrow_mut ( )
131- . unify_var_value ( vid, val)
132- . map_err ( |e| int_unification_error ( vid_is_expected, e) ) ?;
133- match val {
134- IntType ( v) => Ok ( self . tcx . mk_mach_int ( v) ) ,
135- UintType ( v) => Ok ( self . tcx . mk_mach_uint ( v) ) ,
123+ fn unify_integral_variable ( & self ,
124+ vid_is_expected : bool ,
125+ vid : ty:: IntVid ,
126+ val : ty:: IntVarValue )
127+ -> RelateResult < ' tcx , Ty < ' tcx > >
128+ {
129+ self . int_unification_table
130+ . borrow_mut ( )
131+ . unify_var_value ( vid, val)
132+ . map_err ( |e| int_unification_error ( vid_is_expected, e) ) ?;
133+ match val {
134+ IntType ( v) => Ok ( self . tcx . mk_mach_int ( v) ) ,
135+ UintType ( v) => Ok ( self . tcx . mk_mach_uint ( v) ) ,
136+ }
136137 }
137- }
138138
139- fn unify_float_variable ( & self ,
140- vid_is_expected : bool ,
141- vid : ty:: FloatVid ,
142- val : ast:: FloatTy )
143- -> RelateResult < ' tcx , Ty < ' tcx > >
144- {
145- self . float_unification_table
146- . borrow_mut ( )
147- . unify_var_value ( vid, val)
148- . map_err ( |e| float_unification_error ( vid_is_expected, e) ) ?;
149- Ok ( self . tcx . mk_mach_float ( val) )
150- }
139+ fn unify_float_variable ( & self ,
140+ vid_is_expected : bool ,
141+ vid : ty:: FloatVid ,
142+ val : ast:: FloatTy )
143+ -> RelateResult < ' tcx , Ty < ' tcx > >
144+ {
145+ self . float_unification_table
146+ . borrow_mut ( )
147+ . unify_var_value ( vid, val)
148+ . map_err ( |e| float_unification_error ( vid_is_expected, e) ) ?;
149+ Ok ( self . tcx . mk_mach_float ( val) )
150+ }
151151}
152152
153153impl < ' a , ' gcx , ' tcx > CombineFields < ' a , ' gcx , ' tcx > {
0 commit comments