[clippy] macro: remaining clippy lints

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-08-22 09:24:37 +02:00
parent c241be9e6a
commit 05b432c422
5 changed files with 12 additions and 24 deletions

View File

@ -22,7 +22,7 @@ fn handle_error(
) -> TokenStream { ) -> TokenStream {
match err.downcast::<syn::Error>() { match err.downcast::<syn::Error>() {
Ok(err) => { 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.extend(err);
item.into() item.into()
} }

View File

@ -47,7 +47,8 @@ pub fn optional_visibility(tokens: &mut TokenIter) -> Result<syn::Visibility, Er
use syn::parse::Parser; use syn::parse::Parser;
let parser = <syn::Visibility as syn::parse::Parse>::parse; let parser = <syn::Visibility as syn::parse::Parse>::parse;
return Ok(parser.parse2(visibility)?);
Ok(parser.parse2(visibility)?)
} }
pub fn match_keyword( pub fn match_keyword(
@ -309,12 +310,7 @@ pub fn parse_object(tokens: TokenStream) -> Result<Object, Error> {
let mut out = Object::new(tokens.span()); let mut out = Object::new(tokens.span());
let mut tokens = tokens.into_iter().peekable(); let mut tokens = tokens.into_iter().peekable();
loop { while let Some(key) = parse_object_key(&mut tokens)? {
let key = match parse_object_key(&mut tokens)? {
Some(key) => key,
None => break,
};
let value = parse_object_value(&mut tokens, &key)?; let value = parse_object_value(&mut tokens, &key)?;
if out.insert(key.clone(), value).is_some() { if out.insert(key.clone(), value).is_some() {

View File

@ -13,11 +13,8 @@ pub fn router_macro(input: TokenStream) -> Result<TokenStream, Error> {
let mut out = TokenStream::new(); let mut out = TokenStream::new();
loop { while let Some(ref peek_val) = input.peek() {
let mut at_span = match input.peek() { let mut at_span = peek_val.span();
Some(ref val) => val.span(),
None => break,
};
let public = optional_visibility(&mut input)?; let public = optional_visibility(&mut input)?;

View File

@ -29,7 +29,7 @@ impl Name {
} }
pub fn span(&self) -> Span { pub fn span(&self) -> Span {
self.1.clone() self.1
} }
} }
@ -43,10 +43,6 @@ impl PartialEq for Name {
fn eq(&self, rhs: &Self) -> bool { fn eq(&self, rhs: &Self) -> bool {
self.0 == rhs.0 self.0 == rhs.0
} }
fn ne(&self, rhs: &Self) -> bool {
self.0 != rhs.0
}
} }
impl Eq for Name {} impl Eq for Name {}

View File

@ -22,15 +22,13 @@ pub fn to_camel_case(text: &str) -> String {
for c in text.chars() { for c in text.chars() {
if c == '_' { if c == '_' {
capitalize = true; capitalize = true;
} else { } else if capitalize {
if capitalize {
out.extend(c.to_uppercase()); out.extend(c.to_uppercase());
capitalize = false; capitalize = false;
} else { } else {
out.push(c); out.push(c);
} }
} }
}
out out
} }
@ -61,6 +59,7 @@ pub struct ApiAttr {
impl Parse for ApiAttr { impl Parse for ApiAttr {
fn parse(input: ParseStream) -> syn::Result<Self> { fn parse(input: ParseStream) -> syn::Result<Self> {
let content; let content;
#[allow(clippy::eval_order_dependence)]
Ok(ApiAttr { Ok(ApiAttr {
paren_token: parenthesized!(content in input), paren_token: parenthesized!(content in input),
items: content.parse_terminated(ApiItem::parse)?, items: content.parse_terminated(ApiItem::parse)?,