Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly encode item visibility in metadata #9432

Merged
merged 2 commits into from
Sep 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/etc/combine-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def scrub(b):
if not ("xfail-test" in s or
"xfail-fast" in s or
"xfail-win32" in s):
if not "pub fn main" in s and "fn main" in s:
print("Warning: no public entry point in " + t)
stage2_tests.append(t)
f.close()

Expand Down
4 changes: 2 additions & 2 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct MutexArcInner<T> { priv lock: Mutex, priv failed: bool, priv data: T }

/// An Arc with mutable data protected by a blocking mutex.
#[no_freeze]
struct MutexArc<T> { priv x: UnsafeArc<MutexArcInner<T>> }
pub struct MutexArc<T> { priv x: UnsafeArc<MutexArcInner<T>> }


impl<T:Send> Clone for MutexArc<T> {
Expand Down Expand Up @@ -343,7 +343,7 @@ struct RWArcInner<T> { priv lock: RWLock, priv failed: bool, priv data: T }
* Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested.
*/
#[no_freeze]
struct RWArc<T> {
pub struct RWArc<T> {
priv x: UnsafeArc<RWArcInner<T>>,
}

Expand Down
12 changes: 6 additions & 6 deletions src/libextra/workcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl WorkMap {
}
}

struct Database {
pub struct Database {
db_filename: Path,
db_cache: TreeMap<~str, ~str>,
db_dirty: bool
Expand Down Expand Up @@ -207,7 +207,7 @@ impl Drop for Database {
}
}

struct Logger {
pub struct Logger {
// FIXME #4432: Fill in
a: ()
}
Expand All @@ -223,10 +223,10 @@ impl Logger {
}
}

type FreshnessMap = TreeMap<~str,extern fn(&str,&str)->bool>;
pub type FreshnessMap = TreeMap<~str,extern fn(&str,&str)->bool>;

#[deriving(Clone)]
struct Context {
pub struct Context {
db: RWArc<Database>,
logger: RWArc<Logger>,
cfg: Arc<json::Object>,
Expand All @@ -239,13 +239,13 @@ struct Context {
freshness: Arc<FreshnessMap>
}

struct Prep<'self> {
pub struct Prep<'self> {
ctxt: &'self Context,
fn_name: &'self str,
declared_inputs: WorkMap,
}

struct Exec {
pub struct Exec {
discovered_inputs: WorkMap,
discovered_outputs: WorkMap
}
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ pub fn phase_2_configure_and_expand(sess: Session,

pub struct CrateAnalysis {
exp_map2: middle::resolve::ExportMap2,
exported_items: @middle::privacy::ExportedItems,
ty_cx: ty::ctxt,
maps: astencode::Maps,
reachable: @mut HashSet<ast::NodeId>
Expand Down Expand Up @@ -258,8 +259,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
middle::check_const::check_crate(sess, crate, ast_map, def_map,
method_map, ty_cx));

time(time_passes, ~"privacy checking", ||
middle::privacy::check_crate(ty_cx, &method_map, crate));
let exported_items =
time(time_passes, ~"privacy checking", ||
middle::privacy::check_crate(ty_cx, &method_map, &exp_map2, crate));

time(time_passes, ~"effect checking", ||
middle::effect::check_crate(ty_cx, method_map, crate));
Expand Down Expand Up @@ -301,6 +303,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,

CrateAnalysis {
exp_map2: exp_map2,
exported_items: @exported_items,
ty_cx: ty_cx,
maps: astencode::Maps {
root_map: root_map,
Expand Down
9 changes: 6 additions & 3 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use syntax::diagnostic::expect;
pub struct StaticMethodInfo {
ident: ast::Ident,
def_id: ast::DefId,
purity: ast::purity
purity: ast::purity,
vis: ast::visibility,
}

pub fn get_symbol(cstore: @mut cstore::CStore, def: ast::DefId) -> ~str {
Expand All @@ -52,7 +53,8 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
/// Iterates over each child of the given item.
pub fn each_child_of_item(cstore: @mut cstore::CStore,
def_id: ast::DefId,
callback: &fn(decoder::DefLike, ast::Ident)) {
callback: &fn(decoder::DefLike, ast::Ident,
ast::visibility)) {
let crate_data = cstore::get_crate_data(cstore, def_id.crate);
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
cstore::get_crate_data(cstore, cnum)
Expand All @@ -68,7 +70,8 @@ pub fn each_child_of_item(cstore: @mut cstore::CStore,
pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore,
cnum: ast::CrateNum,
callback: &fn(decoder::DefLike,
ast::Ident)) {
ast::Ident,
ast::visibility)) {
let crate_data = cstore::get_crate_data(cstore, cnum);
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
cstore::get_crate_data(cstore, cnum)
Expand Down
43 changes: 26 additions & 17 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {

// Looks up an item in the given metadata and returns an ebml doc pointing
// to the item data.
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
pub fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
let items = reader::get_doc(reader::Doc(data), tag_items);
find_item(item_id, items)
}
Expand Down Expand Up @@ -291,7 +291,7 @@ fn enum_variant_ids(item: ebml::Doc, cdata: Cmd) -> ~[ast::DefId] {
return ids;
}

fn item_path(item_doc: ebml::Doc) -> ast_map::path {
pub fn item_path(item_doc: ebml::Doc) -> ast_map::path {
let path_doc = reader::get_doc(item_doc, tag_path);

let len_doc = reader::get_doc(path_doc, tag_path_len);
Expand Down Expand Up @@ -332,7 +332,7 @@ fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::Ident {
}
}

fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
pub fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
-> DefLike {
let fam = item_family(item);
match fam {
Expand Down Expand Up @@ -491,7 +491,7 @@ pub enum DefLike {
DlField
}

fn def_like_to_def(def_like: DefLike) -> ast::Def {
pub fn def_like_to_def(def_like: DefLike) -> ast::Def {
match def_like {
DlDef(def) => return def,
DlImpl(*) => fail!("found impl in def_like_to_def"),
Expand Down Expand Up @@ -544,7 +544,8 @@ impl<'self> EachItemContext<'self> {
fn process_item_and_pop_name(&mut self,
doc: ebml::Doc,
def_id: ast::DefId,
old_len: uint)
old_len: uint,
vis: ast::visibility)
-> bool {
let def_like = item_to_def_like(doc, def_id, self.cdata.cnum);
match def_like {
Expand All @@ -563,8 +564,6 @@ impl<'self> EachItemContext<'self> {
}
}

let vis = item_visibility(doc);

let mut continue = (self.callback)(*self.path_builder, def_like, vis);

let family = item_family(doc);
Expand Down Expand Up @@ -653,9 +652,12 @@ impl<'self> EachItemContext<'self> {
self.push_name(token::ident_to_str(&child_name));

// Process this item.

let vis = item_visibility(child_item_doc);
continue = self.process_item_and_pop_name(child_item_doc,
child_def_id,
old_len);
old_len,
vis);
}
}
continue
Expand Down Expand Up @@ -701,12 +703,13 @@ impl<'self> EachItemContext<'self> {

// Get the item.
match maybe_find_item(def_id.node, other_crates_items) {
None => {}
None => { self.pop_name(old_len); }
Some(reexported_item_doc) => {
continue = self.process_item_and_pop_name(
reexported_item_doc,
def_id,
old_len);
old_len,
ast::public);
}
}

Expand All @@ -721,7 +724,8 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
cdata: Cmd,
item_doc: ebml::Doc,
get_crate_data: GetCrateDataCb,
callback: &fn(DefLike, ast::Ident)) {
callback: &fn(DefLike, ast::Ident,
ast::visibility)) {
// Iterate over all children.
let _ = do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| {
let child_def_id = reader::with_doc_data(child_info_doc,
Expand All @@ -746,7 +750,8 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
let def_like = item_to_def_like(child_item_doc,
child_def_id,
cdata.cnum);
callback(def_like, child_name);
let visibility = item_visibility(child_item_doc);
callback(def_like, child_name, visibility);

}
}
Expand Down Expand Up @@ -788,7 +793,8 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
impl_method_def_id,
cdata.cnum);
callback(static_method_def_like,
static_method_name);
static_method_name,
item_visibility(impl_method_doc));
}
_ => {}
}
Expand Down Expand Up @@ -831,7 +837,8 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
let def_like = item_to_def_like(child_item_doc,
child_def_id,
cdata.cnum);
callback(def_like, token::str_to_ident(name));
callback(def_like, token::str_to_ident(name),
item_visibility(child_item_doc));
}
}

Expand All @@ -844,7 +851,7 @@ pub fn each_child_of_item(intr: @ident_interner,
cdata: Cmd,
id: ast::NodeId,
get_crate_data: GetCrateDataCb,
callback: &fn(DefLike, ast::Ident)) {
callback: &fn(DefLike, ast::Ident, ast::visibility)) {
// Find the item.
let root_doc = reader::Doc(cdata.data);
let items = reader::get_doc(root_doc, tag_items);
Expand All @@ -864,7 +871,8 @@ pub fn each_child_of_item(intr: @ident_interner,
pub fn each_top_level_item_of_crate(intr: @ident_interner,
cdata: Cmd,
get_crate_data: GetCrateDataCb,
callback: &fn(DefLike, ast::Ident)) {
callback: &fn(DefLike, ast::Ident,
ast::visibility)) {
let root_doc = reader::Doc(cdata.data);
let misc_info_doc = reader::get_doc(root_doc, tag_misc_info);
let crate_items_doc = reader::get_doc(misc_info_doc,
Expand Down Expand Up @@ -1161,7 +1169,8 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
static_impl_methods.push(StaticMethodInfo {
ident: item_name(intr, impl_method_doc),
def_id: item_def_id(impl_method_doc, cdata),
purity: purity
purity: purity,
vis: item_visibility(impl_method_doc),
});
}
_ => {}
Expand Down
Loading