summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-08-09 01:25:24 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-08-12 23:20:46 -0700
commit930885d5e5f817e3d7609f93d5ba89b1abebfaf4 (patch)
tree16719bb119d7e3f0aa056d4c3391d6e968bd1198 /src/test
parent44675ac6aff91889f960655b0034964740415e8c (diff)
downloadrust-930885d5e5f817e3d7609f93d5ba89b1abebfaf4.tar.gz
rust-930885d5e5f817e3d7609f93d5ba89b1abebfaf4.zip
Forbid pub/priv where it has no effect
Closes #5495
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/private_variant_xc.rs2
-rw-r--r--src/test/auxiliary/reexported_static_methods.rs8
-rw-r--r--src/test/compile-fail/lint-missing-doc.rs12
-rw-r--r--src/test/compile-fail/useless-priv.rs25
-rw-r--r--src/test/compile-fail/useless-priv2.rs19
-rw-r--r--src/test/run-pass/bug-7295.rs4
-rw-r--r--src/test/run-pass/issue-7712.rs2
-rw-r--r--src/test/run-pass/static-methods-in-traits.rs6
8 files changed, 60 insertions, 18 deletions
diff --git a/src/test/auxiliary/private_variant_xc.rs b/src/test/auxiliary/private_variant_xc.rs
index a3a604d9e78..e1ecbf8c543 100644
--- a/src/test/auxiliary/private_variant_xc.rs
+++ b/src/test/auxiliary/private_variant_xc.rs
@@ -1,4 +1,4 @@
 pub enum Foo {
-    pub Bar,
+    Bar,
     priv Baz,
 }
diff --git a/src/test/auxiliary/reexported_static_methods.rs b/src/test/auxiliary/reexported_static_methods.rs
index 811bf082ae8..bb20b04762d 100644
--- a/src/test/auxiliary/reexported_static_methods.rs
+++ b/src/test/auxiliary/reexported_static_methods.rs
@@ -14,20 +14,20 @@ pub use sub_foo::Boz;
 pub use sub_foo::Bort;
 
 pub trait Bar {
-    pub fn bar() -> Self;
+    fn bar() -> Self;
 }
 
 impl Bar for int {
-    pub fn bar() -> int { 84 }
+    fn bar() -> int { 84 }
 }
 
 pub mod sub_foo {
     pub trait Foo {
-        pub fn foo() -> Self;
+        fn foo() -> Self;
     }
 
     impl Foo for int {
-        pub fn foo() -> int { 42 }
+        fn foo() -> int { 42 }
     }
 
     pub struct Boz {
diff --git a/src/test/compile-fail/lint-missing-doc.rs b/src/test/compile-fail/lint-missing-doc.rs
index 2350ca68b97..75bc93c6d0b 100644
--- a/src/test/compile-fail/lint-missing-doc.rs
+++ b/src/test/compile-fail/lint-missing-doc.rs
@@ -15,19 +15,17 @@
 struct Foo {
     a: int,
     priv b: int,
-    pub c: int, // doesn't matter, Foo is private
 }
 
 pub struct PubFoo { //~ ERROR: missing documentation
     a: int,      //~ ERROR: missing documentation
     priv b: int,
-    pub c: int,  //~ ERROR: missing documentation
 }
 
 #[allow(missing_doc)]
 pub struct PubFoo2 {
     a: int,
-    pub c: int,
+    c: int,
 }
 
 /// dox
@@ -44,9 +42,9 @@ pub trait C {} //~ ERROR: missing documentation
 
 trait Bar {
     /// dox
-    pub fn foo();
+    fn foo();
     fn foo2(); //~ ERROR: missing documentation
-    pub fn foo3(); //~ ERROR: missing documentation
+    fn foo3(); //~ ERROR: missing documentation
 }
 
 impl Foo {
@@ -59,13 +57,13 @@ impl Foo {
 
 #[allow(missing_doc)]
 trait F {
-    pub fn a();
+    fn a();
     fn b(&self);
 }
 
 // should need to redefine documentation for implementations of traits
 impl F for Foo {
-    pub fn a() {}
+    fn a() {}
     fn b(&self) {}
 }
 
diff --git a/src/test/compile-fail/useless-priv.rs b/src/test/compile-fail/useless-priv.rs
new file mode 100644
index 00000000000..3d6841c919a
--- /dev/null
+++ b/src/test/compile-fail/useless-priv.rs
@@ -0,0 +1,25 @@
+// Copyright 2013 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.
+
+struct A { pub i: int }         //~ ERROR: unnecessary `pub`
+struct B { priv i: int }        // don't warn b/c B can still be returned
+pub enum C { pub Variant }      //~ ERROR: unnecessary `pub`
+enum D { priv Variant2 }        //~ ERROR: unnecessary `priv`
+
+pub trait E {
+    pub fn foo() {}             //~ ERROR: unnecessary visibility
+}
+trait F { pub fn foo() {} }     //~ ERROR: unnecessary visibility
+
+impl E for A {
+    pub fn foo() {}             //~ ERROR: unnecessary visibility
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/useless-priv2.rs b/src/test/compile-fail/useless-priv2.rs
new file mode 100644
index 00000000000..0d94300329c
--- /dev/null
+++ b/src/test/compile-fail/useless-priv2.rs
@@ -0,0 +1,19 @@
+// Copyright 2013 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.
+
+pub trait E {
+    pub fn foo();               //~ ERROR: obsolete syntax
+}
+trait F { pub fn foo(); }       //~ ERROR: obsolete syntax
+
+struct B;
+impl E for B {
+    priv fn foo() {}             //~ ERROR: obsolete syntax
+}
diff --git a/src/test/run-pass/bug-7295.rs b/src/test/run-pass/bug-7295.rs
index 2a1a0e35c56..ea711d78dd2 100644
--- a/src/test/run-pass/bug-7295.rs
+++ b/src/test/run-pass/bug-7295.rs
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 pub trait Foo<T> {
-    pub fn func1<U>(&self, t: U);
+    fn func1<U>(&self, t: U);
 
-    pub fn func2<U>(&self, t: U) {
+    fn func2<U>(&self, t: U) {
         self.func1(t);
     }
 }
diff --git a/src/test/run-pass/issue-7712.rs b/src/test/run-pass/issue-7712.rs
index 41c4af86bac..1ea8312ddd9 100644
--- a/src/test/run-pass/issue-7712.rs
+++ b/src/test/run-pass/issue-7712.rs
@@ -11,7 +11,7 @@
 // compile-flags:-Z debug-info
 
 pub trait TraitWithDefaultMethod {
-    pub fn method(self) {
+    fn method(self) {
         ()
     }
 }
diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs
index 8cd7b78312b..180cd115c96 100644
--- a/src/test/run-pass/static-methods-in-traits.rs
+++ b/src/test/run-pass/static-methods-in-traits.rs
@@ -10,17 +10,17 @@
 
 mod a {
     pub trait Foo {
-        pub fn foo() -> Self;
+        fn foo() -> Self;
     }
 
     impl Foo for int {
-        pub fn foo() -> int {
+        fn foo() -> int {
             3
         }
     }
 
     impl Foo for uint {
-        pub fn foo() -> uint {
+        fn foo() -> uint {
             5u
         }
     }