Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Feb 26, 2025
1 parent e62a1bb commit 0648b6e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
6 changes: 5 additions & 1 deletion compiler-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
unstable_features,
unused_results
)]
#![allow(clippy::match_single_binding, clippy::inconsistent_struct_constructor)]
#![allow(
clippy::match_single_binding,
clippy::inconsistent_struct_constructor,
clippy::assign_op_pattern
)]

#[cfg(test)]
#[macro_use]
Expand Down
26 changes: 13 additions & 13 deletions compiler-core/src/javascript/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a> OffsetBits<'a> {
self
}

fn to_doc(self) -> Document<'a> {
fn into_doc(self) -> Document<'a> {
let doc = if self.variables.is_empty() {
self.constant.to_doc()
} else if self.constant == 0 {
Expand Down Expand Up @@ -258,7 +258,7 @@ impl<'module_ctx, 'expression_gen, 'a> Generator<'module_ctx, 'expression_gen, '
Index::Int(i) => acc.append(eco_format!("[{i}]").to_doc()),
// TODO: escape string if needed
Index::String(s) => acc.append(docvec![".", maybe_escape_property_doc(s)]),
Index::ByteAt(i) => acc.append(docvec![".byteAt(", i.clone(), ")"]),
Index::ByteAt(i) => acc.append(docvec![".byteAt(", i.clone().into_doc(), ")"]),
Index::BitArraySliceToInt {
start,
end,
Expand All @@ -268,9 +268,9 @@ impl<'module_ctx, 'expression_gen, 'a> Generator<'module_ctx, 'expression_gen, '
"bitArraySliceToInt(",
acc,
", ",
start.clone(),
start.clone().into_doc(),
", ",
end.clone(),
end.clone().into_doc(),
", ",
bool(endianness.is_big()),
", ",
Expand All @@ -285,9 +285,9 @@ impl<'module_ctx, 'expression_gen, 'a> Generator<'module_ctx, 'expression_gen, '
"bitArraySliceToFloat(",
acc,
", ",
start.clone(),
start.clone().into_doc(),
", ",
end.clone(),
end.clone().into_doc(),
", ",
bool(endianness.is_big()),
")"
Expand All @@ -298,13 +298,13 @@ impl<'module_ctx, 'expression_gen, 'a> Generator<'module_ctx, 'expression_gen, '
"bitArraySlice(",
acc,
", ",
start.clone(),
start.clone().into_doc(),
", ",
end.clone(),
end.clone().into_doc(),
")"
]
}
None => docvec!["bitArraySlice(", acc, ", ", start.clone(), ")"],
None => docvec!["bitArraySlice(", acc, ", ", start.clone().into_doc(), ")"],
},
Index::StringPrefixSlice(i) => docvec!(acc, ".slice(", i, ")"),
})
Expand Down Expand Up @@ -1186,7 +1186,7 @@ impl<'a> Check<'a> {

let bit_size_check = match tail_spread_type {
Some(BitArrayTailSpreadType::Bits) => {
docvec![bit_size, " >= ", expected_bit_size]
docvec![bit_size, " >= ", expected_bit_size.into_doc()]
}
Some(BitArrayTailSpreadType::Bytes) => {
// When the tail spread is for bytes rather than bits,
Expand All @@ -1196,15 +1196,15 @@ impl<'a> Check<'a> {
"(",
bit_size.clone(),
" >= ",
expected_bit_size.clone(),
expected_bit_size.clone().into_doc(),
" && (",
bit_size,
" - ",
expected_bit_size,
expected_bit_size.into_doc(),
") % 8 === 0)"
]
}
None => docvec![bit_size, " == ", expected_bit_size],
None => docvec![bit_size, " == ", expected_bit_size.into_doc()],
};

if match_desired {
Expand Down
1 change: 1 addition & 0 deletions compiler-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
unused_results
)]
#![allow(
clippy::assign_op_pattern,
clippy::to_string_trait_impl,
clippy::match_single_binding,
clippy::match_like_matches_macro,
Expand Down

0 comments on commit 0648b6e

Please sign in to comment.