@@ -21,20 +21,25 @@ use syntax::codemap::span;
21
21
// Requires that the two types unify, and prints an error message if they
22
22
// don't.
23
23
pub fn suptype ( fcx : @mut FnCtxt , sp : span , expected : ty:: t , actual : ty:: t ) {
24
- suptype_with_fn ( fcx, sp, expected, actual,
24
+ suptype_with_fn ( fcx, sp, false , expected, actual,
25
25
|sp, e, a, s| { fcx. report_mismatched_types ( sp, e, a, s) } )
26
26
}
27
27
28
+ pub fn subtype ( fcx : @mut FnCtxt , sp : span , expected : ty:: t , actual : ty:: t ) {
29
+ suptype_with_fn ( fcx, sp, true , actual, expected,
30
+ |sp, a, e, s| { fcx. report_mismatched_types ( sp, e, a, s) } )
31
+ }
32
+
28
33
pub fn suptype_with_fn ( fcx : @mut FnCtxt ,
29
- sp : span ,
30
- expected : ty:: t , actual : ty:: t ,
34
+ sp : span , b_is_expected : bool ,
35
+ ty_a : ty:: t , ty_b : ty:: t ,
31
36
handle_err : fn ( span , ty:: t , ty:: t , & ty:: type_err ) ) {
32
37
// n.b.: order of actual, expected is reversed
33
- match infer:: mk_subty ( fcx. infcx ( ) , false , sp,
34
- actual , expected ) {
38
+ match infer:: mk_subty ( fcx. infcx ( ) , b_is_expected , sp,
39
+ ty_b , ty_a ) {
35
40
result:: Ok ( ( ) ) => { /* ok */ }
36
41
result:: Err ( ref err) => {
37
- handle_err ( sp, expected , actual , err) ;
42
+ handle_err ( sp, ty_a , ty_b , err) ;
38
43
}
39
44
}
40
45
}
0 commit comments