Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KnownLayout violates private-in-public rules in some cases #1292

Open
Tracked by #29
joshlf opened this issue May 17, 2024 · 2 comments
Open
Tracked by #29

KnownLayout violates private-in-public rules in some cases #1292

joshlf opened this issue May 17, 2024 · 2 comments
Assignees
Labels
blocking-next-release This issue should be resolved before we release on crates.io

Comments

@joshlf
Copy link
Member

joshlf commented May 17, 2024

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
Copy link
Collaborator

jswrenn commented May 20, 2024

@jswrenn
Copy link
Collaborator

jswrenn commented May 20, 2024

This is a compiler bug, and is tracked by rust-lang/rust#45713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking-next-release This issue should be resolved before we release on crates.io
Projects
None yet
Development

No branches or pull requests

2 participants