Skip to content

Commit

Permalink
Fix more lints
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Jan 12, 2025
1 parent 1a7a406 commit 66b4976
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 47 deletions.
50 changes: 24 additions & 26 deletions crates/rune-alloc-macros/src/try_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,32 @@ pub(super) fn expand(mut input: syn::DeriveInput) -> Result<TokenStream, Vec<syn
(index, f, member, var, attr)
});

let assigns =
members
.clone()
.map(|(index, f, member, var, _)| match &f.ident {
Some(..) => syn::FieldValue {
attrs: Vec::new(),
member,
colon_token: None,
expr: syn::Expr::Verbatim(quote!()),
},
None => {
let member = syn::Member::Unnamed(syn::Index::from(index));

let expr = syn::Expr::Path(syn::ExprPath {
attrs: Vec::new(),
qself: None,
path: syn::Path::from(var),
});

syn::FieldValue {
attrs: Vec::new(),
member,
colon_token: Some(<syn::Token![:]>::default()),
expr,
}
}
let assigns = members.clone().map(|(index, f, member, var, _)| {
if f.ident.is_some() {
syn::FieldValue {
attrs: Vec::new(),
member,
colon_token: None,
expr: syn::Expr::Verbatim(quote!()),
}
} else {
let member = syn::Member::Unnamed(syn::Index::from(index));

let expr = syn::Expr::Path(syn::ExprPath {
attrs: Vec::new(),
qself: None,
path: syn::Path::from(var),
});

syn::FieldValue {
attrs: Vec::new(),
member,
colon_token: Some(<syn::Token![:]>::default()),
expr,
}
}
});

let fields = members.clone().map(|(_, _, member, var, attr)| {
let expr = match attr.with {
With::Copy => quote! { *#var },
Expand Down
5 changes: 1 addition & 4 deletions crates/rune-alloc/src/btree/navigate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,7 @@ impl<BorrowType: marker::BorrowType, K, V>
loop {
edge = match edge.right_kv() {
Ok(internal_kv) => return Ok(internal_kv),
Err(last_edge) => match last_edge.into_node().ascend() {
Ok(parent_edge) => parent_edge,
Err(root) => return Err(root),
},
Err(last_edge) => last_edge.into_node().ascend()?,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rune-alloc/src/hashbrown/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2289,7 +2289,7 @@ where
}

self.iter()
.all(|(key, value)| other.get(key).map_or(false, |v| *value == *v))
.all(|(key, value)| other.get(key).is_some_and(|v| *value == *v))
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/rune-tracing-macros/src/instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl syn::parse::Parse for Expander {
}

impl Expander {
pub fn expand(self, attr: &Attr) -> Result<TokenStream, Vec<syn::Error>> {
pub(super) fn expand(self, attr: &Attr) -> TokenStream {
let mut it = self.sig.inputs.iter();

let first = match it.next() {
Expand Down Expand Up @@ -97,12 +97,12 @@ impl Expander {
let sig = &self.sig;
let remaining = &self.remaining;

Ok(quote! {
quote! {
#(#attrs)*
#vis #sig {
#log
#remaining
}
})
}
}
}
14 changes: 1 addition & 13 deletions crates/rune-tracing-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,7 @@ pub fn instrument_ast(
) -> proc_macro::TokenStream {
let attr = syn::parse_macro_input!(attr as instrument::Attr);
let internal_call = syn::parse_macro_input!(item as instrument::Expander);

internal_call
.expand(&attr)
.unwrap_or_else(to_compile_errors)
.into()
}

fn to_compile_errors<I>(errors: I) -> proc_macro2::TokenStream
where
I: IntoIterator<Item = syn::Error>,
{
let compile_errors = errors.into_iter().map(syn::Error::into_compile_error);
::quote::quote!(#(#compile_errors)*)
internal_call.expand(&attr).into()
}

/// Passthrough attribute macro.
Expand Down

0 comments on commit 66b4976

Please sign in to comment.