about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-09-23 04:15:37 +0000
committerbors <bors@rust-lang.org>2014-09-23 04:15:37 +0000
commit3941d3c3942a4360bcce4635bfdb33f8382d8f2e (patch)
treeb5c58d05d48b523da9c0abf058fb3139c60173d2 /src/test
parent3f299ff19ddb3ee4752e6db120689189ab4c4231 (diff)
parente9ad12c0cae5c43ada6641c7dc840a0fbe5010a2 (diff)
downloadrust-3941d3c3942a4360bcce4635bfdb33f8382d8f2e.tar.gz
rust-3941d3c3942a4360bcce4635bfdb33f8382d8f2e.zip
auto merge of #17401 : pcwalton/rust/private-items-in-public-apis, r=alexcrichton
This breaks code like:

    struct Foo {
        ...
    }

    pub fn make_foo() -> Foo {
        ...
    }

Change this code to:

    pub struct Foo {    // note `pub`
        ...
    }

    pub fn make_foo() -> Foo {
        ...
    }

The `visible_private_types` lint has been removed, since it is now an
error to attempt to expose a private type in a public API.

Closes #16463.

RFC #48.

[breaking-change]

r? @alexcrichton 
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/iss.rs2
-rw-r--r--src/test/auxiliary/noexporttypelib.rs2
-rw-r--r--src/test/auxiliary/priv-impl-prim-ty.rs2
-rw-r--r--src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs2
-rw-r--r--src/test/codegen/static-method-call-multi.rs2
-rw-r--r--src/test/codegen/static-method-call.rs2
-rw-r--r--src/test/codegen/virtual-method-call-struct-return.rs4
-rw-r--r--src/test/codegen/virtual-method-call.rs2
-rw-r--r--src/test/compile-fail/lint-dead-code-1.rs3
-rw-r--r--src/test/compile-fail/visible-private-types-generics.rs26
-rw-r--r--src/test/compile-fail/visible-private-types-supertrait.rs16
-rw-r--r--src/test/run-pass/deriving-enum-single-variant.rs2
-rw-r--r--src/test/run-pass/extern-pass-TwoU16s.rs2
-rw-r--r--src/test/run-pass/extern-pass-TwoU32s.rs2
-rw-r--r--src/test/run-pass/extern-pass-TwoU64s.rs2
-rw-r--r--src/test/run-pass/extern-pass-TwoU8s.rs2
-rw-r--r--src/test/run-pass/extern-return-TwoU16s.rs2
-rw-r--r--src/test/run-pass/extern-return-TwoU32s.rs2
-rw-r--r--src/test/run-pass/extern-return-TwoU64s.rs2
-rw-r--r--src/test/run-pass/extern-return-TwoU8s.rs2
-rw-r--r--src/test/run-pass/issue-10902.rs8
-rw-r--r--src/test/run-pass/issue-3656.rs2
-rw-r--r--src/test/run-pass/issue-3753.rs2
-rw-r--r--src/test/run-pass/issue-5708.rs2
-rw-r--r--src/test/run-pass/regions-no-variance-from-fn-generics.rs4
-rw-r--r--src/test/run-pass/struct-partial-move-1.rs2
-rw-r--r--src/test/run-pass/struct-partial-move-2.rs4
-rw-r--r--src/test/run-pass/trait-inheritance-num0.rs2
-rw-r--r--src/test/run-pass/trait-inheritance-static.rs2
-rw-r--r--src/test/run-pass/trait-inheritance-static2.rs4
-rw-r--r--src/test/run-pass/visible-private-types-feature-gate.rs22
31 files changed, 99 insertions, 36 deletions
diff --git a/src/test/auxiliary/iss.rs b/src/test/auxiliary/iss.rs
index 095cc3ec1a0..75728c075d1 100644
--- a/src/test/auxiliary/iss.rs
+++ b/src/test/auxiliary/iss.rs
@@ -12,7 +12,7 @@
 
 // part of issue-6919.rs
 
-struct C<'a> {
+pub struct C<'a> {
     pub k: ||: 'a,
 }
 
