Closed
Description
given the following extern crate dep
:
mod private {
pub trait Hidden {}
impl Hidden for &u128 {}
impl Hidden for &u64 {}
impl Hidden for &u32 {}
impl Hidden for &u16 {}
impl Hidden for &u8 {}
}
pub trait Sealed: private::Hidden {}
and the following root crate:
struct Local;
impl dep::Sealed for Local {}
fn main() {}
The order in trait_impls_of
depends on crate metadata of dep
. The rest is only necessary to reproduce this issue.
with the following cargo.toml file
[package]
name = "test2"
version = "0.1.0"
edition = "2021"
[profile.dev]
codegen-units = <insert num codegen-units here>
[dependencies]
dep = { path = "dep" }
the output of cargo c
is unstable:
with 1 codegen unit it's
error[E0277]: the trait bound `Local: dep::private::Hidden` is not satisfied
--> src/main.rs:2:22
|
2 | impl dep::Sealed for Local {}
| ^^^^^ the trait `dep::private::Hidden` is not implemented for `Local`
|
= help: the following other types implement trait `dep::private::Hidden`:
&u128
&u64
&u32
&u16
&u8
note: required by a bound in `Sealed`
--> /home/lcnr/test2/dep/src/lib.rs:10:19
|
10 | pub trait Sealed: private::Hidden {}
| ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
= note: `Sealed` is a "sealed trait", because to implement it you also need to implement `dep::private::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
= help: the following types implement the trait:
&u32
&u8
&u16
&u64
&u128
while with 2 it is
error[E0277]: the trait bound `Local: dep::private::Hidden` is not satisfied
--> src/main.rs:2:22
|
2 | impl dep::Sealed for Local {}
| ^^^^^ the trait `dep::private::Hidden` is not implemented for `Local`
|
= help: the following other types implement trait `dep::private::Hidden`:
&u128
&u64
&u32
&u16
&u8
note: required by a bound in `Sealed`
--> /home/lcnr/test2/dep/src/lib.rs:10:19
|
10 | pub trait Sealed: private::Hidden {}
| ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
= note: `Sealed` is a "sealed trait", because to implement it you also need to implement `dep::private::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
= help: the following types implement the trait:
&u8
&u16
&u64
&u128
&u32