Skip to content

Disallow implementation of cross-crate priv traits #11628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,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() {}