Skip to content

Commit

Permalink
auto merge of #11628 : alexcrichton/rust/issue-11593, r=brson
Browse files Browse the repository at this point in the history
Turns out we were just forgetting to encode the privacy for trais, and
everything without privacy defaults to public!

Closes #11593
  • Loading branch information
bors committed Jan 19, 2014
2 parents 7d79cc7 + d37e2f7 commit 6d58c70
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/cci_impl_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#[crate_id="cci_impl_lib"];

trait uint_helpers {
pub trait uint_helpers {
fn to(&self, v: uint, f: |uint|);
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/issue_3979_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/test/auxiliary/private_trait_xc.rs
Original file line number Diff line number Diff line change
@@ -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 {}
2 changes: 1 addition & 1 deletion src/test/auxiliary/trait_default_method_xc_aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/auxiliary/trait_inheritance_auto_xc_aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
21 changes: 21 additions & 0 deletions src/test/compile-fail/issue-11593.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 6d58c70

Please sign in to comment.