diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs index 8baae4f4c8baf..bcad09ef3f690 100644 --- a/tasks/ast_tools/src/generators/typescript.rs +++ b/tasks/ast_tools/src/generators/typescript.rs @@ -108,17 +108,19 @@ fn typescript_struct(def: &StructDef, always_flatten_structs: &FxHashSet let ident = field.ident().unwrap(); if let Some(append_after) = append_to.get(&ident.to_string()) { - let after_type = match &append_after.markers.derive_attributes.estree.typescript_type { - Some(ty) => ty.clone(), - None => { + let after_type = + if let Some(ty) = &append_after.markers.derive_attributes.estree.typescript_type { + ty.clone() + } else { let typ = append_after.typ.name(); if let TypeName::Opt(inner) = typ { type_to_string(inner) } else { - panic!("expected field labeled with append_to to be Option<...>, but found {typ}"); + panic!( + "expected field labeled with append_to to be Option<...>, but found {typ}" + ); } - } - }; + }; if let Some(inner) = ty.strip_prefix("Array<") { ty = format!("Array<{after_type} | {inner}"); } else { diff --git a/tasks/ast_tools/src/layout.rs b/tasks/ast_tools/src/layout.rs index e380056e642cb..1c6a8a315fa67 100644 --- a/tasks/ast_tools/src/layout.rs +++ b/tasks/ast_tools/src/layout.rs @@ -160,10 +160,10 @@ impl Layout { /// For `n` bigger than `16`, Or if it's not a power of 2 number fn max_val_of_bytes(n: usize) -> u128 { match n { - 1 => u8::MAX as u128, - 2 => u16::MAX as u128, - 4 => u32::MAX as u128, - 8 => u64::MAX as u128, + 1 => u128::from(u8::MAX), + 2 => u128::from(u16::MAX), + 4 => u128::from(u32::MAX), + 8 => u128::from(u64::MAX), 16 => u128::MAX, _ => panic!("We do not support `n` bigger than 16 bytes."), }