Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 5a3875e998ad2583978bfc8f0e6d1533b10fbea4 1 parent 3ef620b
@catamorphism catamorphism authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 src/rustc/middle/infer.rs
View
21 src/rustc/middle/infer.rs
@@ -528,11 +528,14 @@ impl unify_methods for infer_ctxt {
}
}
- fn flds(a: ty::field, b: ty::field) -> ures {
- if a.ident != b.ident {
- ret self.uerr(ty::terr_record_fields(a.ident, b.ident));
+ /* mk_subty passes the "smaller" type as the first argument
+ and the "bigger" type as the second -- so the first arg
+ is the actual type, and the second is the expected type */
+ fn flds(a: ty::field, e: ty::field) -> ures {
+ if e.ident != a.ident {
+ ret self.uerr(ty::terr_record_fields(e.ident, a.ident));
}
- self.mts(a.mt, b.mt)
+ self.mts(a.mt, e.mt)
}
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])
}
}
-fn c_flds<C:combine>(self: C, a: ty::field, b: ty::field) -> cres<ty::field> {
- if a.ident == b.ident {
- self.c_mts(a.mt, b.mt).chain {|mt|
- ok({ident: a.ident, mt: mt})
+fn c_flds<C:combine>(self: C, e: ty::field, a: ty::field) -> cres<ty::field> {
+ if e.ident == a.ident {
+ self.c_mts(e.mt, a.mt).chain {|mt|
+ ok({ident: e.ident, mt: mt})
}
} else {
- err(ty::terr_record_fields(a.ident, b.ident))
+ err(ty::terr_record_fields(e.ident, a.ident))
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.