Lines Matching full:packed
29 pub(crate) enum Repr<Prim, Packed> {
33 /// optionally combined with `repr(packed(...))` or `repr(align(...))`
34 Compound(Spanned<CompoundRepr<Prim>>, Option<Spanned<AlignRepr<Packed>>>),
63 /// `repr(packed(...))` or `repr(align(...))`
65 pub(crate) enum AlignRepr<Packed> {
66 Packed(Packed), enumerator
76 impl<Prim, Packed> Repr<Prim, Packed> {
126 pub(crate) fn get_packed(&self) -> Option<&Packed> { in get_packed() argument
129 if let Compound(_, Some(Spanned { t: Packed(p), span: _ })) = self { in get_packed()
167 /// Does `self` describe a `#[repr(packed)]` or `#[repr(packed(1))]` type?
173 impl<Packed> Repr<PrimitiveRepr, Packed> {
195 impl<Prim, Packed> ToTokens for Repr<Prim, Packed>
198 Packed: With<NonZeroU32> + Copy,
245 impl<Packed: With<NonZeroU32> + Copy> ToTokens for Spanned<AlignRepr<Packed>> {
251 // `#[repr(packed(...))]`. in to_tokens()
254 Packed(n) => n.with(|n| { in to_tokens()
256 ts.append_all(quote_spanned! { self.span => #[repr(packed(#n))] }) in to_tokens()
288 Packed, enumerator
298 /// it's `packed` repr and we're parsing an `AlignRepr` for an enum type).
330 Transparent | C | Rust | Align(_) | PackedN(_) | Packed => { in try_from()
339 Transparent | Align(_) | PackedN(_) | Packed => Err(FromRawReprError::None), in try_from()
349 Packed | PackedN(_) => Pcked::try_with_or( in try_from()
351 Packed => Ok(NonZeroU32::new(1).unwrap()), in try_from()
358 .map(AlignRepr::Packed) in try_from()
371 /// (e.g. there's a `packed` repr and we're parsing an `AlignRepr` for an
375 /// parsing (e.g., the list is `#[repr(align(2), packed)]`). Note that we
377 /// `#[repr(packed, packed)]`).
395 // `repr(packed)` on an enum). in try_from_raw_reprs()
455 impl<Prim, Packed> Repr<Prim, Packed> {
456 fn from_attrs_inner(attrs: &[Attribute]) -> Result<Repr<Prim, Packed>, Spanned<FromAttrsError>> in from_attrs_inner() argument
459 Packed: With<NonZeroU32>, in from_attrs_inner()
487 let align: Option<Spanned<AlignRepr<Packed>>> = in from_attrs_inner()
507 impl<Prim, Packed> Repr<Prim, Packed> {
508 pub(crate) fn from_attrs(attrs: &[Attribute]) -> Result<Repr<Prim, Packed>, Error> in from_attrs() argument
511 Packed: With<NonZeroU32>, in from_attrs()
597 ("packed", None) => Packed, in from_meta()
598 ("packed", Some(list)) => PackedN(parse_nzu64(list)?), in from_meta()
701 impl<Prim: PartialEq, Packed: PartialEq> PartialEq for Repr<Prim, Packed> {
702 fn eq(&self, other: &Repr<Prim, Packed>) -> bool { in eq()
748 … test!(#[repr(packed)] => StructUnionRepr::Compound(Rust.into(), Some(Packed(nz(1)).into()))); in test()
749 … test!(#[repr(packed(2))] => StructUnionRepr::Compound(Rust.into(), Some(Packed(nz(2)).into()))); in test()
753 … test!(#[repr(C, packed)] => StructUnionRepr::Compound(C.into(), Some(Packed(nz(1)).into()))); in test()
754 … test!(#[repr(C, packed(2))] => StructUnionRepr::Compound(C.into(), Some(Packed(nz(2)).into()))); in test()
795 // Invalid packed or align attributes in test()
796 test!(@error #[repr(packed(0))] => $repr => Unrecognized.into()); in test()
797 test!(@error #[repr(packed(3))] => $repr => Unrecognized.into()); in test()
847 … test!(@error #[repr(packed)] => EnumRepr => FromRawReprs(Single(UnsupportedReprError)).into()); in test()
848 … test!(@error #[repr(packed(1))] => EnumRepr => FromRawReprs(Single(UnsupportedReprError)).into()); in test()
849 … test!(@error #[repr(packed(2))] => EnumRepr => FromRawReprs(Single(UnsupportedReprError)).into()); in test()