clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
92ffe4c240
commit
65a284784b
@ -14,7 +14,7 @@ mod enums;
|
||||
mod method;
|
||||
mod structs;
|
||||
|
||||
pub const INTNAMES: &[&'static str] = &[
|
||||
pub const INTNAMES: &[&str] = &[
|
||||
"Integer", "i8", "i16", "i32", "i64", "isize", "u8", "u16", "u32", "u64", "usize",
|
||||
];
|
||||
|
||||
@ -103,7 +103,7 @@ impl Schema {
|
||||
self.item.to_schema(
|
||||
ts,
|
||||
self.description.as_ref(),
|
||||
&self.span,
|
||||
self.span,
|
||||
&self.properties,
|
||||
true,
|
||||
)
|
||||
@ -113,7 +113,7 @@ impl Schema {
|
||||
self.item.to_schema(
|
||||
ts,
|
||||
self.description.as_ref(),
|
||||
&self.span,
|
||||
self.span,
|
||||
&self.properties,
|
||||
false,
|
||||
)
|
||||
@ -212,10 +212,10 @@ impl SchemaItem {
|
||||
&self,
|
||||
ts: &mut TokenStream,
|
||||
description: Option<&syn::LitStr>,
|
||||
span: &Span,
|
||||
span: Span,
|
||||
properties: &[(Ident, syn::Expr)],
|
||||
) -> Result<bool, Error> {
|
||||
let description = description.ok_or_else(|| format_err!(*span, "missing description"));
|
||||
let description = description.ok_or_else(|| format_err!(span, "missing description"));
|
||||
|
||||
match self {
|
||||
SchemaItem::Null => {
|
||||
@ -276,7 +276,7 @@ impl SchemaItem {
|
||||
&self,
|
||||
ts: &mut TokenStream,
|
||||
description: Option<&syn::LitStr>,
|
||||
span: &Span,
|
||||
span: Span,
|
||||
properties: &[(Ident, syn::Expr)],
|
||||
typed: bool,
|
||||
) -> Result<(), Error> {
|
||||
|
@ -73,17 +73,14 @@ pub fn handle_enum(
|
||||
|
||||
let args: AttrArgs = syn::parse2(attrib.tokens.clone())?;
|
||||
for arg in args.args {
|
||||
match arg {
|
||||
syn::NestedMeta::Meta(syn::Meta::NameValue(var)) => {
|
||||
if var.path.is_ident("rename") {
|
||||
match var.lit {
|
||||
syn::Lit::Str(lit) => variants.push(lit),
|
||||
_ => bail!(var.lit => "'rename' value must be a string literal"),
|
||||
}
|
||||
renamed = true;
|
||||
if let syn::NestedMeta::Meta(syn::Meta::NameValue(var)) = arg {
|
||||
if var.path.is_ident("rename") {
|
||||
match var.lit {
|
||||
syn::Lit::Str(lit) => variants.push(lit),
|
||||
_ => bail!(var.lit => "'rename' value must be a string literal"),
|
||||
}
|
||||
renamed = true;
|
||||
}
|
||||
_ => (), // ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,13 +62,10 @@ pub fn handle_method(mut attribs: JSONObject, mut func: syn::ItemFn) -> Result<T
|
||||
|
||||
let returns_schema = {
|
||||
let mut ts = TokenStream::new();
|
||||
match returns_schema {
|
||||
Some(schema) => {
|
||||
let mut inner = TokenStream::new();
|
||||
schema.to_schema(&mut inner)?;
|
||||
ts.extend(quote! { .returns(#inner) });
|
||||
}
|
||||
None => (),
|
||||
if let Some(schema) = returns_schema {
|
||||
let mut inner = TokenStream::new();
|
||||
schema.to_schema(&mut inner)?;
|
||||
ts.extend(quote! { .returns(#inner) });
|
||||
}
|
||||
ts
|
||||
};
|
||||
@ -247,12 +244,10 @@ fn handle_function_signature(
|
||||
let param_type = if let Some((name, optional, schema)) =
|
||||
input_schema.find_obj_property_by_ident(&pat.ident.to_string())
|
||||
{
|
||||
match schema {
|
||||
PropertySchema::Schema(schema) => match &schema.item {
|
||||
SchemaItem::Inferred(span) => bail!(*span, "failed to infer type"),
|
||||
_ => (),
|
||||
},
|
||||
_ => (),
|
||||
if let PropertySchema::Schema(schema) = schema {
|
||||
if let SchemaItem::Inferred(span) = &schema.item {
|
||||
bail!(*span, "failed to infer type");
|
||||
}
|
||||
}
|
||||
param_name = name.clone();
|
||||
// Found an explicit parameter: extract it:
|
||||
@ -426,5 +421,5 @@ fn create_wrapper_function(
|
||||
}
|
||||
});
|
||||
|
||||
return Ok(api_func_name);
|
||||
Ok(api_func_name)
|
||||
}
|
||||
|
@ -116,6 +116,8 @@ impl Parse for FieldName {
|
||||
/// Most of our schema definition consists of a json-like notation.
|
||||
/// For parsing we mostly just need to destinguish between objects and non-objects.
|
||||
/// For specific expression types we match on the contained expression later on.
|
||||
// FIXME: Expr(Box<syn::Expr>)
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum JSONValue {
|
||||
Object(JSONObject),
|
||||
Expr(syn::Expr),
|
||||
@ -283,7 +285,7 @@ impl JSONObject {
|
||||
input.parse_terminated(JSONMapEntry::parse)?;
|
||||
let mut elems = HashMap::with_capacity(map_elems.len());
|
||||
for c in map_elems {
|
||||
if elems.insert(c.key.clone().into(), c.value).is_some() {
|
||||
if elems.insert(c.key.clone(), c.value).is_some() {
|
||||
bail!(c.key.span(), "duplicate '{}' in schema", c.key.as_str());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user