mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-21 14:22:26 +00:00
parent
995205de23
commit
d47d527ac2
@ -592,6 +592,11 @@ fn get_repr(attributes: &[Attribute]) -> Result<Representation> {
|
||||
| (None, b) => b,
|
||||
| _ => bail!("conflicting representation hints"),
|
||||
},
|
||||
align: match (a.align, b.align) {
|
||||
| (a, None) => a,
|
||||
| (None, b) => b,
|
||||
| _ => bail!("conflicting representation hints"),
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -643,12 +648,13 @@ macro_rules! mk_repr {(
|
||||
#[derive(Clone, Copy)]
|
||||
struct Representation {
|
||||
packed: Option<u32>,
|
||||
align: Option<u32>,
|
||||
repr: Repr,
|
||||
}
|
||||
|
||||
impl Default for Representation {
|
||||
fn default() -> Self {
|
||||
Self { packed: None, repr: Repr::Rust }
|
||||
Self { packed: None, align: None, repr: Repr::Rust }
|
||||
}
|
||||
}
|
||||
|
||||
@ -672,6 +678,12 @@ macro_rules! mk_repr {(
|
||||
let _: Option<Token![,]> = input.parse()?;
|
||||
continue;
|
||||
},
|
||||
"align" => {
|
||||
let contents; parenthesized!(contents in input);
|
||||
ret.align = Some(LitInt::base10_parse::<u32>(&contents.parse()?)?);
|
||||
let _: Option<Token![,]> = input.parse()?;
|
||||
continue;
|
||||
},
|
||||
$(
|
||||
stringify!($xn) => Repr::$Xn,
|
||||
)*
|
||||
|
@ -185,3 +185,7 @@ fn anybitpattern_implies_zeroable() {
|
||||
let test = AnyBitPatternTest::zeroed();
|
||||
assert_eq!(test, AnyBitPatternTest { a: 0, b: 0 });
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
||||
#[repr(C, align(16))]
|
||||
struct Issue127 {}
|
||||
|
Loading…
Reference in New Issue
Block a user