compiler/rust: rewrite match into a simpler if let

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38807>
This commit is contained in:
Eric Engestrom 2025-10-04 15:35:42 +02:00
parent 1def70585b
commit cb57b77239

View file

@ -66,15 +66,12 @@ pub fn derive_as_slice(
Data::Struct(s) => { Data::Struct(s) => {
let mut has_repr_c = false; let mut has_repr_c = false;
for attr in attrs { for attr in attrs {
match attr.meta { if let Meta::List(ml) = attr.meta {
Meta::List(ml) => { if ml.path.is_ident("repr")
if ml.path.is_ident("repr") && format!("{}", ml.tokens) == "C"
&& format!("{}", ml.tokens) == "C" {
{ has_repr_c = true;
has_repr_c = true;
}
} }
_ => (),
} }
} }
assert!(has_repr_c, "Struct must be declared #[repr(C)]"); assert!(has_repr_c, "Struct must be declared #[repr(C)]");