Skip to content

Commit

Permalink
Silence private_bounds lint in KnownLayout derive (#2182)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jswrenn authored Dec 23, 2024
1 parent 2c8ef74 commit 0fa779e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions zerocopy-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ fn derive_known_layout_inner(ast: &DeriveInput, _top_level: Trait) -> Result<Tok
// `#ty`, not `__ZerocopyKnownLayoutMaybeUninit` (see #2116).
#repr
#[doc(hidden)]
// Required on some rustc versions due to a lint that is only
// triggered when `derive(KnownLayout)` is applied to `repr(C)`
// structs that are generated by macros. See #2177 for details.
#[allow(private_bounds)]
#vis struct __ZerocopyKnownLayoutMaybeUninit<#params> (
#(::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit<
<#ident #ty_generics as
Expand Down
1 change: 1 addition & 0 deletions zerocopy-derive/src/output_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ fn test_known_layout() {
#[repr(C)]
#[repr(align(2))]
#[doc(hidden)]
#[allow(private_bounds)]
struct __ZerocopyKnownLayoutMaybeUninit<T, U>(
::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit<
<Foo<T, U> as ::zerocopy::util::macro_util::Field<__Zerocopy_Field_0>>::Type,
Expand Down

0 comments on commit 0fa779e

Please sign in to comment.