pub const tag_item_unnamed_field: usize = 0x77;
pub const tag_items_data_item_visibility: usize = 0x78;
-// GAP 0x79
-pub const tag_item_method_fty: usize = 0x7a;
+// GAP 0x79, 0x7a
pub const tag_mod_child: usize = 0x7b;
pub const tag_misc_info: usize = 0x108; // top-level only
})
}
-fn doc_method_fty<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>,
- cdata: Cmd) -> ty::BareFnTy<'tcx> {
- let tp = reader::get_doc(doc, tag_item_method_fty);
- TyDecoder::with_doc(tcx, cdata.cnum, tp,
- &mut |_, did| translate_def_id(cdata, did))
- .parse_bare_fn_ty()
-}
-
pub fn item_type<'tcx>(_item_id: DefId, item: rbml::Doc,
tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
doc_type(item, tcx, cdata)
Some('r') | Some('p') => {
let generics = doc_generics(item_doc, tcx, cdata, tag_method_ty_generics);
let predicates = doc_predicates(item_doc, tcx, cdata, tag_method_ty_generics);
- let fty = doc_method_fty(item_doc, tcx, cdata);
+ let ity = tcx.lookup_item_type(def_id).ty;
+ let fty = match ity.sty {
+ ty::TyBareFn(_, fty) => fty.clone(),
+ _ => tcx.sess.bug(&format!(
+ "the type {:?} of the method {:?} is not a function?",
+ ity, name))
+ };
let explicit_self = get_explicit_self(item_doc);
ty::MethodTraitItem(Rc::new(ty::Method::new(name,
rbml_w.end_tag();
}
-fn encode_method_fty<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
- rbml_w: &mut Encoder,
- typ: &ty::BareFnTy<'tcx>) {
- rbml_w.start_tag(tag_item_method_fty);
-
- let ty_str_ctxt = &tyencode::ctxt {
- diag: ecx.diag,
- ds: def_to_string,
- tcx: ecx.tcx,
- abbrevs: &ecx.type_abbrevs
- };
- tyencode::enc_bare_fn_ty(rbml_w, ty_str_ctxt, typ);
-
- rbml_w.end_tag();
-}
-
fn encode_symbol(ecx: &EncodeContext,
rbml_w: &mut Encoder,
id: NodeId) {
encode_generics(rbml_w, ecx, index,
&method_ty.generics, &method_ty.predicates,
tag_method_ty_generics);
- encode_method_fty(ecx, rbml_w, &method_ty.fty);
encode_visibility(rbml_w, method_ty.vis);
encode_explicit_self(rbml_w, &method_ty.explicit_self);
match method_ty.explicit_self {
let stab = stability::lookup(ecx.tcx, m.def_id);
encode_stability(rbml_w, stab);
- // The type for methods gets encoded twice, which is unfortunate.
encode_bounds_and_type_for_item(rbml_w, ecx, index, m.def_id.local_id());
let elem = ast_map::PathName(m.name);