From adfd6d4b3a0fe350b138e4cdd498eaf4c4fe621a Mon Sep 17 00:00:00 2001 From: Hendrik Sollich Date: Tue, 25 Jul 2023 20:37:34 +0200 Subject: [PATCH 1/2] fix: raise syn to 2.0 --- Cargo.toml | 2 +- src/helpers.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 856b009..d05be72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,6 @@ edition = "2021" proc-macro = true [dependencies] -syn = "1" +syn = "2" quote = "1" proc-macro2 = "1" diff --git a/src/helpers.rs b/src/helpers.rs index 2a24140..c47d72d 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -31,10 +31,12 @@ pub fn has_binding_arguments(segments: &[syn::PathSegment]) -> bool { if let Some(&syn::PathArguments::AngleBracketed(ref generics)) = segments.last().map(|x| &x.arguments) { - generics - .args - .iter() - .any(|f| matches!(f, syn::GenericArgument::Binding(_))) + generics.args.iter().any(|f| { + matches!( + f, + syn::GenericArgument::AssocConst(_) | syn::GenericArgument::AssocType(_) + ) + }) } else { false } From 3bd94313d2ab357636474ac747745ded250e29db Mon Sep 17 00:00:00 2001 From: Hendrik Sollich Date: Tue, 25 Jul 2023 20:38:47 +0200 Subject: [PATCH 2/2] refactor: clippy --- src/helpers.rs | 10 ++++------ tests/borrowed.rs | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index c47d72d..9843691 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,7 +1,7 @@ use crate::field_kind::FieldKind; pub fn has_lifetime_arguments(segments: &[syn::PathSegment]) -> bool { - if let Some(&syn::PathArguments::AngleBracketed(ref generics)) = + if let Some(syn::PathArguments::AngleBracketed(generics)) = segments.last().map(|x| &x.arguments) { generics @@ -14,7 +14,7 @@ pub fn has_lifetime_arguments(segments: &[syn::PathSegment]) -> bool { } pub fn number_of_type_arguments(segments: &[syn::PathSegment]) -> usize { - if let Some(&syn::PathArguments::AngleBracketed(ref generics)) = + if let Some(syn::PathArguments::AngleBracketed(generics)) = segments.last().map(|x| &x.arguments) { generics @@ -28,7 +28,7 @@ pub fn number_of_type_arguments(segments: &[syn::PathSegment]) -> usize { } pub fn has_binding_arguments(segments: &[syn::PathSegment]) -> bool { - if let Some(&syn::PathArguments::AngleBracketed(ref generics)) = + if let Some(syn::PathArguments::AngleBracketed(generics)) = segments.last().map(|x| &x.arguments) { generics.args.iter().any(|f| { @@ -68,9 +68,7 @@ pub fn is_cow(segments: &[syn::PathSegment]) -> bool { } pub fn is_cow_alike(segments: &[syn::PathSegment]) -> bool { - if let Some(&syn::PathArguments::AngleBracketed(ref _data)) = - segments.last().map(|x| &x.arguments) - { + if let Some(syn::PathArguments::AngleBracketed(_data)) = segments.last().map(|x| &x.arguments) { has_lifetime_arguments(segments) } else { false diff --git a/tests/borrowed.rs b/tests/borrowed.rs index 40e86ed..d81cf2a 100644 --- a/tests/borrowed.rs +++ b/tests/borrowed.rs @@ -37,6 +37,6 @@ fn borrowed() { fn test<'b, 'a: 'b>(lives_longer: &Foo<'a>, lives_less: Foo<'b>) { drop(lives_less); - #[allow(clippy::drop_ref)] + #[allow(dropping_references)] drop(lives_longer); }