]> git.lizzy.rs Git - rust.git/commitdiff
don't store method_fty
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Sun, 20 Sep 2015 11:15:21 +0000 (14:15 +0300)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Thu, 1 Oct 2015 19:30:18 +0000 (22:30 +0300)
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
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs

index e27178b32f9e2f9de093ce4bdc4e711541b5388f..c436963f6ad8dfb7e920d483b172b34a995ca01b 100644 (file)
@@ -163,8 +163,7 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
 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
index 565ec2414f41dbd82730ca01c54b2d57ac842645..69d3e55835f5b488bc085d9b1b3961dc1c3e0bfa 100644 (file)
@@ -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<IdentInterner>,
         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,
index 822887a9c12a2e03c0cef22cf4966b75a7f5203d..dd23584994b9a2dfe4d26bc372be4424451c5cf5 100644 (file)
@@ -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);