2020-06-27 21:36:35 +01:00
|
|
|
//@ aux-crate:priv:priv_dep=priv_dep.rs
|
|
|
|
|
//@ aux-build:pub_dep.rs
|
2024-03-17 15:46:40 -07:00
|
|
|
//@ aux-crate:priv:pm=pm.rs
|
2021-11-03 20:00:00 -07:00
|
|
|
//@ compile-flags: -Zunstable-options
|
2024-03-17 15:46:40 -07:00
|
|
|
|
|
|
|
|
// Basic behavior check of exported_private_dependencies from either a public
|
|
|
|
|
// dependency or a private one.
|
|
|
|
|
|
2019-01-20 22:04:22 -05:00
|
|
|
#![deny(exported_private_dependencies)]
|
2019-01-13 18:50:24 -05:00
|
|
|
|
|
|
|
|
// This crate is a private dependency
|
2024-03-17 15:46:40 -07:00
|
|
|
// FIXME: This should trigger.
|
|
|
|
|
pub extern crate priv_dep;
|
2019-12-05 16:26:21 -08:00
|
|
|
// This crate is a public dependency
|
2019-01-13 20:37:27 -05:00
|
|
|
extern crate pub_dep;
|
2024-03-17 15:46:40 -07:00
|
|
|
// This crate is a private dependency
|
|
|
|
|
extern crate pm;
|
2019-01-13 18:50:24 -05:00
|
|
|
|
2020-06-27 21:36:35 +01:00
|
|
|
use priv_dep::{OtherTrait, OtherType};
|
2019-01-13 20:37:27 -05:00
|
|
|
use pub_dep::PubType;
|
2019-01-13 18:50:24 -05:00
|
|
|
|
|
|
|
|
// Type from private dependency used in private
|
|
|
|
|
// type - this is fine
|
|
|
|
|
struct PrivateType {
|
2020-06-27 21:36:35 +01:00
|
|
|
field: OtherType,
|
2019-01-13 18:50:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct PublicType {
|
|
|
|
|
pub field: OtherType,
|
2020-09-02 10:40:56 +03:00
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
2020-06-27 21:36:35 +01:00
|
|
|
priv_field: OtherType, // Private field - this is fine
|
|
|
|
|
pub other_field: PubType, // Type from public dependency - this is fine
|
2019-01-13 18:50:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PublicType {
|
2024-03-17 15:46:40 -07:00
|
|
|
pub fn pub_fn_param(param: OtherType) {}
|
|
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
|
|
|
|
|
|
|
|
|
pub fn pub_fn_return() -> OtherType { OtherType }
|
2020-09-02 10:40:56 +03:00
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
2019-01-13 18:50:24 -05:00
|
|
|
|
|
|
|
|
fn priv_fn(param: OtherType) {}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-13 20:37:27 -05:00
|
|
|
pub trait MyPubTrait {
|
|
|
|
|
type Foo: OtherTrait;
|
|
|
|
|
}
|
2020-09-07 10:01:45 +01:00
|
|
|
//~^^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
2019-01-13 20:37:27 -05:00
|
|
|
|
2024-03-17 15:46:40 -07:00
|
|
|
pub trait WithSuperTrait: OtherTrait {}
|
|
|
|
|
//~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
|
|
|
|
|
|
|
|
|
pub trait PubLocalTraitWithAssoc {
|
|
|
|
|
type X;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct PrivateAssoc;
|
|
|
|
|
impl PubLocalTraitWithAssoc for PrivateAssoc {
|
|
|
|
|
type X = OtherType;
|
|
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn in_bounds<T: OtherTrait>(x: T) { unimplemented!() }
|
|
|
|
|
//~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
|
|
|
|
|
|
|
|
|
pub fn private_in_generic() -> std::num::Saturating<OtherType> { unimplemented!() }
|
|
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
|
|
|
|
|
|
|
|
|
pub static STATIC: OtherType = OtherType;
|
|
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
|
|
|
|
|
|
|
|
|
pub const CONST: OtherType = OtherType;
|
|
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
|
|
|
|
|
|
|
|
|
pub type Alias = OtherType;
|
|
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
|
|
|
|
|
|
|
|
|
pub struct PublicWithPrivateImpl;
|
|
|
|
|
|
|
|
|
|
impl OtherTrait for PublicWithPrivateImpl {}
|
2025-03-10 18:24:54 +03:00
|
|
|
//~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
2024-03-17 15:46:40 -07:00
|
|
|
|
|
|
|
|
pub trait PubTraitOnPrivate {}
|
|
|
|
|
|
|
|
|
|
impl PubTraitOnPrivate for OtherType {}
|
2025-03-10 18:24:54 +03:00
|
|
|
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
|
|
|
|
//~| ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
2024-03-17 15:46:40 -07:00
|
|
|
|
2019-01-30 15:37:27 -05:00
|
|
|
pub struct AllowedPrivType {
|
|
|
|
|
#[allow(exported_private_dependencies)]
|
2020-06-27 21:36:35 +01:00
|
|
|
pub allowed: OtherType,
|
2019-01-30 15:37:27 -05:00
|
|
|
}
|
|
|
|
|
|
2024-03-17 15:46:40 -07:00
|
|
|
// FIXME: This should trigger.
|
|
|
|
|
pub use priv_dep::m;
|
|
|
|
|
// FIXME: This should trigger.
|
|
|
|
|
pub use pm::fn_like;
|
|
|
|
|
// FIXME: This should trigger.
|
|
|
|
|
pub use pm::PmDerive;
|
|
|
|
|
// FIXME: This should trigger.
|
|
|
|
|
pub use pm::pm_attr;
|
|
|
|
|
|
|
|
|
|
// FIXME: This should trigger.
|
|
|
|
|
pub use priv_dep::E::V1;
|
|
|
|
|
|
2019-01-13 18:50:24 -05:00
|
|
|
fn main() {}
|