auto merge of #11628 : alexcrichton/rust/issue-11593, r=brson

Turns out we were just forgetting to encode the privacy for trais, and
everything without privacy defaults to public!

Closes #11593
This commit is contained in:
bors 2014-01-19 00:36:48 -08:00
commit 6d58c70fb3
7 changed files with 41 additions and 8 deletions

View File

@ -1195,6 +1195,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_trait_ref(ebml_w, ecx, trait_def.trait_ref, tag_item_trait_ref);
encode_name(ecx, ebml_w, item.ident);
encode_attributes(ebml_w, item.attrs);
encode_visibility(ebml_w, vis);
for &method_def_id in ty::trait_method_def_ids(tcx, def_id).iter() {
ebml_w.start_tag(tag_item_trait_method);
encode_def_id(ebml_w, method_def_id);

View File

@ -10,7 +10,7 @@
#[crate_id="cci_impl_lib"];
trait uint_helpers {
pub trait uint_helpers {
fn to(&self, v: uint, f: |uint|);
}

View File

@ -12,12 +12,12 @@
#[crate_type = "lib"];
trait Positioned {
pub trait Positioned {
fn SetX(&mut self, int);
fn X(&self) -> int;
}
trait Movable: Positioned {
pub trait Movable: Positioned {
fn translate(&mut self, dx: int) {
let x = self.X() + dx;
self.SetX(x);

View File

@ -0,0 +1,11 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait Foo {}

View File

@ -18,7 +18,7 @@ impl A for Something {
fn f(&self) -> int { 10 }
}
trait B<T> {
pub trait B<T> {
fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
fn staticthing<U>(_z: &Self, x: T, y: U) -> (T, U) { (x, y) }
}

View File

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait Foo { fn f(&self) -> int; }
trait Bar { fn g(&self) -> int; }
trait Baz { fn h(&self) -> int; }
pub trait Foo { fn f(&self) -> int; }
pub trait Bar { fn g(&self) -> int; }
pub trait Baz { fn h(&self) -> int; }
trait Quux: Foo + Bar + Baz { }
pub trait Quux: Foo + Bar + Baz { }
impl<T:Foo + Bar + Baz> Quux for T { }

View File

@ -0,0 +1,21 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:private_trait_xc.rs
extern mod private_trait_xc;
struct Bar;
impl private_trait_xc::Foo for Bar {}
//~^ ERROR: trait `Foo` is private
fn main() {}