Skip to content

Commit 6d58c70

Browse files
committed
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
2 parents 7d79cc7 + d37e2f7 commit 6d58c70

File tree

7 files changed

+41
-8
lines changed

7 files changed

+41
-8
lines changed

src/librustc/metadata/encoder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
11951195
encode_trait_ref(ebml_w, ecx, trait_def.trait_ref, tag_item_trait_ref);
11961196
encode_name(ecx, ebml_w, item.ident);
11971197
encode_attributes(ebml_w, item.attrs);
1198+
encode_visibility(ebml_w, vis);
11981199
for &method_def_id in ty::trait_method_def_ids(tcx, def_id).iter() {
11991200
ebml_w.start_tag(tag_item_trait_method);
12001201
encode_def_id(ebml_w, method_def_id);

src/test/auxiliary/cci_impl_lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#[crate_id="cci_impl_lib"];
1212

13-
trait uint_helpers {
13+
pub trait uint_helpers {
1414
fn to(&self, v: uint, f: |uint|);
1515
}
1616

src/test/auxiliary/issue_3979_traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
#[crate_type = "lib"];
1414

15-
trait Positioned {
15+
pub trait Positioned {
1616
fn SetX(&mut self, int);
1717
fn X(&self) -> int;
1818
}
1919

20-
trait Movable: Positioned {
20+
pub trait Movable: Positioned {
2121
fn translate(&mut self, dx: int) {
2222
let x = self.X() + dx;
2323
self.SetX(x);
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo {}

src/test/auxiliary/trait_default_method_xc_aux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl A for Something {
1818
fn f(&self) -> int { 10 }
1919
}
2020

21-
trait B<T> {
21+
pub trait B<T> {
2222
fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
2323
fn staticthing<U>(_z: &Self, x: T, y: U) -> (T, U) { (x, y) }
2424
}

src/test/auxiliary/trait_inheritance_auto_xc_aux.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
trait Foo { fn f(&self) -> int; }
12-
trait Bar { fn g(&self) -> int; }
13-
trait Baz { fn h(&self) -> int; }
11+
pub trait Foo { fn f(&self) -> int; }
12+
pub trait Bar { fn g(&self) -> int; }
13+
pub trait Baz { fn h(&self) -> int; }
1414

15-
trait Quux: Foo + Bar + Baz { }
15+
pub trait Quux: Foo + Bar + Baz { }
1616

1717
impl<T:Foo + Bar + Baz> Quux for T { }

src/test/compile-fail/issue-11593.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:private_trait_xc.rs
12+
13+
extern mod private_trait_xc;
14+
15+
struct Bar;
16+
17+
impl private_trait_xc::Foo for Bar {}
18+
//~^ ERROR: trait `Foo` is private
19+
20+
fn main() {}
21+

0 commit comments

Comments
 (0)