Skip to content

Commit

Permalink
fix(clippy): address latest clippy warnings (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagolobocastro authored Jul 6, 2022
1 parent 894428a commit e0d4989
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions core/src/v2/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion macros/src/actix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
27 changes: 12 additions & 15 deletions src/v2/codegen/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/v2/codegen/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/v2/codegen/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/v2/codegen/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
)?;
Expand Down Expand Up @@ -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(),
},
)?;

Expand Down

0 comments on commit e0d4989

Please sign in to comment.