diff --git a/src/test/auxiliary/noexporttypelib.rs b/src/test/auxiliary/noexporttypelib.rs
index 4e9e3688ecd..94b079b1dcf 100644
--- a/src/test/auxiliary/noexporttypelib.rs
+++ b/src/test/auxiliary/noexporttypelib.rs
@@ -8,5 +8,5 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-type oint = Option<int>;
+pub type oint = Option<int>;
 pub fn foo() -> oint { Some(3) }
diff --git a/src/test/auxiliary/priv-impl-prim-ty.rs b/src/test/auxiliary/priv-impl-prim-ty.rs
index 16d3ca8fa64..8c07dd5b785 100644
--- a/src/test/auxiliary/priv-impl-prim-ty.rs
+++ b/src/test/auxiliary/priv-impl-prim-ty.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-trait A {
+pub trait A {
     fn frob(&self);
 }
 
diff --git a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs
index a7429ca534b..1e9fd035f44 100644
--- a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs
+++ b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs
@@ -16,7 +16,7 @@ pub enum MaybeOwned<'a> {
     Borrowed(&'a int)
 }
 
-struct Inv<'a> { // invariant w/r/t 'a
+pub struct Inv<'a> { // invariant w/r/t 'a
     x: &'a mut &'a int
 }
 
