Skip to content

Commit a48ebd6

Browse files
fix(tasks): cargo clippy error on rust 1.82.0 (#7283)
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>
1 parent 01ddf37 commit a48ebd6

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

tasks/ast_tools/src/generators/typescript.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,19 @@ fn typescript_struct(def: &StructDef, always_flatten_structs: &FxHashSet<TypeId>
108108

109109
let ident = field.ident().unwrap();
110110
if let Some(append_after) = append_to.get(&ident.to_string()) {
111-
let after_type = match &append_after.markers.derive_attributes.estree.typescript_type {
112-
Some(ty) => ty.clone(),
113-
None => {
111+
let after_type =
112+
if let Some(ty) = &append_after.markers.derive_attributes.estree.typescript_type {
113+
ty.clone()
114+
} else {
114115
let typ = append_after.typ.name();
115116
if let TypeName::Opt(inner) = typ {
116117
type_to_string(inner)
117118
} else {
118-
panic!("expected field labeled with append_to to be Option<...>, but found {typ}");
119+
panic!(
120+
"expected field labeled with append_to to be Option<...>, but found {typ}"
121+
);
119122
}
120-
}
121-
};
123+
};
122124
if let Some(inner) = ty.strip_prefix("Array<") {
123125
ty = format!("Array<{after_type} | {inner}");
124126
} else {

tasks/ast_tools/src/layout.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ impl Layout {
160160
/// For `n` bigger than `16`, Or if it's not a power of 2 number
161161
fn max_val_of_bytes(n: usize) -> u128 {
162162
match n {
163-
1 => u8::MAX as u128,
164-
2 => u16::MAX as u128,
165-
4 => u32::MAX as u128,
166-
8 => u64::MAX as u128,
163+
1 => u128::from(u8::MAX),
164+
2 => u128::from(u16::MAX),
165+
4 => u128::from(u32::MAX),
166+
8 => u128::from(u64::MAX),
167167
16 => u128::MAX,
168168
_ => panic!("We do not support `n` bigger than 16 bytes."),
169169
}

0 commit comments

Comments
 (0)