]> git.lizzy.rs Git - rust.git/blob - src/test/ui/privacy/pub-priv-dep/pub-priv1.rs
784615354a95c6f5e105a4b5eb957bac7888d452
[rust.git] / src / test / ui / privacy / pub-priv-dep / pub-priv1.rs
1  // aux-build:priv_dep.rs
2  // aux-build:pub_dep.rs
3  // extern-private:priv_dep
4 #![deny(exported_private_dependencies)]
5
6 // This crate is a private dependency
7 extern crate priv_dep;
8 // This crate is a public dependenct
9 extern crate pub_dep;
10
11 use priv_dep::{OtherType, OtherTrait};
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 `priv_dep::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 {
28     pub fn pub_fn(param: OtherType) {}
29     //~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
30
31     fn priv_fn(param: OtherType) {}
32 }
33
34 pub trait MyPubTrait {
35     type Foo: OtherTrait;
36 }
37 //~^^^ ERROR trait `priv_dep::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
44
45
46 fn main() {}