diff --git a/proxmox-api-macro/src/lib.rs b/proxmox-api-macro/src/lib.rs index 809d0d80..d42c2037 100644 --- a/proxmox-api-macro/src/lib.rs +++ b/proxmox-api-macro/src/lib.rs @@ -22,7 +22,7 @@ fn handle_error( ) -> TokenStream { match err.downcast::() { Ok(err) => { - let err: proc_macro2::TokenStream = err.to_compile_error().into(); + let err: proc_macro2::TokenStream = err.to_compile_error(); item.extend(err); item.into() } diff --git a/proxmox-api-macro/src/parsing.rs b/proxmox-api-macro/src/parsing.rs index 574afeed..04738a58 100644 --- a/proxmox-api-macro/src/parsing.rs +++ b/proxmox-api-macro/src/parsing.rs @@ -47,7 +47,8 @@ pub fn optional_visibility(tokens: &mut TokenIter) -> Result::parse; - return Ok(parser.parse2(visibility)?); + + Ok(parser.parse2(visibility)?) } pub fn match_keyword( @@ -309,12 +310,7 @@ pub fn parse_object(tokens: TokenStream) -> Result { let mut out = Object::new(tokens.span()); let mut tokens = tokens.into_iter().peekable(); - loop { - let key = match parse_object_key(&mut tokens)? { - Some(key) => key, - None => break, - }; - + while let Some(key) = parse_object_key(&mut tokens)? { let value = parse_object_value(&mut tokens, &key)?; if out.insert(key.clone(), value).is_some() { diff --git a/proxmox-api-macro/src/router_macro.rs b/proxmox-api-macro/src/router_macro.rs index 400b395f..1d04c998 100644 --- a/proxmox-api-macro/src/router_macro.rs +++ b/proxmox-api-macro/src/router_macro.rs @@ -13,11 +13,8 @@ pub fn router_macro(input: TokenStream) -> Result { let mut out = TokenStream::new(); - loop { - let mut at_span = match input.peek() { - Some(ref val) => val.span(), - None => break, - }; + while let Some(ref peek_val) = input.peek() { + let mut at_span = peek_val.span(); let public = optional_visibility(&mut input)?; diff --git a/proxmox-api-macro/src/types.rs b/proxmox-api-macro/src/types.rs index d404eab9..220f992f 100644 --- a/proxmox-api-macro/src/types.rs +++ b/proxmox-api-macro/src/types.rs @@ -29,7 +29,7 @@ impl Name { } pub fn span(&self) -> Span { - self.1.clone() + self.1 } } @@ -43,10 +43,6 @@ impl PartialEq for Name { fn eq(&self, rhs: &Self) -> bool { self.0 == rhs.0 } - - fn ne(&self, rhs: &Self) -> bool { - self.0 != rhs.0 - } } impl Eq for Name {} diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs index 6bd05fc9..e7cb7939 100644 --- a/proxmox-api-macro/src/util.rs +++ b/proxmox-api-macro/src/util.rs @@ -22,13 +22,11 @@ pub fn to_camel_case(text: &str) -> String { for c in text.chars() { if c == '_' { capitalize = true; + } else if capitalize { + out.extend(c.to_uppercase()); + capitalize = false; } else { - if capitalize { - out.extend(c.to_uppercase()); - capitalize = false; - } else { - out.push(c); - } + out.push(c); } } @@ -61,6 +59,7 @@ pub struct ApiAttr { impl Parse for ApiAttr { fn parse(input: ParseStream) -> syn::Result { let content; + #[allow(clippy::eval_order_dependence)] Ok(ApiAttr { paren_token: parenthesized!(content in input), items: content.parse_terminated(ApiItem::parse)?,