Skip to content

Commit 5a3875e

Browse files
committed
Print "expected a record with field..." fields in the right order
Because terr_record_mismatch was getting called by infer::flds, which takes types a and b where it's trying to prove a <: b, the expected and actual fields were switched. Fixed it. Closes #2094
1 parent 3ef620b commit 5a3875e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/rustc/middle/infer.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,14 @@ impl unify_methods for infer_ctxt {
528528
}
529529
}
530530

531-
fn flds(a: ty::field, b: ty::field) -> ures {
532-
if a.ident != b.ident {
533-
ret self.uerr(ty::terr_record_fields(a.ident, b.ident));
531+
/* mk_subty passes the "smaller" type as the first argument
532+
and the "bigger" type as the second -- so the first arg
533+
is the actual type, and the second is the expected type */
534+
fn flds(a: ty::field, e: ty::field) -> ures {
535+
if e.ident != a.ident {
536+
ret self.uerr(ty::terr_record_fields(e.ident, a.ident));
534537
}
535-
self.mts(a.mt, b.mt)
538+
self.mts(a.mt, e.mt)
536539
}
537540

538541
fn tps(as: [ty::t], bs: [ty::t]) -> ures {
@@ -1087,13 +1090,13 @@ fn c_fieldvecs<C:combine>(self: C, as: [ty::field], bs: [ty::field])
10871090
}
10881091
}
10891092

1090-
fn c_flds<C:combine>(self: C, a: ty::field, b: ty::field) -> cres<ty::field> {
1091-
if a.ident == b.ident {
1092-
self.c_mts(a.mt, b.mt).chain {|mt|
1093-
ok({ident: a.ident, mt: mt})
1093+
fn c_flds<C:combine>(self: C, e: ty::field, a: ty::field) -> cres<ty::field> {
1094+
if e.ident == a.ident {
1095+
self.c_mts(e.mt, a.mt).chain {|mt|
1096+
ok({ident: e.ident, mt: mt})
10941097
}
10951098
} else {
1096-
err(ty::terr_record_fields(a.ident, b.ident))
1099+
err(ty::terr_record_fields(e.ident, a.ident))
10971100
}
10981101
}
10991102

0 commit comments

Comments
 (0)