Skip to content

Commit 6e86581

Browse files
committed
fix an if statement that can be collapsed
1 parent f2918cd commit 6e86581

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

crates/libm-macros/src/lib.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(let_chains)]
2+
13
mod enums;
24
mod parse;
35
mod shared;
@@ -266,27 +268,28 @@ fn validate(input: &mut StructuredInput) -> syn::Result<Vec<&'static MathOpInfo>
266268
}
267269
}
268270

269-
if let Some(map) = &input.fn_extra {
270-
if !map.keys().any(|key| key == "_") {
271-
// No default provided; make sure every expected function is covered
272-
let mut fns_not_covered = Vec::new();
273-
for func in &fn_list {
274-
if !map.keys().any(|key| key == func.name) {
275-
// `name` was not mentioned in the `match` statement
276-
fns_not_covered.push(func);
277-
}
271+
#[allow(clippy::collapsible_if)]
272+
if let Some(map) = &input.fn_extra
273+
&& !map.keys().any(|key| key == "_")
274+
{
275+
// No default provided; make sure every expected function is covered
276+
let mut fns_not_covered = Vec::new();
277+
for func in &fn_list {
278+
if !map.keys().any(|key| key == func.name) {
279+
// `name` was not mentioned in the `match` statement
280+
fns_not_covered.push(func);
278281
}
282+
}
279283

280-
if !fns_not_covered.is_empty() {
281-
let e = syn::Error::new(
282-
input.fn_extra_span.unwrap(),
283-
format!(
284-
"`fn_extra`: no default `_` pattern specified and the following \
285-
patterns are not covered: {fns_not_covered:#?}"
286-
),
287-
);
288-
return Err(e);
289-
}
284+
if !fns_not_covered.is_empty() {
285+
let e = syn::Error::new(
286+
input.fn_extra_span.unwrap(),
287+
format!(
288+
"`fn_extra`: no default `_` pattern specified and the following \
289+
patterns are not covered: {fns_not_covered:#?}"
290+
),
291+
);
292+
return Err(e);
290293
}
291294
};
292295

0 commit comments

Comments
 (0)