Adjust metadata for new fields and enum variants. Yawn.

This commit is contained in:
Niko Matsakis 2014-11-26 05:53:15 -05:00
parent 2a43b352f7
commit fad1423d1e
3 changed files with 31 additions and 7 deletions

View file

@ -453,7 +453,11 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
return ty::mk_closure(st.tcx, parse_closure_ty(st, |x,y| conv(x,y)));
}
'F' => {
return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, |x,y| conv(x,y)));
let def_id = parse_def(st, NominalType, |x,y| conv(x,y));
return ty::mk_bare_fn(st.tcx, Some(def_id), parse_bare_fn_ty(st, |x,y| conv(x,y)));
}
'G' => {
return ty::mk_bare_fn(st.tcx, None, parse_bare_fn_ty(st, |x,y| conv(x,y)));
}
'#' => {
let pos = parse_hex(st);

View file

@ -123,8 +123,13 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
mywrite!(w, "f");
enc_closure_ty(w, cx, &**f);
}
ty::ty_bare_fn(ref f) => {
ty::ty_bare_fn(Some(def_id), ref f) => {
mywrite!(w, "F");
mywrite!(w, "{}|", (cx.ds)(def_id));
enc_bare_fn_ty(w, cx, f);
}
ty::ty_bare_fn(None, ref f) => {
mywrite!(w, "G");
enc_bare_fn_ty(w, cx, f);
}
ty::ty_infer(_) => {

View file

@ -1007,14 +1007,21 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
self.emit_enum("AutoAdjustment", |this| {
match *adj {
ty::AdjustAddEnv(store) => {
this.emit_enum_variant("AutoAddEnv", 0, 1, |this| {
this.emit_enum_variant_arg(0, |this| store.encode(this))
ty::AdjustAddEnv(def_id, store) => {
this.emit_enum_variant("AdjustAddEnv", 0, 2, |this| {
this.emit_enum_variant_arg(0, |this| def_id.encode(this));
this.emit_enum_variant_arg(1, |this| store.encode(this))
})
}
ty::AdjustReifyFnPointer(def_id) => {
this.emit_enum_variant("AdjustReifyFnPointer", 1, 2, |this| {
this.emit_enum_variant_arg(0, |this| def_id.encode(this))
})
}
ty::AdjustDerefRef(ref auto_deref_ref) => {
this.emit_enum_variant("AutoDerefRef", 1, 1, |this| {
this.emit_enum_variant("AdjustDerefRef", 2, 2, |this| {
this.emit_enum_variant_arg(0,
|this| Ok(this.emit_auto_deref_ref(ecx, auto_deref_ref)))
})
@ -1648,12 +1655,20 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
this.read_enum_variant(&variants, |this, i| {
Ok(match i {
0 => {
let def_id: ast::DefId =
this.read_def_id(dcx);
let store: ty::TraitStore =
this.read_enum_variant_arg(0, |this| Decodable::decode(this)).unwrap();
ty::AdjustAddEnv(store.tr(dcx))
ty::AdjustAddEnv(def_id, store.tr(dcx))
}
1 => {
let def_id: ast::DefId =
this.read_def_id(dcx);
ty::AdjustReifyFnPointer(def_id)
}
2 => {
let auto_deref_ref: ty::AutoDerefRef =
this.read_enum_variant_arg(0,
|this| Ok(this.read_auto_deref_ref(dcx))).unwrap();