From 8557cb47cba1f343563f92b14151661425573270 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sun, 20 Sep 2015 14:15:21 +0300 Subject: [PATCH] don't store method_fty It is redundant with the item type. This is not much of a win, as there are really not *that* many methods, but it makes the code uglier. --- src/librustc/metadata/common.rs | 3 +-- src/librustc/metadata/decoder.rs | 16 +++++++--------- src/librustc/metadata/encoder.rs | 18 ------------------ 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index e27178b32f9e..c436963f6ad8 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -163,8 +163,7 @@ pub const tag_lang_items_missing: usize = 0x76; 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 diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 565ec2414f41..69d3e55835f5 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -219,14 +219,6 @@ fn maybe_doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Opt }) } -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) @@ -880,7 +872,13 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc, 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, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 822887a9c12a..dd23584994b9 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -235,22 +235,6 @@ fn encode_region(ecx: &EncodeContext, 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) { @@ -755,7 +739,6 @@ fn encode_method_ty_fields<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, 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 { @@ -826,7 +809,6 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, 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);