2023-06-16 13:09:54 -05:00
|
|
|
// provide custom privacy error for sealed traits
|
|
|
|
pub mod a {
|
|
|
|
pub trait Sealed: self::b::Hidden {
|
|
|
|
fn foo() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct X;
|
|
|
|
impl Sealed for X {}
|
|
|
|
impl self::b::Hidden for X {}
|
|
|
|
|
|
|
|
mod b {
|
|
|
|
pub trait Hidden {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 11:34:41 -05:00
|
|
|
pub mod c {
|
|
|
|
pub trait Sealed: self::d::Hidden {
|
|
|
|
fn foo() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct X;
|
|
|
|
impl Sealed for X {}
|
|
|
|
impl self::d::Hidden for X {}
|
|
|
|
|
|
|
|
struct Y;
|
|
|
|
impl Sealed for Y {}
|
|
|
|
impl self::d::Hidden for Y {}
|
|
|
|
|
|
|
|
mod d {
|
|
|
|
pub trait Hidden {}
|
|
|
|
}
|
|
|
|
}
|
2023-06-16 13:09:54 -05:00
|
|
|
|
2023-10-19 11:34:41 -05:00
|
|
|
pub mod e {
|
|
|
|
pub trait Sealed: self::f::Hidden {
|
|
|
|
fn foo() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct X;
|
|
|
|
impl self::f::Hidden for X {}
|
|
|
|
|
|
|
|
struct Y;
|
|
|
|
impl self::f::Hidden for Y {}
|
|
|
|
impl<T: self::f::Hidden> Sealed for T {}
|
|
|
|
|
|
|
|
mod f {
|
|
|
|
pub trait Hidden {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
impl a::Sealed for S {} //~ ERROR the trait bound
|
|
|
|
impl c::Sealed for S {} //~ ERROR the trait bound
|
|
|
|
impl e::Sealed for S {} //~ ERROR the trait bound
|
2023-06-16 13:09:54 -05:00
|
|
|
fn main() {}
|