diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2015-11-26 20:56:20 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2015-12-18 04:14:46 +0300 |
| commit | a745614f44d343cf40bd2a623d0b8d522547d570 (patch) | |
| tree | 2a73d5f992d4d24a52baa5f4cc8633d258f36c18 /src/test | |
| parent | 1a9239c964f4589c7f1646a1faf8412eb0c37a0e (diff) | |
Use lint instead of warning
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-28450-1.rs | 16 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-28450.rs | 8 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-private-in-public.rs | 33 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-visible-private-types-1.rs | 41 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-visible-private-types.rs | 23 |
5 files changed, 96 insertions, 25 deletions
diff --git a/src/test/compile-fail/issue-28450-1.rs b/src/test/compile-fail/issue-28450-1.rs new file mode 100644 index 00000000000..7239e6ddc37 --- /dev/null +++ b/src/test/compile-fail/issue-28450-1.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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. + +// Checks for private types in public interfaces + +type Foo = u8; +pub fn foo(f: Foo) {} //~ ERROR private type in public interface + +fn main() {} diff --git a/src/test/compile-fail/issue-28450.rs b/src/test/compile-fail/issue-28450.rs index 2e073051858..65c5978103a 100644 --- a/src/test/compile-fail/issue-28450.rs +++ b/src/test/compile-fail/issue-28450.rs @@ -10,6 +10,8 @@ // Checks for private types in public interfaces +#![feature(rustc_attrs)] + struct Priv; pub use self::private::public; @@ -28,9 +30,6 @@ impl<T> Pointer for *const T { type Pointee = T; } pub type __CFArrayRevealed = <CFArrayRef as Pointer>::Pointee; //~^ WARN private type in public interface -type Foo = u8; -pub fn foo(f: Foo) {} //~ ERROR private type in public interface - pub trait Exporter { type Output; } @@ -49,6 +48,7 @@ pub fn block() -> <Helper as Exporter>::Output { Inner } -fn main() { +#[rustc_error] +fn main() { //~ ERROR compilation successful block().poke(); } diff --git a/src/test/compile-fail/lint-private-in-public.rs b/src/test/compile-fail/lint-private-in-public.rs new file mode 100644 index 00000000000..f9b049c5d33 --- /dev/null +++ b/src/test/compile-fail/lint-private-in-public.rs @@ -0,0 +1,33 @@ +// 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. + +mod m1 { + #![deny(private_in_public)] + + pub struct Pub; + struct Priv; + + impl Pub { + pub fn f() -> Priv {} //~ ERROR private type in public interface + } +} + +mod m2 { + #![deny(future_incompatible)] + + pub struct Pub; + struct Priv; + + impl Pub { + pub fn f() -> Priv {} //~ ERROR private type in public interface + } +} + +fn main() {} diff --git a/src/test/compile-fail/lint-visible-private-types-1.rs b/src/test/compile-fail/lint-visible-private-types-1.rs new file mode 100644 index 00000000000..69c4eca1a0a --- /dev/null +++ b/src/test/compile-fail/lint-visible-private-types-1.rs @@ -0,0 +1,41 @@ +// 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(rustc_attrs)] +#![allow(dead_code)] + +use std::marker; + +struct Private<T>(marker::PhantomData<T>); +pub struct Public<T>(marker::PhantomData<T>); + +pub trait PubTrait { + type Output; +} + +type PrivAlias = Public<i8>; + +trait PrivTrait2 { + type Alias; +} +impl PrivTrait2 for Private<isize> { + type Alias = Public<u8>; +} + +impl PubTrait for PrivAlias { + type Output = Private<isize>; //~ WARN private type in public interface +} + +impl PubTrait for <Private<isize> as PrivTrait2>::Alias { + type Output = Private<isize>; //~ WARN private type in public interface +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/lint-visible-private-types.rs b/src/test/compile-fail/lint-visible-private-types.rs index 154acbcfd60..1fd61605557 100644 --- a/src/test/compile-fail/lint-visible-private-types.rs +++ b/src/test/compile-fail/lint-visible-private-types.rs @@ -75,8 +75,8 @@ pub trait PubTrait { } impl PubTrait for Public<isize> { - fn bar(&self) -> Private<isize> { panic!() } //~ WARN private type in public interface - fn baz() -> Private<isize> { panic!() } //~ WARN private type in public interface + fn bar(&self) -> Private<isize> { panic!() } // Warns in lint checking phase + fn baz() -> Private<isize> { panic!() } // Warns in lint checking phase } impl PubTrait for Public<Private<isize>> { fn bar(&self) -> Private<isize> { panic!() } @@ -121,22 +121,3 @@ impl<T: ParamTrait<Private<isize>>> //~ ERROR private type in public interface ParamTrait<T> for Public<i8> { fn foo() -> T { panic!() } } - -type PrivAlias = Public<i8>; - -trait PrivTrait2 { - type Alias; -} -impl PrivTrait2 for Private<isize> { - type Alias = Public<u8>; -} - -impl PubTrait for PrivAlias { - fn bar(&self) -> Private<isize> { panic!() } //~ WARN private type in public interface - fn baz() -> Private<isize> { panic!() } //~ WARN private type in public interface -} - -impl PubTrait for <Private<isize> as PrivTrait2>::Alias { - fn bar(&self) -> Private<isize> { panic!() } //~ WARN private type in public interface - fn baz() -> Private<isize> { panic!() } //~ WARN private type in public interface -} |
