Skip to content

Standardize whether T: KnownLayout requires T's fields to be KnownLayout #1162

@joshlf

Description

@joshlf

Progress

  • Restrict KnownLayout for Unalign<T> to require T: KnownLayout (add a test to confirm this behavior doesn't regress)
    • Record the fact that the reason for doing it this way (rather than always implementing it manually - even when feature = "derive" - without a T: KnownLayout bound) is to be forwards-compatible with supporting unsized Unalign (#209)
  • Teach impl_or_verify! to support KnownLayout - the Unalign bounds issue wasn't caught because, for KnownLayout, we use impl_known_layout! rather than impl_or_verify!
  • [Possibly after 0.8] Relax so that T: KnownLayout never requires its fields to be KnownLayout

Details

Relates to #29.

Consider the following code:

#[derive(KnownLayout]
#[repr(C)]
pub struct Foo<T>(T);

Since T has an implicit T: Sized bound, our emitted derive should not require that T: KnownLayout, but it does. This is currently affecting Unalign, resulting in it having a different bound when compiling with feature = "derive" (namely, T: KnownLayout) than when compiling without feature = "derive".

Metadata

Metadata

Assignees

Labels

blocking-next-releaseThis issue should be resolved before we release on crates.io

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions