diff options
| author | bors <bors@rust-lang.org> | 2014-01-19 00:36:48 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-19 00:36:48 -0800 |
| commit | 6d58c70fb3c9bb0160f51368e1acaaa175747734 (patch) | |
| tree | 7e0a7aff2a347db895113f8bfbbfc4868377ec8d | |
| parent | 7d79cc73fb4c0fcbdf8bb47a3c96ae9dadbd1895 (diff) | |
| parent | d37e2f79cc049331a6fbde3ae5cc75a8e08ecb08 (diff) | |
| download | rust-6d58c70fb3c9bb0160f51368e1acaaa175747734.tar.gz rust-6d58c70fb3c9bb0160f51368e1acaaa175747734.zip | |
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
| -rw-r--r-- | src/librustc/metadata/encoder.rs | 1 | ||||
| -rw-r--r-- | src/test/auxiliary/cci_impl_lib.rs | 2 | ||||
| -rw-r--r-- | src/test/auxiliary/issue_3979_traits.rs | 4 | ||||
| -rw-r--r-- | src/test/auxiliary/private_trait_xc.rs | 11 | ||||
| -rw-r--r-- | src/test/auxiliary/trait_default_method_xc_aux.rs | 2 | ||||
| -rw-r--r-- | src/test/auxiliary/trait_inheritance_auto_xc_aux.rs | 8 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-11593.rs | 21 |
7 files changed, 41 insertions, 8 deletions
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 5271d6ceba6..baa72105577 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -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); diff --git a/src/test/auxiliary/cci_impl_lib.rs b/src/test/auxiliary/cci_impl_lib.rs index 28c0c3062f3..6301158714a 100644 --- a/src/test/auxiliary/cci_impl_lib.rs +++ b/src/test/auxiliary/cci_impl_lib.rs @@ -10,7 +10,7 @@ #[crate_id="cci_impl_lib"]; -trait uint_helpers { +pub trait uint_helpers { fn to(&self, v: uint, f: |uint|); } diff --git a/src/test/auxiliary/issue_3979_traits.rs b/src/test/auxiliary/issue_3979_traits.rs index 75bdad7c95e..7b8d7e0d4d9 100644 --- a/src/test/auxiliary/issue_3979_traits.rs +++ b/src/test/auxiliary/issue_3979_traits.rs @@ -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); diff --git a/src/test/auxiliary/private_trait_xc.rs b/src/test/auxiliary/private_trait_xc.rs new file mode 100644 index 00000000000..37ee10c8d37 --- /dev/null +++ b/src/test/auxiliary/private_trait_xc.rs @@ -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 {} diff --git a/src/test/auxiliary/trait_default_method_xc_aux.rs b/src/test/auxiliary/trait_default_method_xc_aux.rs index 9ed45da9e17..0012d3e36c6 100644 --- a/src/test/auxiliary/trait_default_method_xc_aux.rs +++ b/src/test/auxiliary/trait_default_method_xc_aux.rs @@ -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) } } diff --git a/src/test/auxiliary/trait_inheritance_auto_xc_aux.rs b/src/test/auxiliary/trait_inheritance_auto_xc_aux.rs index d5949d1ce09..59fdaed744e 100644 --- a/src/test/auxiliary/trait_inheritance_auto_xc_aux.rs +++ b/src/test/auxiliary/trait_inheritance_auto_xc_aux.rs @@ -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 { } diff --git a/src/test/compile-fail/issue-11593.rs b/src/test/compile-fail/issue-11593.rs new file mode 100644 index 00000000000..9ca91f067ba --- /dev/null +++ b/src/test/compile-fail/issue-11593.rs @@ -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() {} + |
