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 7e2e660dd47c9718126d1c45ae1caa632e287a14.

* Revert "clippy: it is more idiomatic to loop over references to containers instead of using explicit iteration methods"

This reverts commit 5c4804f790fc6a33a7a0f0d2aacdc4b98529b978.
This commit is contained in:
Stephan Wolski
2018-07-15 12:43:55 -04:00
committed by Alex Crichton
parent babc2134e1
commit 4cc069bd01
4 changed files with 9 additions and 8 deletions

View File

@ -217,7 +217,7 @@ impl Function {
impl Export { impl Export {
pub(crate) fn rust_symbol(&self) -> Ident { pub(crate) fn rust_symbol(&self) -> Ident {
let mut generated_name = format!("__wasm_bindgen_generated"); let mut generated_name = String::from("__wasm_bindgen_generated");
if let Some(class) = &self.class { if let Some(class) = &self.class {
generated_name.push_str("_"); generated_name.push_str("_");
generated_name.push_str(&class.to_string()); generated_name.push_str(&class.to_string());

View File

@ -314,11 +314,12 @@ impl ToTokens for ast::Export {
let mut converted_arguments = vec![]; let mut converted_arguments = vec![];
let ret = Ident::new("_ret", Span::call_site()); let ret = Ident::new("_ret", Span::call_site());
let mut offset = 0; let offset = if self.method_self.is_some() {
if self.method_self.is_some() {
args.push(quote! { me: u32 }); args.push(quote! { me: u32 });
offset = 1; 1
} } else {
0
};
let name = &self.function.name; let name = &self.function.name;
let receiver = match self.method_self { let receiver = match self.method_self {

View File

@ -125,7 +125,7 @@ impl FirstPass for webidl::ast::NonPartialMixin {
let entry = record let entry = record
.mixins .mixins
.entry(self.name.clone()) .entry(self.name.clone())
.or_insert(Default::default()); .or_insert_with(Default::default);
if mem::replace(&mut entry.non_partial, Some(self)).is_some() { if mem::replace(&mut entry.non_partial, Some(self)).is_some() {
warn!( warn!(
"Encounterd multiple declarations of {}, using last encountered", "Encounterd multiple declarations of {}, using last encountered",
@ -142,7 +142,7 @@ impl FirstPass for webidl::ast::PartialMixin {
let entry = record let entry = record
.mixins .mixins
.entry(self.name.clone()) .entry(self.name.clone())
.or_insert(Default::default()); .or_insert_with(Default::default);
entry.partials.push(self); entry.partials.push(self);
Ok(()) Ok(())

View File

@ -247,7 +247,7 @@ impl<'a> FirstPassRecord<'a> {
let js_ret = ret.clone(); let js_ret = ret.clone();
if catch { if catch {
ret = Some(ret.map_or_else(|| result_ty(unit_ty()), |ret| result_ty(ret))) ret = Some(ret.map_or_else(|| result_ty(unit_ty()), result_ty))
} }
let shim = { let shim = {