|
| 1 | +//@ aux-crate:priv:diamond_priv_dep=diamond_priv_dep.rs |
| 2 | +//@ aux-crate:diamond_pub_dep=diamond_pub_dep.rs |
| 3 | +//@ compile-flags: -Zunstable-options |
| 4 | + |
| 5 | +// A diamond dependency: |
| 6 | +// |
| 7 | +// diamond_reepxort |
| 8 | +// /\ |
| 9 | +// (public) / \ (PRIVATE) |
| 10 | +// / \ |
| 11 | +// diamond_pub_dep diamond_priv_dep |
| 12 | +// \ / |
| 13 | +// (public) \ / (public) |
| 14 | +// \/ |
| 15 | +// shared |
| 16 | +// |
| 17 | +// Where the pub and private crates reexport something from the shared crate. |
| 18 | +// |
| 19 | +// Checks the behavior when the same shared item appears in the public API, |
| 20 | +// depending on whether it comes from the public side or the private side. |
| 21 | +// |
| 22 | +// NOTE: compiletest does not support deduplicating shared dependencies. |
| 23 | +// However, it should work well enough for this test, the only downside is |
| 24 | +// that diamond_shared gets built twice. |
| 25 | + |
| 26 | +#![crate_type = "lib"] |
| 27 | +#![deny(exported_private_dependencies)] |
| 28 | + |
| 29 | +extern crate diamond_priv_dep; |
| 30 | +extern crate diamond_pub_dep; |
| 31 | + |
| 32 | +// FIXME: This should trigger. |
| 33 | +pub fn leaks_priv() -> diamond_priv_dep::Shared { |
| 34 | + diamond_priv_dep::Shared |
| 35 | +} |
| 36 | + |
| 37 | +pub fn leaks_pub() -> diamond_pub_dep::Shared { |
| 38 | + diamond_pub_dep::Shared |
| 39 | +} |
| 40 | + |
| 41 | +pub struct PrivInStruct { |
| 42 | + pub f: diamond_priv_dep::SharedInType |
| 43 | +//~^ ERROR type `diamond_priv_dep::SharedInType` from private dependency 'diamond_priv_dep' in public interface |
| 44 | +} |
| 45 | + |
| 46 | +pub struct PubInStruct { |
| 47 | + pub f: diamond_pub_dep::SharedInType |
| 48 | +} |
0 commit comments