Skip to content

Commit 4cc069b

Browse files
Slowkialexcrichton
authored andcommitted
Clean up Some Clippy Warnings (#478)
* clippy: it is more idiomatic to loop over references to containers instead of using explicit iteration methods * clippy: useless use of `format!` * clippy: if/else is an expression * clippy: use of followed by a function call * clippy: large size difference between variants * clippy: redundant closure * Revert "clippy: large size difference between variants" This reverts commit 7e2e660. * Revert "clippy: it is more idiomatic to loop over references to containers instead of using explicit iteration methods" This reverts commit 5c4804f.
1 parent babc213 commit 4cc069b

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

crates/backend/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl Function {
217217

218218
impl Export {
219219
pub(crate) fn rust_symbol(&self) -> Ident {
220-
let mut generated_name = format!("__wasm_bindgen_generated");
220+
let mut generated_name = String::from("__wasm_bindgen_generated");
221221
if let Some(class) = &self.class {
222222
generated_name.push_str("_");
223223
generated_name.push_str(&class.to_string());

crates/backend/src/codegen.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,12 @@ impl ToTokens for ast::Export {
314314
let mut converted_arguments = vec![];
315315
let ret = Ident::new("_ret", Span::call_site());
316316

317-
let mut offset = 0;
318-
if self.method_self.is_some() {
317+
let offset = if self.method_self.is_some() {
319318
args.push(quote! { me: u32 });
320-
offset = 1;
321-
}
319+
1
320+
} else {
321+
0
322+
};
322323

323324
let name = &self.function.name;
324325
let receiver = match self.method_self {

crates/webidl/src/first_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl FirstPass for webidl::ast::NonPartialMixin {
125125
let entry = record
126126
.mixins
127127
.entry(self.name.clone())
128-
.or_insert(Default::default());
128+
.or_insert_with(Default::default);
129129
if mem::replace(&mut entry.non_partial, Some(self)).is_some() {
130130
warn!(
131131
"Encounterd multiple declarations of {}, using last encountered",
@@ -142,7 +142,7 @@ impl FirstPass for webidl::ast::PartialMixin {
142142
let entry = record
143143
.mixins
144144
.entry(self.name.clone())
145-
.or_insert(Default::default());
145+
.or_insert_with(Default::default);
146146
entry.partials.push(self);
147147

148148
Ok(())

crates/webidl/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl<'a> FirstPassRecord<'a> {
247247
let js_ret = ret.clone();
248248

249249
if catch {
250-
ret = Some(ret.map_or_else(|| result_ty(unit_ty()), |ret| result_ty(ret)))
250+
ret = Some(ret.map_or_else(|| result_ty(unit_ty()), result_ty))
251251
}
252252

253253
let shim = {

0 commit comments

Comments
 (0)