1 // aux-crate:priv:priv_dep=priv_dep.rs 2 // aux-build:pub_dep.rs 3 // compile-flags: -Zunstable-options 4 #![deny(exported_private_dependencies)] 5 6 // This crate is a private dependency 7 extern crate priv_dep; 8 // This crate is a public dependency 9 extern crate pub_dep; 10 11 use priv_dep::{OtherTrait, OtherType}; 12 use pub_dep::PubType; 13 14 // Type from private dependency used in private 15 // type - this is fine 16 struct PrivateType { 17 field: OtherType, 18 } 19 20 pub struct PublicType { 21 pub field: OtherType, 22 //~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface 23 priv_field: OtherType, // Private field - this is fine 24 pub other_field: PubType, // Type from public dependency - this is fine 25 } 26 27 impl PublicType { pub_fn(param: OtherType)28 pub fn pub_fn(param: OtherType) {} 29 //~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface 30 priv_fn(param: OtherType)31 fn priv_fn(param: OtherType) {} 32 } 33 34 pub trait MyPubTrait { 35 type Foo: OtherTrait; 36 } 37 //~^^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface 38 39 pub struct AllowedPrivType { 40 #[allow(exported_private_dependencies)] 41 pub allowed: OtherType, 42 } 43 main()44fn main() {} 45