api-macro: clippy fixes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-11-30 17:00:27 +01:00
parent 60fa521095
commit e461be1c9f
4 changed files with 10 additions and 9 deletions

View File

@ -356,7 +356,7 @@ fn handle_function_signature(
// Found an explicit parameter: extract it:
ParameterType::Normal(NormalParameter {
ty: &pat_type.ty,
entry: &entry,
entry,
})
} else if is_api_method_type(&pat_type.ty) {
if api_method_param.is_some() {
@ -567,7 +567,7 @@ fn extract_normal_parameter(
) -> Result<(), Error> {
let span = name_span; // renamed during refactorization
let name_str = syn::LitStr::new(name.as_str(), span);
let arg_name = Ident::new(&format!("input_arg_{}", name.as_ident().to_string()), span);
let arg_name = Ident::new(&format!("input_arg_{}", name.as_ident()), span);
let default_value = param.entry.schema.find_schema_property("default");

View File

@ -443,7 +443,7 @@ pub enum OptionType {
/// An updater type uses its "base" type's field's updaters to determine whether the field is
/// supposed to be an option.
Updater(syn::Type),
Updater(Box<syn::Type>),
}
impl OptionType {
@ -465,7 +465,7 @@ impl From<bool> for OptionType {
impl From<syn::Type> for OptionType {
fn from(ty: syn::Type) -> Self {
OptionType::Updater(ty)
OptionType::Updater(Box::new(ty))
}
}

View File

@ -8,6 +8,7 @@ use std::convert::TryFrom;
use crate::util::{AttrArgs, FieldName};
/// Serde name types.
#[allow(clippy::enum_variant_names)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RenameAll {
LowerCase,

View File

@ -561,7 +561,7 @@ pub fn make_path(span: Span, leading_colon: bool, path: &[&str]) -> syn::Path {
None
},
segments: path
.into_iter()
.iter()
.map(|entry| syn::PathSegment {
ident: Ident::new(entry, span),
arguments: syn::PathArguments::None,
@ -682,9 +682,9 @@ impl<T> Maybe<T> {
}
}
impl<T> Into<Option<T>> for Maybe<T> {
fn into(self) -> Option<T> {
match self {
impl<T> From<Maybe<T>> for Option<T> {
fn from(maybe: Maybe<T>) -> Option<T> {
match maybe {
Maybe::Explicit(t) | Maybe::Derived(t) => Some(t),
Maybe::None => None,
}
@ -694,7 +694,7 @@ impl<T> Into<Option<T>> for Maybe<T> {
/// Helper to iterate over all the `#[derive(...)]` types found in an attribute list.
pub fn derived_items(attributes: &[syn::Attribute]) -> DerivedItems {
DerivedItems {
attributes: attributes.into_iter(),
attributes: attributes.iter(),
current: None,
}
}