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
blocked-on-rust Blocked on a Rust feature landing or stabilizing bug Something isn't working

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

@joshlf joshlf added the blocking-next-release This issue should be resolved before we release on crates.io label May 30, 2024
@joshlf joshlf mentioned this issue Jun 24, 2024
87 tasks
@joshlf joshlf added blocking-next-release-publicization and removed blocking-next-release This issue should be resolved before we release on crates.io labels Jul 1, 2024
jswrenn added a commit that referenced this issue Sep 23, 2024
jswrenn added a commit that referenced this issue Sep 23, 2024
jswrenn added a commit that referenced this issue Sep 23, 2024
jswrenn added a commit that referenced this issue Sep 23, 2024
jswrenn added a commit that referenced this issue Sep 23, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 23, 2024
@joshlf joshlf added the blocked-on-rust Blocked on a Rust feature landing or stabilizing label Oct 6, 2024
@joshlf joshlf added the bug Something isn't working label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked-on-rust Blocked on a Rust feature landing or stabilizing bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants