Skip to content

Commit

Permalink
Make Clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Oct 4, 2024
1 parent 39a8092 commit 623f0b2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion examples/tests/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod lifetime {
#[derive(Clone, Deserialize, Serialize)]
struct Y(bool);

impl<'a> From<X<'a>> for Y {
impl From<X<'_>> for Y {
fn from(x: X) -> Self {
Self(*x.0)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct Foo;
#[derive(Clone)]
struct Bar<'a>(&'a Foo);

impl<'a> Serialize for Bar<'a> {
impl Serialize for Bar<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -15,7 +15,7 @@ impl<'a> Serialize for Bar<'a> {
}
}

impl<'de, 'a> Deserialize<'de> for Bar<'a> {
impl<'de> Deserialize<'de> for Bar<'_> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
Expand Down
1 change: 1 addition & 0 deletions examples/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ mod byte_array {
}

mod option {
#[allow(clippy::ref_option)]
#[test_fuzz::test_fuzz]
fn target(option: Option<u8>, ref_option: &Option<u8>, ref_mut_option: &mut Option<u8>) {
super::consume(option);
Expand Down
33 changes: 16 additions & 17 deletions macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn test_fuzz_impl(args: TokenStream, item: TokenStream) -> TokenStream {
(Some(path.clone()), Some(quote! { #bang #path #for_ }))
});

let (impl_items, modules) = map_impl_items(&generics, &trait_path, &self_ty, &items);
let (impl_items, modules) = map_impl_items(&generics, trait_path.as_ref(), &self_ty, &items);

let result = quote! {
#(#attrs)* #defaultness #unsafety #impl_token #generics #trait_ #self_ty #where_clause {
Expand All @@ -78,7 +78,7 @@ pub fn test_fuzz_impl(args: TokenStream, item: TokenStream) -> TokenStream {

fn map_impl_items(
generics: &Generics,
trait_path: &Option<Path>,
trait_path: Option<&Path>,
self_ty: &Type,
items: &[ImplItem],
) -> (Vec<ImplItem>, Vec<ItemMod>) {
Expand All @@ -93,17 +93,16 @@ fn map_impl_items(
(impl_items, modules)
}

fn map_impl_item(
generics: &Generics,
trait_path: &Option<Path>,
self_ty: &Type,
) -> impl Fn(&ImplItem) -> (ImplItem, Option<ItemMod>) {
fn map_impl_item<'a>(
generics: &'a Generics,
trait_path: Option<&'a Path>,
self_ty: &'a Type,
) -> impl Fn(&ImplItem) -> (ImplItem, Option<ItemMod>) + 'a {
let generics = generics.clone();
let trait_path = trait_path.clone();
let self_ty = self_ty.clone();
move |impl_item| {
if let ImplItem::Fn(impl_item_fn) = &impl_item {
map_impl_item_fn(&generics, &trait_path, &self_ty, impl_item_fn)
map_impl_item_fn(&generics, trait_path, &self_ty, impl_item_fn)
} else {
(impl_item.clone(), None)
}
Expand All @@ -116,7 +115,7 @@ fn map_impl_item(
// https://github.com/dtolnay/syn/releases/tag/2.0.0
fn map_impl_item_fn(
generics: &Generics,
trait_path: &Option<Path>,
trait_path: Option<&Path>,
self_ty: &Type,
impl_item_fn: &ImplItemFn,
) -> (ImplItem, Option<ItemMod>) {
Expand All @@ -142,7 +141,7 @@ fn map_impl_item_fn(
&opts,
&attrs,
vis,
defaultness,
defaultness.as_ref(),
sig,
block,
);
Expand Down Expand Up @@ -189,12 +188,12 @@ pub fn test_fuzz(args: TokenStream, item: TokenStream) -> TokenStream {
} = &item;
let (item, module) = map_method_or_fn(
&Generics::default(),
&None,
None,
None,
&opts,
attrs,
vis,
&None,
None,
sig,
block,
);
Expand All @@ -215,12 +214,12 @@ pub fn test_fuzz(args: TokenStream, item: TokenStream) -> TokenStream {
#[cfg_attr(dylint_lib = "supplementary", allow(commented_code))]
fn map_method_or_fn(
generics: &Generics,
trait_path: &Option<Path>,
trait_path: Option<&Path>,
self_ty: Option<&Type>,
opts: &TestFuzzOpts,
attrs: &Vec<Attribute>,
vis: &Visibility,
defaultness: &Option<token::Default>,
defaultness: Option<&token::Default>,
sig: &Signature,
block: &Block,
) -> (TokenStream2, ItemMod) {
Expand Down Expand Up @@ -766,7 +765,7 @@ fn generic_params_map<'a, 'b>(
fn map_args<'a, I>(
conversions: &mut Conversions,
candidates: &mut BTreeSet<OrdType>,
trait_path: &Option<Path>,
trait_path: Option<&Path>,
self_ty: Option<&Type>,
inputs: I,
) -> (Vec<Type>, Vec<Stmt>, Vec<Expr>, Vec<Expr>)
Expand All @@ -784,7 +783,7 @@ where
fn map_arg<'a>(
conversions: &'a mut Conversions,
candidates: &'a mut BTreeSet<OrdType>,
trait_path: &'a Option<Path>,
trait_path: Option<&'a Path>,
self_ty: Option<&'a Type>,
) -> impl FnMut((usize, &FnArg)) -> (Type, Stmt, Expr, Expr) + 'a {
move |(i, arg)| {
Expand Down
10 changes: 5 additions & 5 deletions macro/src/type_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct GenericParamVisitor<'a> {
map: &'a BTreeMap<&'a Ident, &'a GenericArgument>,
}

impl<'a> VisitMut for GenericParamVisitor<'a> {
impl VisitMut for GenericParamVisitor<'_> {
fn visit_type_mut(&mut self, ty: &mut Type) {
if let Type::Path(TypePath { qself: None, path }) = ty {
if let Some(ident) = path.get_ident() {
Expand Down Expand Up @@ -64,7 +64,7 @@ struct TurbofishVisitor {
tokens: Vec<TokenTree>,
}

impl<'a> Visit<'a> for TurbofishVisitor {
impl Visit<'_> for TurbofishVisitor {
fn visit_path_arguments(&mut self, path_args: &PathArguments) {
if !path_args.is_none() {
let mut visitor_token_strings = token_strings(&self.tokens);
Expand Down Expand Up @@ -99,7 +99,7 @@ fn token_strings(tokens: &[TokenTree]) -> Vec<String> {
tokens.iter().map(ToString::to_string).collect::<Vec<_>>()
}

pub fn expand_self(trait_path: &Option<Path>, self_ty: &Type, ty: &Type) -> Type {
pub fn expand_self(trait_path: Option<&Path>, self_ty: &Type, ty: &Type) -> Type {
let mut ty = ty.clone();
let mut visitor = ExpandSelfVisitor {
trait_path,
Expand All @@ -110,11 +110,11 @@ pub fn expand_self(trait_path: &Option<Path>, self_ty: &Type, ty: &Type) -> Type
}

struct ExpandSelfVisitor<'a> {
trait_path: &'a Option<Path>,
trait_path: Option<&'a Path>,
self_ty: &'a Type,
}

impl<'a> VisitMut for ExpandSelfVisitor<'a> {
impl VisitMut for ExpandSelfVisitor<'_> {
fn visit_type_mut(&mut self, ty: &mut Type) {
// smoelius: Rewrite this using if-let-guards once the feature is stable.
// https://rust-lang.github.io/rfcs/2294-if-let-guard.html
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<T> TryDebugFallback for T {

pub struct TryDebug<'a, T>(pub &'a T);

impl<'a, T: Debug> TryDebug<'a, T> {
impl<T: Debug> TryDebug<'_, T> {
pub fn apply<U>(&self, f: &mut dyn FnMut(&dyn Debug) -> U) -> U {
f(self.0)
}
Expand Down

0 comments on commit 623f0b2

Please sign in to comment.