Skip to content

Commit 8557cb4

Browse files
Ariel Ben-Yehudaarielb1
authored andcommitted
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.
1 parent a1c921e commit 8557cb4

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

src/librustc/metadata/common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ pub const tag_lang_items_missing: usize = 0x76;
163163
pub const tag_item_unnamed_field: usize = 0x77;
164164
pub const tag_items_data_item_visibility: usize = 0x78;
165165

166-
// GAP 0x79
167-
pub const tag_item_method_fty: usize = 0x7a;
166+
// GAP 0x79, 0x7a
168167

169168
pub const tag_mod_child: usize = 0x7b;
170169
pub const tag_misc_info: usize = 0x108; // top-level only

src/librustc/metadata/decoder.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,6 @@ fn maybe_doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Opt
219219
})
220220
}
221221

222-
fn doc_method_fty<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>,
223-
cdata: Cmd) -> ty::BareFnTy<'tcx> {
224-
let tp = reader::get_doc(doc, tag_item_method_fty);
225-
TyDecoder::with_doc(tcx, cdata.cnum, tp,
226-
&mut |_, did| translate_def_id(cdata, did))
227-
.parse_bare_fn_ty()
228-
}
229-
230222
pub fn item_type<'tcx>(_item_id: DefId, item: rbml::Doc,
231223
tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
232224
doc_type(item, tcx, cdata)
@@ -880,7 +872,13 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
880872
Some('r') | Some('p') => {
881873
let generics = doc_generics(item_doc, tcx, cdata, tag_method_ty_generics);
882874
let predicates = doc_predicates(item_doc, tcx, cdata, tag_method_ty_generics);
883-
let fty = doc_method_fty(item_doc, tcx, cdata);
875+
let ity = tcx.lookup_item_type(def_id).ty;
876+
let fty = match ity.sty {
877+
ty::TyBareFn(_, fty) => fty.clone(),
878+
_ => tcx.sess.bug(&format!(
879+
"the type {:?} of the method {:?} is not a function?",
880+
ity, name))
881+
};
884882
let explicit_self = get_explicit_self(item_doc);
885883

886884
ty::MethodTraitItem(Rc::new(ty::Method::new(name,

src/librustc/metadata/encoder.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,6 @@ fn encode_region(ecx: &EncodeContext,
235235
rbml_w.end_tag();
236236
}
237237

238-
fn encode_method_fty<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
239-
rbml_w: &mut Encoder,
240-
typ: &ty::BareFnTy<'tcx>) {
241-
rbml_w.start_tag(tag_item_method_fty);
242-
243-
let ty_str_ctxt = &tyencode::ctxt {
244-
diag: ecx.diag,
245-
ds: def_to_string,
246-
tcx: ecx.tcx,
247-
abbrevs: &ecx.type_abbrevs
248-
};
249-
tyencode::enc_bare_fn_ty(rbml_w, ty_str_ctxt, typ);
250-
251-
rbml_w.end_tag();
252-
}
253-
254238
fn encode_symbol(ecx: &EncodeContext,
255239
rbml_w: &mut Encoder,
256240
id: NodeId) {
@@ -755,7 +739,6 @@ fn encode_method_ty_fields<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
755739
encode_generics(rbml_w, ecx, index,
756740
&method_ty.generics, &method_ty.predicates,
757741
tag_method_ty_generics);
758-
encode_method_fty(ecx, rbml_w, &method_ty.fty);
759742
encode_visibility(rbml_w, method_ty.vis);
760743
encode_explicit_self(rbml_w, &method_ty.explicit_self);
761744
match method_ty.explicit_self {
@@ -826,7 +809,6 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
826809
let stab = stability::lookup(ecx.tcx, m.def_id);
827810
encode_stability(rbml_w, stab);
828811

829-
// The type for methods gets encoded twice, which is unfortunate.
830812
encode_bounds_and_type_for_item(rbml_w, ecx, index, m.def_id.local_id());
831813

832814
let elem = ast_map::PathName(m.name);

0 commit comments

Comments
 (0)