From e0d4989d185876107d8eac87ab607cc1d5feb793 Mon Sep 17 00:00:00 2001 From: Tiago Castro Date: Wed, 6 Jul 2022 17:51:27 +0100 Subject: [PATCH] fix(clippy): address latest clippy warnings (#448) --- core/src/v2/models.rs | 4 ++-- macros/src/actix.rs | 2 +- src/v2/codegen/emitter.rs | 27 ++++++++++++--------------- src/v2/codegen/impls.rs | 2 +- src/v2/codegen/object.rs | 2 +- src/v2/codegen/state.rs | 8 ++++---- 6 files changed, 21 insertions(+), 24 deletions(-) diff --git a/core/src/v2/models.rs b/core/src/v2/models.rs index d72fabdf9..d8cd61535 100644 --- a/core/src/v2/models.rs +++ b/core/src/v2/models.rs @@ -239,8 +239,8 @@ impl SpecFormat { /// The mime for this format. pub fn mime(self) -> &'static MediaRange { match self { - SpecFormat::Json => &*JSON_MIME, - SpecFormat::Yaml => &*YAML_MIME, + SpecFormat::Json => &JSON_MIME, + SpecFormat::Yaml => &YAML_MIME, } } } diff --git a/macros/src/actix.rs b/macros/src/actix.rs index 0be04752b..63f2a7994 100644 --- a/macros/src/actix.rs +++ b/macros/src/actix.rs @@ -1314,7 +1314,7 @@ pub fn emit_v2_header(input: TokenStream) -> TokenStream { }; let (quoted_type, quoted_format) = if let Some(format) = parameter_attrs.get("format") { - let quoted_format = quote_format(&*format); + let quoted_format = quote_format(format); let quoted_type = quote! { #quoted_format.map(|format| format.into()) }; (quoted_type, quoted_format) } else { diff --git a/src/v2/codegen/emitter.rs b/src/v2/codegen/emitter.rs index 5efbbc26d..2db411687 100644 --- a/src/v2/codegen/emitter.rs +++ b/src/v2/codegen/emitter.rs @@ -595,7 +595,7 @@ where // be in its own module, which is identified by the initial parent name. if let Some(name) = self.def_anon_name(def, &ctx.parents) { ty_path.push_str("::"); - let parent = ctx.parents.get(0).expect("expected first parent name"); + let parent = ctx.parents.first().expect("expected first parent name"); ty_path.push_str(&parent.to_snake_case()); ty_path.push_str("::"); ty_path.push_str(&name); @@ -808,21 +808,18 @@ where } } - params = params - .into_iter() - .filter(|p| { - let skip = p.presence == ParameterIn::FormData && schema_path.is_some(); - if skip { - warn!( - "Skipping form data parameter {:?} in path {:?} because \ + params.retain(|p| { + let skip = p.presence == ParameterIn::FormData && schema_path.is_some(); + if skip { + warn!( + "Skipping form data parameter {:?} in path {:?} because \ the operation already has a body.", - p.name, self.path - ); - } + p.name, self.path + ); + } - !skip - }) - .collect(); + !skip + }); // If there's a matching object, add the params to its operation. if let Some(pat) = schema_path.as_ref() { @@ -904,7 +901,7 @@ where if let Some(def) = p.schema.as_ref() { // If a schema exists, then get its path for later use. - let pat = self.emitter.def_mod_path(&*def.read())?; + let pat = self.emitter.def_mod_path(&def.read())?; if def_mods.get(&pat).is_some() { schema_path = Some(pat); continue; diff --git a/src/v2/codegen/impls.rs b/src/v2/codegen/impls.rs index 09f59d4db..6c29fff8d 100644 --- a/src/v2/codegen/impls.rs +++ b/src/v2/codegen/impls.rs @@ -853,7 +853,7 @@ impl<'a, 'b> SendableCodegen<'a, 'b> { { let (range, coder) = match self.builder.decoding { Some(&(ref r, ref c)) => (r.as_str(), c), - None => ((*JSON_MIME).0.as_ref(), &*JSON_CODER), + None => ((JSON_MIME).0.as_ref(), &*JSON_CODER), }; accepted_range = Some(range); diff --git a/src/v2/codegen/object.rs b/src/v2/codegen/object.rs index 62709d886..3af6ae04e 100644 --- a/src/v2/codegen/object.rs +++ b/src/v2/codegen/object.rs @@ -490,7 +490,7 @@ impl<'a> ApiObjectBuilder<'a> { }, boxed: field.boxed, desc: field.description.as_deref(), - strict_child_fields: &*field.child_req_fields, + strict_child_fields: &field.child_req_fields, param_loc: None, overridden: false, needs_any: field.needs_any, diff --git a/src/v2/codegen/state.rs b/src/v2/codegen/state.rs index 8db3342d9..589fda8e4 100644 --- a/src/v2/codegen/state.rs +++ b/src/v2/codegen/state.rs @@ -297,7 +297,7 @@ pub mod util { TEMPLATE::CLIENT_MOD, &ClientModContext { mod_prefix: &self.normalized_mod_prefix(), - media_coders: &*self.media_coders.borrow(), + media_coders: &self.media_coders.borrow(), base_url: self.base_url.borrow().as_str(), }, )?; @@ -346,14 +346,14 @@ pub mod util { let cli_mod = root.with_file_name("cli.rs"); self.write_contents(&base_content, &clap_yaml)?; - self.append_contents(&*self.cli_yaml.borrow(), &clap_yaml)?; + self.append_contents(&self.cli_yaml.borrow(), &clap_yaml)?; // CLI module let cli_content = template::render( TEMPLATE::CLI_UTIL, &CliUtilContext { - match_arms: &*self.cli_match_arms.borrow(), - media_coders: &*self.media_coders.borrow(), + match_arms: &self.cli_match_arms.borrow(), + media_coders: &self.media_coders.borrow(), }, )?;