diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-05-18 10:14:22 +0200 |
|---|---|---|
| committer | Trevor Gross <t.gross35@gmail.com> | 2025-05-18 12:01:05 +0200 |
| commit | abbf8fe6e7abf6b6b612bcc65f87ded71a6ce562 (patch) | |
| tree | 0e849fcca35186e89f3dfc87a726590effd21458 | |
| parent | d16c82dba15f4aaf61874f6668417856002d32a6 (diff) | |
| download | rust-abbf8fe6e7abf6b6b612bcc65f87ded71a6ce562.tar.gz rust-abbf8fe6e7abf6b6b612bcc65f87ded71a6ce562.zip | |
fix an if statement that can be collapsed
| -rw-r--r-- | library/compiler-builtins/crates/libm-macros/src/lib.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/library/compiler-builtins/crates/libm-macros/src/lib.rs b/library/compiler-builtins/crates/libm-macros/src/lib.rs index e8afe3aad55..482da974ca8 100644 --- a/library/compiler-builtins/crates/libm-macros/src/lib.rs +++ b/library/compiler-builtins/crates/libm-macros/src/lib.rs @@ -1,3 +1,5 @@ +#![feature(let_chains)] + mod enums; mod parse; mod shared; @@ -266,27 +268,27 @@ fn validate(input: &mut StructuredInput) -> syn::Result<Vec<&'static MathOpInfo> } } - if let Some(map) = &input.fn_extra { - if !map.keys().any(|key| key == "_") { - // No default provided; make sure every expected function is covered - let mut fns_not_covered = Vec::new(); - for func in &fn_list { - if !map.keys().any(|key| key == func.name) { - // `name` was not mentioned in the `match` statement - fns_not_covered.push(func); - } + if let Some(map) = &input.fn_extra + && !map.keys().any(|key| key == "_") + { + // No default provided; make sure every expected function is covered + let mut fns_not_covered = Vec::new(); + for func in &fn_list { + if !map.keys().any(|key| key == func.name) { + // `name` was not mentioned in the `match` statement + fns_not_covered.push(func); } + } - if !fns_not_covered.is_empty() { - let e = syn::Error::new( - input.fn_extra_span.unwrap(), - format!( - "`fn_extra`: no default `_` pattern specified and the following \ - patterns are not covered: {fns_not_covered:#?}" - ), - ); - return Err(e); - } + if !fns_not_covered.is_empty() { + let e = syn::Error::new( + input.fn_extra_span.unwrap(), + format!( + "`fn_extra`: no default `_` pattern specified and the following \ + patterns are not covered: {fns_not_covered:#?}" + ), + ); + return Err(e); } }; |
