`KnownLayout` violates private-in-public rules in some cases
joshlf opened this issue · 2 comments
joshlf commented
In some cases, #[derive(KnownLayout)]
generates code like this:
trait KnownLayout {
type PointerMetadata;
}
mod foo {
use super::*;
pub struct Foo {
bar: Bar,
}
impl KnownLayout for Foo {
type PointerMetadata = <Bar as KnownLayout>::PointerMetadata;
}
struct Bar;
impl KnownLayout for Bar {
type PointerMetadata = ();
}
}
This causes a private-in-public error:
error[E0446]: private type `Bar` in public interface
--> src/lib.rs:13:9
|
13 | type PointerMetadata = <Bar as KnownLayout>::PointerMetadata;
| ^^^^^^^^^^^^^^^^^^^^ can't leak private type
...
16 | struct Bar;
| ---------- `Bar` declared as private
This is probably a rustc bug.
jswrenn commented
Discussion in the rust-lang zulip here: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Relaxing.20priv-in-path.20error/near/439582018
jswrenn commented
This is a compiler bug, and is tracked by rust-lang/rust#45713