Permalink
Browse files

Tag re-exports differently in metadata

so that the "list metadata" command doesn't print out anything
about intrinsics, but other code can see them.

Closes #2771
  • Loading branch information...
1 parent 3f9a346 commit 271da617cbd1233ed41459e3b136870bf8f6ab43 @catamorphism catamorphism committed Jul 9, 2012
Showing with 19 additions and 9 deletions.
  1. +1 −0 src/rustc/metadata/common.rs
  2. +10 −6 src/rustc/metadata/decoder.rs
  3. +8 −3 src/rustc/metadata/encoder.rs
@@ -96,6 +96,7 @@ const tag_mod_impl_trait: uint = 0x47u;
*/
const tag_item_impl_method: uint = 0x48u;
const tag_item_dtor: uint = 0x49u;
+const tag_paths_foreign_path: uint = 0x4a;
// used to encode crate_ctxt side tables
enum astencode_tag { // Reserves 0x50 -- 0x6f
@@ -827,13 +827,17 @@ fn get_crate_vers(data: @~[u8]) -> @str {
fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) {
out.write_str("=Items=\n");
let items = ebml::get_doc(md, tag_items);
- do iter_crate_items(bytes) |path, did| {
- out.write_str(#fmt["%s (%s)\n", path, describe_def(items, did)]);
+ do iter_crate_items(bytes) |tag, path, did| {
+ // Don't print out any metadata info about intrinsics
+ if tag != tag_paths_foreign_path {
+ out.write_str(#fmt["%s (%s)\n", path,
+ describe_def(items, did)]);
+ }
}
out.write_str("\n");
}
-fn iter_crate_items(bytes: @~[u8], proc: fn(str, ast::def_id)) {
+fn iter_crate_items(bytes: @~[u8], proc: fn(uint, str, ast::def_id)) {
let md = ebml::doc(bytes);
let paths = ebml::get_doc(md, tag_paths);
let index = ebml::get_doc(paths, tag_index);
@@ -842,10 +846,10 @@ fn iter_crate_items(bytes: @~[u8], proc: fn(str, ast::def_id)) {
let et = tag_index_buckets_bucket_elt;
do ebml::tagged_docs(bucket, et) |elt| {
let data = read_path(elt);
- let {tag:_, doc:def} = ebml::doc_at(bytes, data.pos);
+ let {tag:t, doc:def} = ebml::doc_at(bytes, data.pos);
let did_doc = ebml::get_doc(def, tag_def_id);
let did = ebml::with_doc_data(did_doc, |d| parse_def_id(d));
- proc(data.path, did);
+ proc(t, data.path, did);
};
};
}
@@ -859,7 +863,7 @@ fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, str)] {
// fowarded path due to renamed import or reexport
let mut res = ~[];
let mods = map::str_hash();
- do iter_crate_items(bytes) |path, did| {
+ do iter_crate_items(bytes) |_tag, path, did| {
let m = mod_of_path(path);
if str::is_not_empty(m) {
// if m has a sub-item, it must be a module
@@ -131,8 +131,11 @@ fn add_to_index(ebml_w: ebml::writer, path: &[ident], &index: ~[entry<str>],
fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod,
path: ~[ident], &index: ~[entry<str>]) {
for nmod.items.each |nitem| {
- add_to_index(ebml_w, path, index, nitem.ident);
- encode_named_def_id(ebml_w, nitem.ident, local_def(nitem.id));
+ add_to_index(ebml_w, path, index, nitem.ident);
+ do ebml_w.wr_tag(tag_paths_foreign_path) {
+ encode_name(ebml_w, nitem.ident);
+ encode_def_id(ebml_w, local_def(nitem.id));
+ }
}
}
@@ -244,7 +247,9 @@ fn encode_reexport_paths(ebml_w: ebml::writer,
for ecx.reexports.each |reexport| {
let (path, def_id) = reexport;
vec::push(index, {val: path, pos: ebml_w.writer.tell()});
- ebml_w.start_tag(tag_paths_data_item);
+ // List metadata ignores tag_paths_foreign_path things, but
+ // other things look at it.
+ ebml_w.start_tag(tag_paths_foreign_path);
encode_name(ebml_w, @path);
encode_def_id(ebml_w, def_id);
ebml_w.end_tag();

0 comments on commit 271da61

Please sign in to comment.