git.delta.rocks / unique-network / refs/commits / 7b633dc2f17c

difftreelog

fix clippy

Trubnikov Sergey2022-12-02parent: #ad92b1d.patch.diff
in: master

2 files changed

modifiedcrates/evm-coder/procedural/src/abi_derive/derive_enum.rsdiffbeforeafterboth
85 )85 )
86}86}
8787
88pub fn impl_enum_solidity_type_name<'a>(name: &syn::Ident) -> proc_macro2::TokenStream {88pub fn impl_enum_solidity_type_name(name: &syn::Ident) -> proc_macro2::TokenStream {
89 quote!(89 quote!(
90 #[cfg(feature = "stubgen")]90 #[cfg(feature = "stubgen")]
91 impl ::evm_coder::solidity::SolidityTypeName for #name {91 impl ::evm_coder::solidity::SolidityTypeName for #name {
154154
155pub fn check_and_count_options(de: &syn::DataEnum) -> syn::Result<usize> {155pub fn check_and_count_options(de: &syn::DataEnum) -> syn::Result<usize> {
156 let mut count = 0;156 let mut count = 0;
157 for error in de.variants.iter().filter_map(|v| {157 for v in de.variants.iter() {
158 if !v.fields.is_empty() {158 if !v.fields.is_empty() {
159 Some(Err(syn::Error::new(159 return Err(syn::Error::new(
160 v.ident.span(),160 v.ident.span(),
161 "Enumeration parameters should not have fields",161 "Enumeration parameters should not have fields",
162 )))162 ));
163 } else if v.discriminant.is_some() {163 } else if v.discriminant.is_some() {
164 Some(Err(syn::Error::new(164 return Err(syn::Error::new(
165 v.ident.span(),165 v.ident.span(),
166 "Enumeration options should not have an explicit specified value",166 "Enumeration options should not have an explicit specified value",
167 )))167 ));
168 } else {168 } else {
169 count += 1;169 count += 1;
170 None
171 }170 }
172 }) {171 }
173 return error;
174 }
175172
176 Ok(count)173 Ok(count)
177}174}
178175
179pub fn check_repr_u8(name: &syn::Ident, attrs: &Vec<syn::Attribute>) -> syn::Result<()> {176pub fn check_repr_u8(name: &syn::Ident, attrs: &[syn::Attribute]) -> syn::Result<()> {
180 let mut has_repr = false;177 let mut has_repr = false;
181 for attr in attrs.iter() {178 for attr in attrs.iter() {
182 if attr.path.is_ident("repr") {179 if attr.path.is_ident("repr") {
196fn check_meta_u8(meta: &syn::Meta) -> Result<(), syn::Error> {193fn check_meta_u8(meta: &syn::Meta) -> Result<(), syn::Error> {
197 if let syn::Meta::List(p) = meta {194 if let syn::Meta::List(p) = meta {
198 for nm in p.nested.iter() {195 for nm in p.nested.iter() {
199 if let syn::NestedMeta::Meta(m) = nm {196 if let syn::NestedMeta::Meta(syn::Meta::Path(p)) = nm {
200 if let syn::Meta::Path(p) = m {
201 if !p.is_ident("u8") {197 if !p.is_ident("u8") {
202 return Err(syn::Error::new(198 return Err(syn::Error::new(
203 p.segments199 p.segments
208 "Enum is not \"repr(u8)\"",204 "Enum is not \"repr(u8)\"",
209 ));205 ));
210 }206 }
211 }
212 }207 }
213 }208 }
214 }209 }
modifiedcrates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity/mod.rs
+++ b/crates/evm-coder/src/solidity/mod.rs
@@ -276,7 +276,7 @@
 		writer: &mut impl fmt::Write,
 		tc: &TypeCollector,
 	) -> fmt::Result {
-		let hide_comment = self.hide.then(|| "// ").unwrap_or("");
+		let hide_comment = self.hide.then_some("// ").unwrap();
 		for doc in self.docs {
 			writeln!(writer, "\t{hide_comment}///{}", doc)?;
 		}