Jelajahi Sumber

chore: clippy happy on macro

Jonathan Kelley 3 tahun lalu
induk
melakukan
e1c858d

+ 0 - 1
packages/core-macro/src/lib.rs

@@ -1,6 +1,5 @@
 use proc_macro::TokenStream;
 use quote::ToTokens;
-use rsx::{AS_HTML, AS_RSX};
 use syn::parse_macro_input;
 
 pub(crate) mod htm;

+ 3 - 3
packages/core-macro/src/props/mod.rs

@@ -17,7 +17,7 @@ pub fn impl_my_derive(ast: &syn::DeriveInput) -> Result<TokenStream, Error> {
     let data = match &ast.data {
         syn::Data::Struct(data) => match &data.fields {
             syn::Fields::Named(fields) => {
-                let struct_info = struct_info::StructInfo::new(&ast, fields.named.iter())?;
+                let struct_info = struct_info::StructInfo::new(ast, fields.named.iter())?;
                 let builder_creation = struct_info.builder_creation_impl()?;
                 let conversion_helper = struct_info.conversion_helper_impl()?;
                 let fields = struct_info
@@ -196,7 +196,7 @@ mod field_info {
             if let Some(ref name) = field.ident {
                 Ok(FieldInfo {
                     ordinal,
-                    name: &name,
+                    name,
                     generic_ident: syn::Ident::new(
                         &format!("__{}", strip_raw_ident_prefix(name.to_string())),
                         proc_macro2::Span::call_site(),
@@ -585,7 +585,7 @@ mod struct_info {
             // we use the heuristic: are there *any* generic parameters?
             // If so, then they might have non-static lifetimes and we can't compare two generic things that *might borrow*
             // Therefore, we will generate code that shortcircuits the "comparison" in memoization
-            let are_there_generics = self.generics.params.len() > 0;
+            let are_there_generics = !self.generics.params.is_empty();
 
             let (impl_generics, ty_generics, where_clause) = self.generics.split_for_impl();
             let all_fields_param = syn::GenericParam::Type(

+ 5 - 5
packages/core-macro/src/rsx/element.rs

@@ -3,9 +3,8 @@ use super::*;
 use proc_macro2::TokenStream as TokenStream2;
 use quote::{quote, ToTokens, TokenStreamExt};
 use syn::{
-    ext::IdentExt,
-    parse::{discouraged::Speculative, Parse, ParseBuffer, ParseStream},
-    token, Error, Expr, ExprClosure, Ident, LitStr, Result, Token,
+    parse::{Parse, ParseBuffer, ParseStream},
+    token, Expr, ExprClosure, Ident, LitStr, Result, Token,
 };
 
 // =======================================
@@ -32,8 +31,9 @@ impl Parse for Element {
         let mut listeners: Vec<ElementAttrNamed> = vec![];
         let mut children: Vec<BodyNode> = vec![];
         let mut key = None;
-        let mut el_ref = None;
+        let mut _el_ref = None;
 
+        // todo: more descriptive error handling
         while !content.is_empty() {
             if content.peek(Ident) && content.peek2(Token![:]) && !content.peek3(Token![:]) {
                 let name = content.parse::<Ident>()?;
@@ -73,7 +73,7 @@ impl Parse for Element {
                             todo!("custom namespace not supported")
                         }
                         "node_ref" => {
-                            el_ref = Some(content.parse::<Expr>()?);
+                            _el_ref = Some(content.parse::<Expr>()?);
                         }
                         _ => {
                             if content.peek(LitStr) {

+ 1 - 1
packages/core-macro/src/rsx/fragment.rs

@@ -8,7 +8,7 @@
 //! - [ ] Children
 //! - [ ] Keys
 
-use super::{AmbiguousElement, HtmlOrRsx, AS_HTML, AS_RSX};
+use super::AmbiguousElement;
 use syn::parse::ParseBuffer;
 use {
     proc_macro2::TokenStream as TokenStream2,

+ 0 - 4
packages/core-macro/src/rsx/mod.rs

@@ -25,7 +25,3 @@ pub use component::*;
 pub use element::*;
 pub use fragment::*;
 pub use node::*;
-
-pub(crate) type HtmlOrRsx = bool;
-pub const AS_HTML: bool = true;
-pub const AS_RSX: bool = false;