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