Skip to content

Commit

Permalink
fix(tasks): cargo clippy error on rust 1.82.0 (#7283)
Browse files Browse the repository at this point in the history
I mentioned this clippy issue in the discord help channel. The problem
seems to be related to using the stable rust toolchain, but when I
switched to version `1.81.0`, the issue was resolved.

However, some of the clippy suggestions might still be worth considering
and could be adopted.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
shulaoda and autofix-ci[bot] authored Nov 14, 2024
1 parent 01ddf37 commit a48ebd6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions tasks/ast_tools/src/generators/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,19 @@ fn typescript_struct(def: &StructDef, always_flatten_structs: &FxHashSet<TypeId>

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 {
Expand Down
8 changes: 4 additions & 4 deletions tasks/ast_tools/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
}
Expand Down

0 comments on commit a48ebd6

Please sign in to comment.