From 93d872dbc88412c2ef1c22be1f81961cae730ac2 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sun, 13 Jan 2019 18:50:24 -0500 Subject: [PATCH] Add UI test --- .../pub-priv-dep/auxiliary/priv_dep.rs | 1 + src/test/ui/privacy/pub-priv-dep/pub-priv1.rs | 31 +++++++++++++++++++ .../ui/privacy/pub-priv-dep/pub-priv1.stderr | 25 +++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/test/ui/privacy/pub-priv-dep/auxiliary/priv_dep.rs create mode 100644 src/test/ui/privacy/pub-priv-dep/pub-priv1.rs create mode 100644 src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr diff --git a/src/test/ui/privacy/pub-priv-dep/auxiliary/priv_dep.rs b/src/test/ui/privacy/pub-priv-dep/auxiliary/priv_dep.rs new file mode 100644 index 00000000000..23426f96c75 --- /dev/null +++ b/src/test/ui/privacy/pub-priv-dep/auxiliary/priv_dep.rs @@ -0,0 +1 @@ +pub struct OtherType; diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs new file mode 100644 index 00000000000..d8620944065 --- /dev/null +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs @@ -0,0 +1,31 @@ + // aux-build:priv_dep.rs +#![feature(public_private_dependencies)] +#![deny(leaked_private_dependency)] + +// This crate is a private dependency +extern crate priv_dep; + +use priv_dep::OtherType; + +// Type from private dependency used in private +// type - this is fine +struct PrivateType { + field: OtherType +} + +pub struct PublicType { + pub field: OtherType, + //~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface [leaked_private_dependency] + //~| WARNING this was previously accepted + priv_field: OtherType, +} + +impl PublicType { + pub fn pub_fn(param: OtherType) {} + //~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface [leaked_private_dependency] + //~| WARNING this was previously accepted + + fn priv_fn(param: OtherType) {} +} + +fn main() {} diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr new file mode 100644 index 00000000000..330bf8a1f52 --- /dev/null +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr @@ -0,0 +1,25 @@ +error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface + --> $DIR/pub-priv1.rs:17:5 + | +LL | pub field: OtherType, + | ^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/pub-priv1.rs:3:9 + | +LL | #![deny(leaked_private_dependency)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #44663 + +error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface + --> $DIR/pub-priv1.rs:24:5 + | +LL | pub fn pub_fn(param: OtherType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #44663 + +error: aborting due to 2 previous errors + -- 2.44.0