diff --git a/src/test/codegen/static-method-call-multi.rs b/src/test/codegen/static-method-call-multi.rs
index efac93692f6..996d2203824 100644
--- a/src/test/codegen/static-method-call-multi.rs
+++ b/src/test/codegen/static-method-call-multi.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct Struct {
+pub struct Struct {
     field: int
 }
 
diff --git a/src/test/codegen/static-method-call.rs b/src/test/codegen/static-method-call.rs
index 79fb9d8aa29..9c5894fb97a 100644
--- a/src/test/codegen/static-method-call.rs
+++ b/src/test/codegen/static-method-call.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct Struct {
+pub struct Struct {
     field: int
 }
 
diff --git a/src/test/codegen/virtual-method-call-struct-return.rs b/src/test/codegen/virtual-method-call-struct-return.rs
index 20bda755f37..ff1a611c4ef 100644
--- a/src/test/codegen/virtual-method-call-struct-return.rs
+++ b/src/test/codegen/virtual-method-call-struct-return.rs
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct Stuff {
+pub struct Stuff {
   a: int,
   b: f64
 }
 
-trait Trait {
+pub trait Trait {
     fn method(&self) -> Stuff;
 }
 
diff --git a/src/test/codegen/virtual-method-call.rs b/src/test/codegen/virtual-method-call.rs
index 513a299cc63..036c0957e99 100644
--- a/src/test/codegen/virtual-method-call.rs
+++ b/src/test/codegen/virtual-method-call.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-trait Trait {
+pub trait Trait {
     fn method(&self) -> int;
 }
 
diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs
index 8417f7810ea..a2d2c02dc43 100644
--- a/src/test/compile-fail/lint-dead-code-1.rs
+++ b/src/test/compile-fail/lint-dead-code-1.rs
@@ -11,7 +11,6 @@
 #![no_std]
 #![allow(unused_variable)]
 #![allow(non_camel_case_types)]
-#![allow(visible_private_types)]
 #![deny(dead_code)]
 #![feature(lang_items)]
 
@@ -54,7 +53,7 @@ impl SemiUsedStruct {
     fn la_la_la() {}
 }
 struct StructUsedAsField;
-struct StructUsedInEnum;
+pub struct StructUsedInEnum;
 struct StructUsedInGeneric;
 pub struct PubStruct2 {
     #[allow(dead_code)]
diff --git a/src/test/compile-fail/visible-private-types-generics.rs b/src/test/compile-fail/visible-private-types-generics.rs
new file mode 100644
index 00000000000..740848e93cb
--- /dev/null
+++ b/src/test/compile-fail/visible-private-types-generics.rs
@@ -0,0 +1,26 @@
+// 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 {}
+
+pub fn f<T:Foo>() {}    //~ ERROR private type in exported type
+
+pub fn g<T>() where T: Foo {}   //~ ERROR private type in exported type
+
+pub struct H<T:Foo> {   //~ ERROR private type in exported type
+    x: T,
+}
+
+pub struct I<T> where T: Foo {  //~ ERROR private type in exported type
+    x: T,
+}
+
+fn main() {}
+
diff --git a/src/test/compile-fail/visible-private-types-supertrait.rs b/src/test/compile-fail/visible-private-types-supertrait.rs
new file mode 100644
index 00000000000..c4457aaf1e1
--- /dev/null
+++ b/src/test/compile-fail/visible-private-types-supertrait.rs
@@ -0,0 +1,16 @@
+// 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 {}
+
+pub trait Bar : Foo {}  //~ ERROR private type in exported type
+
+fn main() {}
+
diff --git a/src/test/run-pass/deriving-enum-single-variant.rs b/src/test/run-pass/deriving-enum-single-variant.rs
index fc03763a3b7..a9bdcf2734b 100644
--- a/src/test/run-pass/deriving-enum-single-variant.rs
+++ b/src/test/run-pass/deriving-enum-single-variant.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-type task_id = int;
+pub type task_id = int;
 
 #[deriving(PartialEq)]
 pub enum Task {
diff --git a/src/test/run-pass/extern-pass-TwoU16s.rs b/src/test/run-pass/extern-pass-TwoU16s.rs
index 8a9231b640e..6161d31c4a9 100644
--- a/src/test/run-pass/extern-pass-TwoU16s.rs
+++ b/src/test/run-pass/extern-pass-TwoU16s.rs
@@ -12,7 +12,7 @@
 // by value.
 
 #[deriving(PartialEq, Show)]
-struct TwoU16s {
+pub struct TwoU16s {
     one: u16, two: u16
 }
 
diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs
index 480eef1c6e9..3e6b6502074 100644
--- a/src/test/run-pass/extern-pass-TwoU32s.rs
+++ b/src/test/run-pass/extern-pass-TwoU32s.rs
@@ -12,7 +12,7 @@
 // by value.
 
 #[deriving(PartialEq, Show)]
-struct TwoU32s {
+pub struct TwoU32s {
     one: u32, two: u32
 }
 
diff --git a/src/test/run-pass/extern-pass-TwoU64s.rs b/src/test/run-pass/extern-pass-TwoU64s.rs
index ca0df4728c6..5ad1e89425b 100644
--- a/src/test/run-pass/extern-pass-TwoU64s.rs
+++ b/src/test/run-pass/extern-pass-TwoU64s.rs
@@ -12,7 +12,7 @@
 // by value.
 
 #[deriving(PartialEq, Show)]
-struct TwoU64s {
+pub struct TwoU64s {
     one: u64, two: u64
 }
 
diff --git a/src/test/run-pass/extern-pass-TwoU8s.rs b/src/test/run-pass/extern-pass-TwoU8s.rs
index 7aeb0a0ec84..14ba7c80059 100644
--- a/src/test/run-pass/extern-pass-TwoU8s.rs
+++ b/src/test/run-pass/extern-pass-TwoU8s.rs
@@ -12,7 +12,7 @@
 // by value.
 
 #[deriving(PartialEq, Show)]
-struct TwoU8s {
+pub struct TwoU8s {
     one: u8, two: u8
 }
 
diff --git a/src/test/run-pass/extern-return-TwoU16s.rs b/src/test/run-pass/extern-return-TwoU16s.rs
index 95352e67020..ca9767307f4 100644
--- a/src/test/run-pass/extern-return-TwoU16s.rs
+++ b/src/test/run-pass/extern-return-TwoU16s.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct TwoU16s {
+pub struct TwoU16s {
     one: u16, two: u16
 }
 
diff --git a/src/test/run-pass/extern-return-TwoU32s.rs b/src/test/run-pass/extern-return-TwoU32s.rs
index 81bd0e9559d..8d650459daa 100644
--- a/src/test/run-pass/extern-return-TwoU32s.rs
+++ b/src/test/run-pass/extern-return-TwoU32s.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct TwoU32s {
+pub struct TwoU32s {
     one: u32, two: u32
 }
 
diff --git a/src/test/run-pass/extern-return-TwoU64s.rs b/src/test/run-pass/extern-return-TwoU64s.rs
index 7c37e0f4e68..924aaf811f4 100644
--- a/src/test/run-pass/extern-return-TwoU64s.rs
+++ b/src/test/run-pass/extern-return-TwoU64s.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct TwoU64s {
+pub struct TwoU64s {
     one: u64, two: u64
 }
 
diff --git a/src/test/run-pass/extern-return-TwoU8s.rs b/src/test/run-pass/extern-return-TwoU8s.rs
index d20f5475c4e..1dbce403cc8 100644
--- a/src/test/run-pass/extern-return-TwoU8s.rs
+++ b/src/test/run-pass/extern-return-TwoU8s.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct TwoU8s {
+pub struct TwoU8s {
     one: u8, two: u8
 }
 
diff --git a/src/test/run-pass/issue-10902.rs b/src/test/run-pass/issue-10902.rs
index f8fd96166ea..84d71e1ef5d 100644
--- a/src/test/run-pass/issue-10902.rs
+++ b/src/test/run-pass/issue-10902.rs
@@ -9,16 +9,16 @@
 // except according to those terms.
 
 pub mod two_tuple {
-    trait T {}
-    struct P<'a>(&'a T + 'a, &'a T + 'a);
+    pub trait T {}
+    pub struct P<'a>(&'a T + 'a, &'a T + 'a);
     pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
         P(car, cdr)
     }
 }
 
 pub mod two_fields {
-    trait T {}
-    struct P<'a> { car: &'a T + 'a, cdr: &'a T + 'a }
+    pub trait T {}
+    pub struct P<'a> { car: &'a T + 'a, cdr: &'a T + 'a }
     pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
         P{ car: car, cdr: cdr }
     }
diff --git a/src/test/run-pass/issue-3656.rs b/src/test/run-pass/issue-3656.rs
index 8fd603781ba..53157ce7546 100644
--- a/src/test/run-pass/issue-3656.rs
+++ b/src/test/run-pass/issue-3656.rs
@@ -15,7 +15,7 @@
 extern crate libc;
 use libc::{c_uint, uint32_t, c_void};
 
-struct KEYGEN {
+pub struct KEYGEN {
     hash_algorithm: [c_uint, ..2],
     count: uint32_t,
     salt: *const c_void,
diff --git a/src/test/run-pass/issue-3753.rs b/src/test/run-pass/issue-3753.rs
index fe2d729bc9e..951832a14aa 100644
--- a/src/test/run-pass/issue-3753.rs
+++ b/src/test/run-pass/issue-3753.rs
@@ -14,7 +14,7 @@
 
 use std::f64;
 
-struct Point {
+pub struct Point {
     x: f64,
     y: f64
 }
diff --git a/src/test/run-pass/issue-5708.rs b/src/test/run-pass/issue-5708.rs
index 6168753b6d7..9c728005b6f 100644
--- a/src/test/run-pass/issue-5708.rs
+++ b/src/test/run-pass/issue-5708.rs
@@ -48,7 +48,7 @@ pub fn main() {
 
 
 // minimal
-trait MyTrait<T> { }
+pub trait MyTrait<T> { }
 
 pub struct MyContainer<'a, T> {
     foos: Vec<&'a MyTrait<T>+'a> ,
diff --git a/src/test/run-pass/regions-no-variance-from-fn-generics.rs b/src/test/run-pass/regions-no-variance-from-fn-generics.rs
index 3814de79bb6..a35ab1bfc0c 100644
--- a/src/test/run-pass/regions-no-variance-from-fn-generics.rs
+++ b/src/test/run-pass/regions-no-variance-from-fn-generics.rs
@@ -12,7 +12,7 @@
 // should not upset the variance inference for actual occurrences of
 // that lifetime in type expressions.
 
-trait HasLife<'a> { }
+pub trait HasLife<'a> { }
 
 trait UseLife01 {
     fn refs<'a, H: HasLife<'a>>(&'a self) -> H;
@@ -23,7 +23,7 @@ trait UseLife02 {
 }
 
 
-trait HasType<T> { }
+pub trait HasType<T> { }
 
 trait UseLife03<T> {
     fn refs<'a, H: HasType<&'a T>>(&'a self) -> H;
diff --git a/src/test/run-pass/struct-partial-move-1.rs b/src/test/run-pass/struct-partial-move-1.rs
index 7e02d102081..d64408ec42f 100644
--- a/src/test/run-pass/struct-partial-move-1.rs
+++ b/src/test/run-pass/struct-partial-move-1.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 #[deriving(PartialEq, Show)]
-struct Partial<T> { x: T, y: T }
+pub struct Partial<T> { x: T, y: T }
 
 #[deriving(PartialEq, Show)]
 struct S { val: int }
diff --git a/src/test/run-pass/struct-partial-move-2.rs b/src/test/run-pass/struct-partial-move-2.rs
index fe5e1eaaa1a..0e77079ed05 100644
--- a/src/test/run-pass/struct-partial-move-2.rs
+++ b/src/test/run-pass/struct-partial-move-2.rs
@@ -9,14 +9,14 @@
 // except according to those terms.
 
 #[deriving(PartialEq, Show)]
-struct Partial<T> { x: T, y: T }
+pub struct Partial<T> { x: T, y: T }
 
 #[deriving(PartialEq, Show)]
 struct S { val: int }
 impl S { fn new(v: int) -> S { S { val: v } } }
 impl Drop for S { fn drop(&mut self) { } }
 
-type Two<T> = (Partial<T>, Partial<T>);
+pub type Two<T> = (Partial<T>, Partial<T>);
 
 pub fn f<T>((b1, b2): (T, T), (b3, b4): (T, T), f: |T| -> T) -> Two<T> {
     let p = Partial { x: b1, y: b2 };
diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs
index 58709ab4c85..16e702bb79a 100644
--- a/src/test/run-pass/trait-inheritance-num0.rs
+++ b/src/test/run-pass/trait-inheritance-num0.rs
@@ -13,7 +13,7 @@
 
 use std::num::NumCast;
 
-trait Num {
+pub trait Num {
     fn from_int(i: int) -> Self;
     fn gt(&self, other: &Self) -> bool;
 }
diff --git a/src/test/run-pass/trait-inheritance-static.rs b/src/test/run-pass/trait-inheritance-static.rs
index 08543b236f3..611c3e006ec 100644
--- a/src/test/run-pass/trait-inheritance-static.rs
+++ b/src/test/run-pass/trait-inheritance-static.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-trait MyNum {
+pub trait MyNum {
     fn from_int(int) -> Self;
 }
 
diff --git a/src/test/run-pass/trait-inheritance-static2.rs b/src/test/run-pass/trait-inheritance-static2.rs
index 95131176ce7..3b454aad03e 100644
--- a/src/test/run-pass/trait-inheritance-static2.rs
+++ b/src/test/run-pass/trait-inheritance-static2.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-trait MyEq { }
+pub trait MyEq { }
 
-trait MyNum {
+pub trait MyNum {
     fn from_int(int) -> Self;
 }
 
diff --git a/src/test/run-pass/visible-private-types-feature-gate.rs b/src/test/run-pass/visible-private-types-feature-gate.rs
new file mode 100644
index 00000000000..9518671b479
--- /dev/null
+++ b/src/test/run-pass/visible-private-types-feature-gate.rs
@@ -0,0 +1,22 @@
+// 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.
+
+#![feature(visible_private_types)]
+
+trait Foo {}
+
+pub trait Bar : Foo {}
+
+struct Baz;
+
+pub fn f(_: Baz) {}
+
+fn main() {}
+