librustc: Fix bugs regarding to impl privacy. rs=bugfix

This commit is contained in:
Patrick Walton 2013-01-31 12:40:05 -08:00
parent 5d03612f9d
commit 04eb9b4eb0
6 changed files with 47 additions and 3 deletions

View File

@ -547,8 +547,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder,
let tcx = ecx.tcx;
let must_write =
match item.node {
item_enum(_, _) | item_impl(*)
| item_trait(*) | item_struct(*) => true,
item_enum(_, _) | item_impl(*) | item_trait(*) | item_struct(*) |
item_mod(*) | item_foreign_mod(*) => true,
_ => false
};
if !must_write && !reachable(ecx, item.id) { return; }

View File

@ -1212,7 +1212,7 @@ pub impl Resolver {
let parent_link = self.get_parent_link(new_parent,
ident);
let def_id = local_def(item.id);
name_bindings.define_module(privacy,
name_bindings.define_module(Public,
parent_link,
Some(def_id),
TraitModuleKind,

View File

@ -0,0 +1,10 @@
#[crate_type = "lib"];
pub struct Fish {
x: int
}
impl Fish {
fn swim(&self) {}
}

View File

@ -0,0 +1,15 @@
#[crate_type = "lib"];
pub struct Fish {
x: int
}
mod unexported {
use super::Fish;
impl Fish : Eq {
pure fn eq(&self, _: &Fish) -> bool { true }
pure fn ne(&self, _: &Fish) -> bool { false }
}
}

View File

@ -0,0 +1,9 @@
// aux-build:impl_privacy_xc_1.rs
extern mod impl_privacy_xc_1;
fn main() {
let fish = impl_privacy_xc_1::Fish { x: 1 };
fish.swim();
}

View File

@ -0,0 +1,10 @@
// aux-build:impl_privacy_xc_2.rs
extern mod impl_privacy_xc_2;
fn main() {
let fish1 = impl_privacy_xc_2::Fish { x: 1 };
let fish2 = impl_privacy_xc_2::Fish { x: 2 };
io::println(if fish1.eq(&fish2) { "yes" } else { "no " });
}