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) => {
let mut has_repr_c = false;
for attr in attrs {
match attr.meta {
Meta::List(ml) => {
if ml.path.is_ident("repr")
&& format!("{}", ml.tokens) == "C"
{
has_repr_c = true;
}
if let Meta::List(ml) = attr.meta {
if ml.path.is_ident("repr")
&& format!("{}", ml.tokens) == "C"
{
has_repr_c = true;
}
_ => (),
}
}
assert!(has_repr_c, "Struct must be declared #[repr(C)]");