-
Notifications
You must be signed in to change notification settings - Fork 105
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
Inconsistent visibility on some derive-synthesized types #2177
Comments
We currently use field visibility, not the outer type visibility: https://github.com/google/zerocopy/blob/2c8ef7463c109138aa3202622bd3f93b884385a9/zerocopy-derive/src/lib.rs#L281C1-L282C1 This is correct, as it allows us to accommodate types whose fields have a type which is less visible than the enclosing type. What's going on here is way weirder. This is a minimum replication of the issue: use zerocopy_derive::KnownLayout;
macro_rules! define {
($name:ident, $repr:ty) => {
#[derive(KnownLayout)]
#[repr(C)]
pub struct $name($repr);
}
}
define!(Foo, u8); ...that triggers the
What's very weird is the macro indirection is essential here. (Don't even ask how long it took me to figure this out.) This program, for example, does not trigger the lint: use zerocopy_derive::KnownLayout;
#[derive(KnownLayout)]
#[repr(C)]
pub struct Foo(u8);
fn main() {} This strikes me as probably a rustc bug. I'll dig deeper to confirm, but the good news is that the fix on our end is as simple as slapping an |
For reasons not-yet-known, the `private_bounds` lint flags the output of `derive(KnownLayout)` on `repr(C)` structs generated by macros. This is likely a rustc bug, but to preserve a good experience for our users, we nonetheless, `allow(private_bounds)`. Fixes #2177
For reasons not-yet-known, the `private_bounds` lint flags the output of `derive(KnownLayout)` on `repr(C)` structs generated by macros. This is likely a rustc bug, but to preserve a good experience for our users, we nonetheless, `allow(private_bounds)`. Fixes #2177
For reasons not-yet-known, the `private_bounds` lint flags the output of `derive(KnownLayout)` on `repr(C)` structs generated by macros. This is likely a rustc bug, but to preserve a good experience for our users, we nonetheless, `allow(private_bounds)`. Fixes #2177
Prompted by this CI failure in rend.
Seems like this is caused by #2055 and #2127. Fixing it should be a simple matter of using the same visibility on synthesized types as we see on the type decorated with
#[derive(KnownLayout)]
and adding#[doc(hidden)]
.The text was updated successfully, but these errors were encountered: