From 469c9a31786c9ddffe0c6fee82a336d202c48c1c Mon Sep 17 00:00:00 2001 From: Jose Torres Date: Sun, 15 Feb 2026 16:28:27 -0500 Subject: [PATCH 1/3] renaming BareFn to FnPtr --- src/classify.rs | 4 ++-- src/gen/clone.rs | 2 +- src/gen/debug.rs | 2 +- src/gen/eq.rs | 2 +- src/gen/fold.rs | 4 ++-- src/gen/hash.rs | 2 +- src/gen/visit.rs | 2 +- src/gen/visit_mut.rs | 2 +- src/ty.rs | 8 ++++---- syn.json | 4 ++-- tests/debug/gen.rs | 4 ++-- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/classify.rs b/src/classify.rs index 6d5edbd559..10c23e2e34 100644 --- a/src/classify.rs +++ b/src/classify.rs @@ -71,7 +71,7 @@ pub(crate) fn requires_comma_to_be_match_arm(expr: &Expr) -> bool { pub(crate) fn trailing_unparameterized_path(mut ty: &Type) -> bool { loop { match ty { - Type::BareFn(t) => match &t.output { + Type::FnPtr(t) => match &t.output { ReturnType::Default => return false, ReturnType::Type(_, ret) => ty = ret, }, @@ -244,7 +244,7 @@ pub(crate) fn expr_trailing_brace(mut expr: &Expr) -> bool { fn type_trailing_brace(mut ty: &Type) -> bool { loop { match ty { - Type::BareFn(t) => match &t.output { + Type::FnPtr(t) => match &t.output { ReturnType::Default => return false, ReturnType::Type(_, ret) => ty = ret, }, diff --git a/src/gen/clone.rs b/src/gen/clone.rs index be2b698422..4fad3c6a5f 100644 --- a/src/gen/clone.rs +++ b/src/gen/clone.rs @@ -1920,7 +1920,7 @@ impl Clone for crate::Type { fn clone(&self) -> Self { match self { crate::Type::Array(v0) => crate::Type::Array(v0.clone()), - crate::Type::BareFn(v0) => crate::Type::BareFn(v0.clone()), + crate::Type::FnPtr(v0) => crate::Type::FnPtr(v0.clone()), crate::Type::Group(v0) => crate::Type::Group(v0.clone()), crate::Type::ImplTrait(v0) => crate::Type::ImplTrait(v0.clone()), crate::Type::Infer(v0) => crate::Type::Infer(v0.clone()), diff --git a/src/gen/debug.rs b/src/gen/debug.rs index bf0784d1c4..fe88cc1e3b 100644 --- a/src/gen/debug.rs +++ b/src/gen/debug.rs @@ -2745,7 +2745,7 @@ impl Debug for crate::Type { formatter.write_str("Type::")?; match self { crate::Type::Array(v0) => v0.debug(formatter, "Array"), - crate::Type::BareFn(v0) => v0.debug(formatter, "BareFn"), + crate::Type::FnPtr(v0) => v0.debug(formatter, "FnPtr"), crate::Type::Group(v0) => v0.debug(formatter, "Group"), crate::Type::ImplTrait(v0) => v0.debug(formatter, "ImplTrait"), crate::Type::Infer(v0) => v0.debug(formatter, "Infer"), diff --git a/src/gen/eq.rs b/src/gen/eq.rs index 5ba15722b7..0a3a757f1f 100644 --- a/src/gen/eq.rs +++ b/src/gen/eq.rs @@ -1925,7 +1925,7 @@ impl PartialEq for crate::Type { fn eq(&self, other: &Self) -> bool { match (self, other) { (crate::Type::Array(self0), crate::Type::Array(other0)) => self0 == other0, - (crate::Type::BareFn(self0), crate::Type::BareFn(other0)) => self0 == other0, + (crate::Type::FnPtr(self0), crate::Type::FnPtr(other0)) => self0 == other0, (crate::Type::Group(self0), crate::Type::Group(other0)) => self0 == other0, (crate::Type::ImplTrait(self0), crate::Type::ImplTrait(other0)) => { self0 == other0 diff --git a/src/gen/fold.rs b/src/gen/fold.rs index b71421f47a..e814ebe1f9 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -3467,8 +3467,8 @@ where crate::Type::Array(_binding_0) => { crate::Type::Array(f.fold_type_array(_binding_0)) } - crate::Type::BareFn(_binding_0) => { - crate::Type::BareFn(f.fold_type_bare_fn(_binding_0)) + crate::Type::FnPtr(_binding_0) => { + crate::Type::FnPtr(f.fold_type_bare_fn(_binding_0)) } crate::Type::Group(_binding_0) => { crate::Type::Group(f.fold_type_group(_binding_0)) diff --git a/src/gen/hash.rs b/src/gen/hash.rs index 508af526c1..936a0e6bb7 100644 --- a/src/gen/hash.rs +++ b/src/gen/hash.rs @@ -2437,7 +2437,7 @@ impl Hash for crate::Type { state.write_u8(0u8); v0.hash(state); } - crate::Type::BareFn(v0) => { + crate::Type::FnPtr(v0) => { state.write_u8(1u8); v0.hash(state); } diff --git a/src/gen/visit.rs b/src/gen/visit.rs index cd258fcde1..9436295358 100644 --- a/src/gen/visit.rs +++ b/src/gen/visit.rs @@ -3521,7 +3521,7 @@ where crate::Type::Array(_binding_0) => { v.visit_type_array(_binding_0); } - crate::Type::BareFn(_binding_0) => { + crate::Type::FnPtr(_binding_0) => { v.visit_type_bare_fn(_binding_0); } crate::Type::Group(_binding_0) => { diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index 6588182c4f..bcd69935cd 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -3347,7 +3347,7 @@ where crate::Type::Array(_binding_0) => { v.visit_type_array_mut(_binding_0); } - crate::Type::BareFn(_binding_0) => { + crate::Type::FnPtr(_binding_0) => { v.visit_type_bare_fn_mut(_binding_0); } crate::Type::Group(_binding_0) => { diff --git a/src/ty.rs b/src/ty.rs index aae7371e59..622c82f5cb 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -26,8 +26,8 @@ ast_enum_of_structs! { /// A fixed size array type: `[T; n]`. Array(TypeArray), - /// A bare function type: `fn(usize) -> bool`. - BareFn(TypeBareFn), + /// A function pointer type: `fn(usize) -> bool`. + FnPtr(TypeBareFn), /// A type contained within invisible delimiters. Group(TypeGroup), @@ -77,7 +77,7 @@ ast_enum_of_structs! { // #![cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // // Type::Array(ty) => {...} - // Type::BareFn(ty) => {...} + // Type::FnPtr(ty) => {...} // ... // Type::Verbatim(ty) => {...} // @@ -507,7 +507,7 @@ pub(crate) mod parsing { { let mut bare_fn: TypeBareFn = input.parse()?; bare_fn.lifetimes = lifetimes; - Ok(Type::BareFn(bare_fn)) + Ok(Type::FnPtr(bare_fn)) } else if lookahead.peek(Ident) || input.peek(Token![super]) || input.peek(Token![self]) diff --git a/syn.json b/syn.json index d1fbf616ee..7286808092 100644 --- a/syn.json +++ b/syn.json @@ -4803,9 +4803,9 @@ "syn": "TypeArray" } ], - "BareFn": [ + "FnPtr": [ { - "syn": "TypeBareFn" + "syn": "TypeFnPtr" } ], "Group": [ diff --git a/tests/debug/gen.rs b/tests/debug/gen.rs index c0d37b791d..3d41f7f906 100644 --- a/tests/debug/gen.rs +++ b/tests/debug/gen.rs @@ -4104,8 +4104,8 @@ impl Debug for Lite { formatter.field("len", Lite(&_val.len)); formatter.finish() } - syn::Type::BareFn(_val) => { - let mut formatter = formatter.debug_struct("Type::BareFn"); + syn::Type::FnPtr(_val) => { + let mut formatter = formatter.debug_struct("Type::FnPtr"); if let Some(val) = &_val.lifetimes { #[derive(RefCast)] #[repr(transparent)] From 7e81b19866a015b1cc8604de5ee8f2771c3ed214 Mon Sep 17 00:00:00 2001 From: Jose Torres Date: Sun, 15 Feb 2026 16:49:41 -0500 Subject: [PATCH 2/3] more renaming --- src/gen/clone.rs | 8 ++++---- src/gen/debug.rs | 10 +++++----- src/gen/eq.rs | 8 ++++---- src/gen/fold.rs | 12 ++++++------ src/gen/hash.rs | 4 ++-- src/gen/visit.rs | 8 ++++---- src/gen/visit_mut.rs | 8 ++++---- src/lib.rs | 2 +- src/ty.rs | 32 ++++++++++++++++---------------- syn.json | 6 +++--- tests/debug/gen.rs | 8 ++++---- 11 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/gen/clone.rs b/src/gen/clone.rs index 4fad3c6a5f..82a94bc7ca 100644 --- a/src/gen/clone.rs +++ b/src/gen/clone.rs @@ -86,9 +86,9 @@ impl Clone for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "clone-impls")))] -impl Clone for crate::BareFnArg { +impl Clone for crate::FnPtrArg { fn clone(&self) -> Self { - crate::BareFnArg { + crate::FnPtrArg { attrs: self.attrs.clone(), name: self.name.clone(), ty: self.ty.clone(), @@ -1951,9 +1951,9 @@ impl Clone for crate::TypeArray { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "clone-impls")))] -impl Clone for crate::TypeBareFn { +impl Clone for crate::TypeFnPtr { fn clone(&self) -> Self { - crate::TypeBareFn { + crate::TypeFnPtr { lifetimes: self.lifetimes.clone(), unsafety: self.unsafety.clone(), abi: self.abi.clone(), diff --git a/src/gen/debug.rs b/src/gen/debug.rs index fe88cc1e3b..fc1c0942cd 100644 --- a/src/gen/debug.rs +++ b/src/gen/debug.rs @@ -98,9 +98,9 @@ impl Debug for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Debug for crate::BareFnArg { +impl Debug for crate::FnPtrArg { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("BareFnArg"); + let mut formatter = formatter.debug_struct("FnPtrArg"); formatter.field("attrs", &self.attrs); formatter.field("name", &self.name); formatter.field("ty", &self.ty); @@ -2786,13 +2786,13 @@ impl crate::TypeArray { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Debug for crate::TypeBareFn { +impl Debug for crate::TypeFnPtr { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - self.debug(formatter, "TypeBareFn") + self.debug(formatter, "TypeFnPtr") } } #[cfg(any(feature = "derive", feature = "full"))] -impl crate::TypeBareFn { +impl crate::TypeFnPtr { fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { let mut formatter = formatter.debug_struct(name); formatter.field("lifetimes", &self.lifetimes); diff --git a/src/gen/eq.rs b/src/gen/eq.rs index 0a3a757f1f..4b40102ca1 100644 --- a/src/gen/eq.rs +++ b/src/gen/eq.rs @@ -84,10 +84,10 @@ impl PartialEq for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Eq for crate::BareFnArg {} +impl Eq for crate::FnPtrArg {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl PartialEq for crate::BareFnArg { +impl PartialEq for crate::FnPtrArg { fn eq(&self, other: &Self) -> bool { self.attrs == other.attrs && self.name == other.name && self.ty == other.ty } @@ -1963,10 +1963,10 @@ impl PartialEq for crate::TypeArray { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Eq for crate::TypeBareFn {} +impl Eq for crate::TypeFnPtr {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl PartialEq for crate::TypeBareFn { +impl PartialEq for crate::TypeFnPtr { fn eq(&self, other: &Self) -> bool { self.lifetimes == other.lifetimes && self.unsafety == other.unsafety && self.abi == other.abi && self.inputs == other.inputs diff --git a/src/gen/fold.rs b/src/gen/fold.rs index e814ebe1f9..e515dbcef0 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -74,7 +74,7 @@ pub trait Fold { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn fold_bare_fn_arg(&mut self, i: crate::BareFnArg) -> crate::BareFnArg { + fn fold_bare_fn_arg(&mut self, i: crate::FnPtrArg) -> crate::FnPtrArg { fold_bare_fn_arg(self, i) } #[cfg(any(feature = "derive", feature = "full"))] @@ -879,7 +879,7 @@ pub trait Fold { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn fold_type_bare_fn(&mut self, i: crate::TypeBareFn) -> crate::TypeBareFn { + fn fold_type_bare_fn(&mut self, i: crate::TypeFnPtr) -> crate::TypeFnPtr { fold_type_bare_fn(self, i) } #[cfg(any(feature = "derive", feature = "full"))] @@ -1121,11 +1121,11 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn fold_bare_fn_arg(f: &mut F, node: crate::BareFnArg) -> crate::BareFnArg +pub fn fold_bare_fn_arg(f: &mut F, node: crate::FnPtrArg) -> crate::FnPtrArg where F: Fold + ?Sized, { - crate::BareFnArg { + crate::FnPtrArg { attrs: f.fold_attributes(node.attrs), name: (node.name).map(|it| (f.fold_ident((it).0), (it).1)), ty: f.fold_type(node.ty), @@ -3522,11 +3522,11 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn fold_type_bare_fn(f: &mut F, node: crate::TypeBareFn) -> crate::TypeBareFn +pub fn fold_type_bare_fn(f: &mut F, node: crate::TypeFnPtr) -> crate::TypeFnPtr where F: Fold + ?Sized, { - crate::TypeBareFn { + crate::TypeFnPtr { lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), unsafety: node.unsafety, abi: (node.abi).map(|it| f.fold_abi(it)), diff --git a/src/gen/hash.rs b/src/gen/hash.rs index 936a0e6bb7..e1fbf1fafd 100644 --- a/src/gen/hash.rs +++ b/src/gen/hash.rs @@ -95,7 +95,7 @@ impl Hash for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Hash for crate::BareFnArg { +impl Hash for crate::FnPtrArg { fn hash(&self, state: &mut H) where H: Hasher, @@ -2509,7 +2509,7 @@ impl Hash for crate::TypeArray { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Hash for crate::TypeBareFn { +impl Hash for crate::TypeFnPtr { fn hash(&self, state: &mut H) where H: Hasher, diff --git a/src/gen/visit.rs b/src/gen/visit.rs index 9436295358..14e9266b22 100644 --- a/src/gen/visit.rs +++ b/src/gen/visit.rs @@ -66,7 +66,7 @@ pub trait Visit<'ast> { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_bare_fn_arg(&mut self, i: &'ast crate::BareFnArg) { + fn visit_bare_fn_arg(&mut self, i: &'ast crate::FnPtrArg) { visit_bare_fn_arg(self, i); } #[cfg(any(feature = "derive", feature = "full"))] @@ -804,7 +804,7 @@ pub trait Visit<'ast> { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_type_bare_fn(&mut self, i: &'ast crate::TypeBareFn) { + fn visit_type_bare_fn(&mut self, i: &'ast crate::TypeFnPtr) { visit_type_bare_fn(self, i); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1041,7 +1041,7 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_bare_fn_arg<'ast, V>(v: &mut V, node: &'ast crate::BareFnArg) +pub fn visit_bare_fn_arg<'ast, V>(v: &mut V, node: &'ast crate::FnPtrArg) where V: Visit<'ast> + ?Sized, { @@ -3578,7 +3578,7 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_type_bare_fn<'ast, V>(v: &mut V, node: &'ast crate::TypeBareFn) +pub fn visit_type_bare_fn<'ast, V>(v: &mut V, node: &'ast crate::TypeFnPtr) where V: Visit<'ast> + ?Sized, { diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index bcd69935cd..4e51cee86f 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -76,7 +76,7 @@ pub trait VisitMut { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_bare_fn_arg_mut(&mut self, i: &mut crate::BareFnArg) { + fn visit_bare_fn_arg_mut(&mut self, i: &mut crate::FnPtrArg) { visit_bare_fn_arg_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] @@ -814,7 +814,7 @@ pub trait VisitMut { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_type_bare_fn_mut(&mut self, i: &mut crate::TypeBareFn) { + fn visit_type_bare_fn_mut(&mut self, i: &mut crate::TypeFnPtr) { visit_type_bare_fn_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1049,7 +1049,7 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_bare_fn_arg_mut(v: &mut V, node: &mut crate::BareFnArg) +pub fn visit_bare_fn_arg_mut(v: &mut V, node: &mut crate::FnPtrArg) where V: VisitMut + ?Sized, { @@ -3404,7 +3404,7 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_type_bare_fn_mut(v: &mut V, node: &mut crate::TypeBareFn) +pub fn visit_type_bare_fn_mut(v: &mut V, node: &mut crate::TypeFnPtr) where V: VisitMut + ?Sized, { diff --git a/src/lib.rs b/src/lib.rs index 578013faec..15e80be8f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -541,7 +541,7 @@ mod ty; #[cfg(any(feature = "full", feature = "derive"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::ty::{ - Abi, BareFnArg, BareVariadic, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup, + Abi, FnPtrArg, BareVariadic, ReturnType, Type, TypeArray, TypeFnPtr, TypeGroup, TypeImplTrait, TypeInfer, TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, TypeSlice, TypeTraitObject, TypeTuple, }; diff --git a/src/ty.rs b/src/ty.rs index 622c82f5cb..ba5249e4b2 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -27,7 +27,7 @@ ast_enum_of_structs! { Array(TypeArray), /// A function pointer type: `fn(usize) -> bool`. - FnPtr(TypeBareFn), + FnPtr(TypeFnPtr), /// A type contained within invisible delimiters. Group(TypeGroup), @@ -103,15 +103,15 @@ ast_struct! { } ast_struct! { - /// A bare function type: `fn(usize) -> bool`. + /// A function pointer type: `fn(usize) -> bool`. #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct TypeBareFn { + pub struct TypeFnPtr { pub lifetimes: Option, pub unsafety: Option, pub abi: Option, pub fn_token: Token![fn], pub paren_token: token::Paren, - pub inputs: Punctuated, + pub inputs: Punctuated, pub variadic: Option, pub output: ReturnType, } @@ -241,7 +241,7 @@ ast_struct! { ast_struct! { /// An argument in a function type: the `usize` in `fn(usize) -> bool`. #[cfg_attr(docsrs, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct BareFnArg { + pub struct FnPtrArg { pub attrs: Vec, pub name: Option<(Ident, Token![:])>, pub ty: Type, @@ -287,7 +287,7 @@ pub(crate) mod parsing { use crate::punctuated::Punctuated; use crate::token; use crate::ty::{ - Abi, BareFnArg, BareVariadic, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup, + Abi, FnPtrArg, BareVariadic, ReturnType, Type, TypeArray, TypeFnPtr, TypeGroup, TypeImplTrait, TypeInfer, TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, TypeSlice, TypeTraitObject, TypeTuple, }; @@ -505,7 +505,7 @@ pub(crate) mod parsing { || lookahead.peek(Token![unsafe]) || lookahead.peek(Token![extern]) { - let mut bare_fn: TypeBareFn = input.parse()?; + let mut bare_fn: TypeFnPtr = input.parse()?; bare_fn.lifetimes = lifetimes; Ok(Type::FnPtr(bare_fn)) } else if lookahead.peek(Ident) @@ -675,12 +675,12 @@ pub(crate) mod parsing { } #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))] - impl Parse for TypeBareFn { + impl Parse for TypeFnPtr { fn parse(input: ParseStream) -> Result { let args; let mut variadic = None; - Ok(TypeBareFn { + Ok(TypeFnPtr { lifetimes: input.parse()?, unsafety: input.parse()?, abi: input.parse()?, @@ -704,7 +704,7 @@ pub(crate) mod parsing { let allow_self = inputs.is_empty(); let arg = parse_bare_fn_arg(&args, allow_self)?; - inputs.push_value(BareFnArg { attrs, ..arg }); + inputs.push_value(FnPtrArg { attrs, ..arg }); if args.is_empty() { break; } @@ -980,14 +980,14 @@ pub(crate) mod parsing { } #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))] - impl Parse for BareFnArg { + impl Parse for FnPtrArg { fn parse(input: ParseStream) -> Result { let allow_self = false; parse_bare_fn_arg(input, allow_self) } } - fn parse_bare_fn_arg(input: ParseStream, allow_self: bool) -> Result { + fn parse_bare_fn_arg(input: ParseStream, allow_self: bool) -> Result { let attrs = input.call(Attribute::parse_outer)?; let begin = input.fork(); @@ -1032,7 +1032,7 @@ pub(crate) mod parsing { } }; - Ok(BareFnArg { attrs, name, ty }) + Ok(FnPtrArg { attrs, name, ty }) } fn parse_bare_variadic(input: ParseStream, attrs: Vec) -> Result { @@ -1079,7 +1079,7 @@ mod printing { use crate::path::printing::PathStyle; use crate::print::TokensOrDefault; use crate::ty::{ - Abi, BareFnArg, BareVariadic, ReturnType, TypeArray, TypeBareFn, TypeGroup, TypeImplTrait, + Abi, FnPtrArg, BareVariadic, ReturnType, TypeArray, TypeFnPtr, TypeGroup, TypeImplTrait, TypeInfer, TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, TypeSlice, TypeTraitObject, TypeTuple, }; @@ -1131,7 +1131,7 @@ mod printing { } #[cfg_attr(docsrs, doc(cfg(feature = "printing")))] - impl ToTokens for TypeBareFn { + impl ToTokens for TypeFnPtr { fn to_tokens(&self, tokens: &mut TokenStream) { self.lifetimes.to_tokens(tokens); self.unsafety.to_tokens(tokens); @@ -1241,7 +1241,7 @@ mod printing { } #[cfg_attr(docsrs, doc(cfg(feature = "printing")))] - impl ToTokens for BareFnArg { + impl ToTokens for FnPtrArg { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); if let Some((name, colon)) = &self.name { diff --git a/syn.json b/syn.json index 7286808092..d0c77b3093 100644 --- a/syn.json +++ b/syn.json @@ -186,7 +186,7 @@ } }, { - "ident": "BareFnArg", + "ident": "FnPtrArg", "features": { "any": [ "derive", @@ -4902,7 +4902,7 @@ } }, { - "ident": "TypeBareFn", + "ident": "TypeFnPtr", "features": { "any": [ "derive", @@ -4934,7 +4934,7 @@ "inputs": { "punctuated": { "element": { - "syn": "BareFnArg" + "syn": "FnPtrArg" }, "punct": "Comma" } diff --git a/tests/debug/gen.rs b/tests/debug/gen.rs index 3d41f7f906..0abc7cab3c 100644 --- a/tests/debug/gen.rs +++ b/tests/debug/gen.rs @@ -129,9 +129,9 @@ impl Debug for Lite { formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("BareFnArg"); + let mut formatter = formatter.debug_struct("FnPtrArg"); if !self.value.attrs.is_empty() { formatter.field("attrs", Lite(&self.value.attrs)); } @@ -4280,9 +4280,9 @@ impl Debug for Lite { formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeBareFn"); + let mut formatter = formatter.debug_struct("TypeFnPtr"); if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] From c878aea9e090647aa0670006233739bb2d3e8b23 Mon Sep 17 00:00:00 2001 From: Jose Torres Date: Sun, 15 Feb 2026 16:56:15 -0500 Subject: [PATCH 3/3] codegen --- src/gen/clone.rs | 22 ++++++++-------- src/gen/debug.rs | 22 ++++++++-------- src/gen/eq.rs | 20 +++++++------- src/gen/fold.rs | 44 +++++++++++++++---------------- src/gen/hash.rs | 24 ++++++++--------- src/gen/visit.rs | 50 +++++++++++++++++------------------ src/gen/visit_mut.rs | 46 ++++++++++++++++---------------- syn.json | 62 ++++++++++++++++++++++---------------------- tests/debug/gen.rs | 48 +++++++++++++++++----------------- 9 files changed, 169 insertions(+), 169 deletions(-) diff --git a/src/gen/clone.rs b/src/gen/clone.rs index 82a94bc7ca..5ac9085d41 100644 --- a/src/gen/clone.rs +++ b/src/gen/clone.rs @@ -86,17 +86,6 @@ impl Clone for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "clone-impls")))] -impl Clone for crate::FnPtrArg { - fn clone(&self) -> Self { - crate::FnPtrArg { - attrs: self.attrs.clone(), - name: self.name.clone(), - ty: self.ty.clone(), - } - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(feature = "clone-impls")))] impl Clone for crate::BareVariadic { fn clone(&self) -> Self { crate::BareVariadic { @@ -877,6 +866,17 @@ impl Clone for crate::FnArg { } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(feature = "clone-impls")))] +impl Clone for crate::FnPtrArg { + fn clone(&self) -> Self { + crate::FnPtrArg { + attrs: self.attrs.clone(), + name: self.name.clone(), + ty: self.ty.clone(), + } + } +} #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "clone-impls")))] impl Clone for crate::ForeignItem { diff --git a/src/gen/debug.rs b/src/gen/debug.rs index fc1c0942cd..669c8d6baa 100644 --- a/src/gen/debug.rs +++ b/src/gen/debug.rs @@ -98,17 +98,6 @@ impl Debug for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Debug for crate::FnPtrArg { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("FnPtrArg"); - formatter.field("attrs", &self.attrs); - formatter.field("name", &self.name); - formatter.field("ty", &self.ty); - formatter.finish() - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Debug for crate::BareVariadic { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("BareVariadic"); @@ -1316,6 +1305,17 @@ impl Debug for crate::FnArg { } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] +impl Debug for crate::FnPtrArg { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("FnPtrArg"); + formatter.field("attrs", &self.attrs); + formatter.field("name", &self.name); + formatter.field("ty", &self.ty); + formatter.finish() + } +} #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Debug for crate::ForeignItem { diff --git a/src/gen/eq.rs b/src/gen/eq.rs index 4b40102ca1..4d002e587e 100644 --- a/src/gen/eq.rs +++ b/src/gen/eq.rs @@ -84,16 +84,6 @@ impl PartialEq for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Eq for crate::FnPtrArg {} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl PartialEq for crate::FnPtrArg { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.name == other.name && self.ty == other.ty - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Eq for crate::BareVariadic {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] @@ -872,6 +862,16 @@ impl PartialEq for crate::FnArg { } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] +impl Eq for crate::FnPtrArg {} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] +impl PartialEq for crate::FnPtrArg { + fn eq(&self, other: &Self) -> bool { + self.attrs == other.attrs && self.name == other.name && self.ty == other.ty + } +} #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Eq for crate::ForeignItem {} diff --git a/src/gen/fold.rs b/src/gen/fold.rs index e515dbcef0..04a1bef6b0 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -74,11 +74,6 @@ pub trait Fold { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn fold_bare_fn_arg(&mut self, i: crate::FnPtrArg) -> crate::FnPtrArg { - fold_bare_fn_arg(self, i) - } - #[cfg(any(feature = "derive", feature = "full"))] - #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_bare_variadic(&mut self, i: crate::BareVariadic) -> crate::BareVariadic { fold_bare_variadic(self, i) } @@ -391,6 +386,11 @@ pub trait Fold { fn fold_fn_arg(&mut self, i: crate::FnArg) -> crate::FnArg { fold_fn_arg(self, i) } + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] + fn fold_fn_ptr_arg(&mut self, i: crate::FnPtrArg) -> crate::FnPtrArg { + fold_fn_ptr_arg(self, i) + } #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "full")))] fn fold_foreign_item(&mut self, i: crate::ForeignItem) -> crate::ForeignItem { @@ -879,8 +879,8 @@ pub trait Fold { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn fold_type_bare_fn(&mut self, i: crate::TypeFnPtr) -> crate::TypeFnPtr { - fold_type_bare_fn(self, i) + fn fold_type_fn_ptr(&mut self, i: crate::TypeFnPtr) -> crate::TypeFnPtr { + fold_type_fn_ptr(self, i) } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] @@ -1121,18 +1121,6 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn fold_bare_fn_arg(f: &mut F, node: crate::FnPtrArg) -> crate::FnPtrArg -where - F: Fold + ?Sized, -{ - crate::FnPtrArg { - attrs: f.fold_attributes(node.attrs), - name: (node.name).map(|it| (f.fold_ident((it).0), (it).1)), - ty: f.fold_type(node.ty), - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_bare_variadic(f: &mut F, node: crate::BareVariadic) -> crate::BareVariadic where F: Fold + ?Sized, @@ -2081,6 +2069,18 @@ where } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] +pub fn fold_fn_ptr_arg(f: &mut F, node: crate::FnPtrArg) -> crate::FnPtrArg +where + F: Fold + ?Sized, +{ + crate::FnPtrArg { + attrs: f.fold_attributes(node.attrs), + name: (node.name).map(|it| (f.fold_ident((it).0), (it).1)), + ty: f.fold_type(node.ty), + } +} #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "full")))] pub fn fold_foreign_item(f: &mut F, node: crate::ForeignItem) -> crate::ForeignItem @@ -3468,7 +3468,7 @@ where crate::Type::Array(f.fold_type_array(_binding_0)) } crate::Type::FnPtr(_binding_0) => { - crate::Type::FnPtr(f.fold_type_bare_fn(_binding_0)) + crate::Type::FnPtr(f.fold_type_fn_ptr(_binding_0)) } crate::Type::Group(_binding_0) => { crate::Type::Group(f.fold_type_group(_binding_0)) @@ -3522,7 +3522,7 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn fold_type_bare_fn(f: &mut F, node: crate::TypeFnPtr) -> crate::TypeFnPtr +pub fn fold_type_fn_ptr(f: &mut F, node: crate::TypeFnPtr) -> crate::TypeFnPtr where F: Fold + ?Sized, { @@ -3532,7 +3532,7 @@ where abi: (node.abi).map(|it| f.fold_abi(it)), fn_token: node.fn_token, paren_token: node.paren_token, - inputs: crate::punctuated::fold(node.inputs, f, F::fold_bare_fn_arg), + inputs: crate::punctuated::fold(node.inputs, f, F::fold_fn_ptr_arg), variadic: (node.variadic).map(|it| f.fold_bare_variadic(it)), output: f.fold_return_type(node.output), } diff --git a/src/gen/hash.rs b/src/gen/hash.rs index e1fbf1fafd..9458d647fc 100644 --- a/src/gen/hash.rs +++ b/src/gen/hash.rs @@ -95,18 +95,6 @@ impl Hash for crate::Attribute { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] -impl Hash for crate::FnPtrArg { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.name.hash(state); - self.ty.hash(state); - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Hash for crate::BareVariadic { fn hash(&self, state: &mut H) where @@ -1139,6 +1127,18 @@ impl Hash for crate::FnArg { } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] +impl Hash for crate::FnPtrArg { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + self.attrs.hash(state); + self.name.hash(state); + self.ty.hash(state); + } +} #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Hash for crate::ForeignItem { diff --git a/src/gen/visit.rs b/src/gen/visit.rs index 14e9266b22..7d7b255d81 100644 --- a/src/gen/visit.rs +++ b/src/gen/visit.rs @@ -66,11 +66,6 @@ pub trait Visit<'ast> { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_bare_fn_arg(&mut self, i: &'ast crate::FnPtrArg) { - visit_bare_fn_arg(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] - #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bare_variadic(&mut self, i: &'ast crate::BareVariadic) { visit_bare_variadic(self, i); } @@ -374,6 +369,11 @@ pub trait Visit<'ast> { fn visit_fn_arg(&mut self, i: &'ast crate::FnArg) { visit_fn_arg(self, i); } + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] + fn visit_fn_ptr_arg(&mut self, i: &'ast crate::FnPtrArg) { + visit_fn_ptr_arg(self, i); + } #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "full")))] fn visit_foreign_item(&mut self, i: &'ast crate::ForeignItem) { @@ -804,8 +804,8 @@ pub trait Visit<'ast> { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_type_bare_fn(&mut self, i: &'ast crate::TypeFnPtr) { - visit_type_bare_fn(self, i); + fn visit_type_fn_ptr(&mut self, i: &'ast crate::TypeFnPtr) { + visit_type_fn_ptr(self, i); } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] @@ -1041,21 +1041,6 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_bare_fn_arg<'ast, V>(v: &mut V, node: &'ast crate::FnPtrArg) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - if let Some(it) = &node.name { - v.visit_ident(&(it).0); - skip!((it).1); - } - v.visit_type(&node.ty); -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bare_variadic<'ast, V>(v: &mut V, node: &'ast crate::BareVariadic) where V: Visit<'ast> + ?Sized, @@ -2116,6 +2101,21 @@ where } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] +pub fn visit_fn_ptr_arg<'ast, V>(v: &mut V, node: &'ast crate::FnPtrArg) +where + V: Visit<'ast> + ?Sized, +{ + for it in &node.attrs { + v.visit_attribute(it); + } + if let Some(it) = &node.name { + v.visit_ident(&(it).0); + skip!((it).1); + } + v.visit_type(&node.ty); +} #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "full")))] pub fn visit_foreign_item<'ast, V>(v: &mut V, node: &'ast crate::ForeignItem) @@ -3522,7 +3522,7 @@ where v.visit_type_array(_binding_0); } crate::Type::FnPtr(_binding_0) => { - v.visit_type_bare_fn(_binding_0); + v.visit_type_fn_ptr(_binding_0); } crate::Type::Group(_binding_0) => { v.visit_type_group(_binding_0); @@ -3578,7 +3578,7 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_type_bare_fn<'ast, V>(v: &mut V, node: &'ast crate::TypeFnPtr) +pub fn visit_type_fn_ptr<'ast, V>(v: &mut V, node: &'ast crate::TypeFnPtr) where V: Visit<'ast> + ?Sized, { @@ -3593,7 +3593,7 @@ where skip!(node.paren_token); for el in Punctuated::pairs(&node.inputs) { let it = el.value(); - v.visit_bare_fn_arg(it); + v.visit_fn_ptr_arg(it); } if let Some(it) = &node.variadic { v.visit_bare_variadic(it); diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index 4e51cee86f..72552804b5 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -76,11 +76,6 @@ pub trait VisitMut { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_bare_fn_arg_mut(&mut self, i: &mut crate::FnPtrArg) { - visit_bare_fn_arg_mut(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] - #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bare_variadic_mut(&mut self, i: &mut crate::BareVariadic) { visit_bare_variadic_mut(self, i); } @@ -384,6 +379,11 @@ pub trait VisitMut { fn visit_fn_arg_mut(&mut self, i: &mut crate::FnArg) { visit_fn_arg_mut(self, i); } + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] + fn visit_fn_ptr_arg_mut(&mut self, i: &mut crate::FnPtrArg) { + visit_fn_ptr_arg_mut(self, i); + } #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "full")))] fn visit_foreign_item_mut(&mut self, i: &mut crate::ForeignItem) { @@ -814,8 +814,8 @@ pub trait VisitMut { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] - fn visit_type_bare_fn_mut(&mut self, i: &mut crate::TypeFnPtr) { - visit_type_bare_fn_mut(self, i); + fn visit_type_fn_ptr_mut(&mut self, i: &mut crate::TypeFnPtr) { + visit_type_fn_ptr_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] @@ -1049,19 +1049,6 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_bare_fn_arg_mut(v: &mut V, node: &mut crate::FnPtrArg) -where - V: VisitMut + ?Sized, -{ - v.visit_attributes_mut(&mut node.attrs); - if let Some(it) = &mut node.name { - v.visit_ident_mut(&mut (it).0); - skip!((it).1); - } - v.visit_type_mut(&mut node.ty); -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bare_variadic_mut(v: &mut V, node: &mut crate::BareVariadic) where V: VisitMut + ?Sized, @@ -2030,6 +2017,19 @@ where } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] +pub fn visit_fn_ptr_arg_mut(v: &mut V, node: &mut crate::FnPtrArg) +where + V: VisitMut + ?Sized, +{ + v.visit_attributes_mut(&mut node.attrs); + if let Some(it) = &mut node.name { + v.visit_ident_mut(&mut (it).0); + skip!((it).1); + } + v.visit_type_mut(&mut node.ty); +} #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "full")))] pub fn visit_foreign_item_mut(v: &mut V, node: &mut crate::ForeignItem) @@ -3348,7 +3348,7 @@ where v.visit_type_array_mut(_binding_0); } crate::Type::FnPtr(_binding_0) => { - v.visit_type_bare_fn_mut(_binding_0); + v.visit_type_fn_ptr_mut(_binding_0); } crate::Type::Group(_binding_0) => { v.visit_type_group_mut(_binding_0); @@ -3404,7 +3404,7 @@ where } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] -pub fn visit_type_bare_fn_mut(v: &mut V, node: &mut crate::TypeFnPtr) +pub fn visit_type_fn_ptr_mut(v: &mut V, node: &mut crate::TypeFnPtr) where V: VisitMut + ?Sized, { @@ -3419,7 +3419,7 @@ where skip!(node.paren_token); for mut el in Punctuated::pairs_mut(&mut node.inputs) { let it = el.value_mut(); - v.visit_bare_fn_arg_mut(it); + v.visit_fn_ptr_arg_mut(it); } if let Some(it) = &mut node.variadic { v.visit_bare_variadic_mut(it); diff --git a/syn.json b/syn.json index d0c77b3093..6084e0a199 100644 --- a/syn.json +++ b/syn.json @@ -185,37 +185,6 @@ } } }, - { - "ident": "FnPtrArg", - "features": { - "any": [ - "derive", - "full" - ] - }, - "fields": { - "attrs": { - "vec": { - "syn": "Attribute" - } - }, - "name": { - "option": { - "tuple": [ - { - "proc_macro2": "Ident" - }, - { - "token": "Colon" - } - ] - } - }, - "ty": { - "syn": "Type" - } - } - }, { "ident": "BareVariadic", "features": { @@ -2192,6 +2161,37 @@ ] } }, + { + "ident": "FnPtrArg", + "features": { + "any": [ + "derive", + "full" + ] + }, + "fields": { + "attrs": { + "vec": { + "syn": "Attribute" + } + }, + "name": { + "option": { + "tuple": [ + { + "proc_macro2": "Ident" + }, + { + "token": "Colon" + } + ] + } + }, + "ty": { + "syn": "Type" + } + } + }, { "ident": "ForeignItem", "features": { diff --git a/tests/debug/gen.rs b/tests/debug/gen.rs index 0abc7cab3c..90ca03ed17 100644 --- a/tests/debug/gen.rs +++ b/tests/debug/gen.rs @@ -129,30 +129,6 @@ impl Debug for Lite { formatter.finish() } } -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("FnPtrArg"); - if !self.value.attrs.is_empty() { - formatter.field("attrs", Lite(&self.value.attrs)); - } - if let Some(val) = &self.value.name { - #[derive(RefCast)] - #[repr(transparent)] - struct Print((proc_macro2::Ident, syn::token::Colon)); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some(")?; - Debug::fmt(Lite(&self.0.0), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - formatter.field("name", Print::ref_cast(val)); - } - formatter.field("ty", Lite(&self.value.ty)); - formatter.finish() - } -} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("BareVariadic"); @@ -1901,6 +1877,30 @@ impl Debug for Lite { } } } +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("FnPtrArg"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.name { + #[derive(RefCast)] + #[repr(transparent)] + struct Print((proc_macro2::Ident, syn::token::Colon)); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("name", Print::ref_cast(val)); + } + formatter.field("ty", Lite(&self.value.ty)); + formatter.finish() + } +} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { match &self.value {