Skip to content

Commit 83e68d3

Browse files
committed
Silence private_bounds lint in KnownLayout derive
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
1 parent 2c8ef74 commit 83e68d3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

zerocopy-derive/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ fn derive_known_layout_inner(ast: &DeriveInput, _top_level: Trait) -> Result<Tok
320320
// `#ty`, not `__ZerocopyKnownLayoutMaybeUninit` (see #2116).
321321
#repr
322322
#[doc(hidden)]
323+
// Required on some rustc versions due to a lint that is only
324+
// triggered when `derive(KnownLayout)` is applied to `repr(C)`
325+
// structs that are generated by macros. See #2177 for details.
326+
#[allow(private_bounds)]
323327
#vis struct __ZerocopyKnownLayoutMaybeUninit<#params> (
324328
#(::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit<
325329
<#ident #ty_generics as

zerocopy-derive/src/output_tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ fn test_known_layout() {
191191
#[repr(C)]
192192
#[repr(align(2))]
193193
#[doc(hidden)]
194+
#[allow(private_bounds)]
194195
struct __ZerocopyKnownLayoutMaybeUninit<T, U>(
195196
::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit<
196197
<Foo<T, U> as ::zerocopy::util::macro_util::Field<__Zerocopy_Field_0>>::Type,

0 commit comments

Comments
 (0)