From 116a6f44bca2236b7f85da55b8e2eb63cb733191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sommer?= Date: Fri, 31 Aug 2018 13:01:22 +0200 Subject: [PATCH] Fix some hints from Rust and clippy * the feature `proc_macro` has been stable since 1.29.0 and no longer requires an attribute to enable * https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_return * https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#len_zero --- src/api/request.rs | 2 +- src/api/response.rs | 6 +++--- src/lib.rs | 1 - tests/ruma_api_macros.rs | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/api/request.rs b/src/api/request.rs index d8272053..d86a2129 100644 --- a/src/api/request.rs +++ b/src/api/request.rs @@ -181,7 +181,7 @@ impl ToTokens for Request { pub struct Request }; - let request_struct_body = if self.fields.len() == 0 { + let request_struct_body = if self.fields.is_empty() { quote!(;) } else { let fields = self.fields.iter().fold(TokenStream::new(), |mut field_tokens, request_field| { diff --git a/src/api/response.rs b/src/api/response.rs index 3d879f6f..1974d6a9 100644 --- a/src/api/response.rs +++ b/src/api/response.rs @@ -15,7 +15,7 @@ impl Response { } pub fn has_fields(&self) -> bool { - self.fields.len() != 0 + !self.fields.is_empty() } pub fn has_header_fields(&self) -> bool { @@ -142,7 +142,7 @@ impl From> for Response { if has_newtype_body { panic!("ruma_api! responses cannot have both normal body fields and a newtype body field"); } else { - return ResponseField::Body(field); + ResponseField::Body(field) } } ResponseFieldKind::Header => ResponseField::Header(field, header.expect("missing header name")), @@ -164,7 +164,7 @@ impl ToTokens for Response { pub struct Response }; - let response_struct_body = if self.fields.len() == 0 { + let response_struct_body = if self.fields.is_empty() { quote!(;) } else { let fields = self.fields.iter().fold(TokenStream::new(), |mut fields_tokens, response_field| { diff --git a/src/lib.rs b/src/lib.rs index 126a60ba..fa110b54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ //! See the documentation for the `ruma_api!` macro for usage details. #![deny(missing_debug_implementations)] -#![feature(proc_macro)] #![recursion_limit="256"] extern crate proc_macro; diff --git a/tests/ruma_api_macros.rs b/tests/ruma_api_macros.rs index 37295dbb..f6735ea1 100644 --- a/tests/ruma_api_macros.rs +++ b/tests/ruma_api_macros.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro, try_from)] +#![feature(try_from)] extern crate futures; extern crate http;