Special case for Visibility's naming convention
diff --git a/codegen/src/debug.rs b/codegen/src/debug.rs
index 7795496..0cda534 100644
--- a/codegen/src/debug.rs
+++ b/codegen/src/debug.rs
@@ -120,6 +120,10 @@
if fields.len() != 1 {
return None;
}
+ let mut outer = outer;
+ if outer == "Visibility" {
+ outer = "Vis";
+ }
match &fields[0] {
Type::Syn(ty) if outer.to_owned() + inner == *ty => Some(ty),
_ => None
diff --git a/tests/debug/gen.rs b/tests/debug/gen.rs
index d9aeee7..05a5f70 100644
--- a/tests/debug/gen.rs
+++ b/tests/debug/gen.rs
@@ -5786,19 +5786,29 @@
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let _val = &self.value;
match _val {
- syn::Visibility::Public(_v0) => {
- let mut formatter = formatter.debug_tuple("Public");
- formatter.field(Lite(_v0));
+ syn::Visibility::Public(_val) => {
+ let mut formatter = formatter.debug_struct("Visibility::Public");
formatter.finish()
}
- syn::Visibility::Crate(_v0) => {
- let mut formatter = formatter.debug_tuple("Crate");
- formatter.field(Lite(_v0));
+ syn::Visibility::Crate(_val) => {
+ let mut formatter = formatter.debug_struct("Visibility::Crate");
formatter.finish()
}
- syn::Visibility::Restricted(_v0) => {
- let mut formatter = formatter.debug_tuple("Restricted");
- formatter.field(Lite(_v0));
+ syn::Visibility::Restricted(_val) => {
+ let mut formatter = formatter.debug_struct("Visibility::Restricted");
+ if let Some(val) = &_val.in_token {
+ #[derive(RefCast)]
+ #[repr(transparent)]
+ struct Print(syn::token::In);
+ impl Debug for Print {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ formatter.write_str("Some")?;
+ Ok(())
+ }
+ }
+ formatter.field("in_token", Print::ref_cast(val));
+ }
+ formatter.field("path", Lite(&_val.path));
formatter.finish()
}
syn::Visibility::Inherited => formatter.write_str("Inherited"),
diff --git a/tests/test_derive_input.rs b/tests/test_derive_input.rs
index bf4440b..ef7d2c1 100644
--- a/tests/test_derive_input.rs
+++ b/tests/test_derive_input.rs
@@ -55,18 +55,14 @@
⋮ tts: `( Debug , Clone )`,
⋮ },
⋮ ],
- ⋮ vis: Public(
- ⋮ VisPublic,
- ⋮ ),
+ ⋮ vis: Visibility::Public,
⋮ ident: "Item",
⋮ generics: Generics,
⋮ data: Data::Struct {
⋮ fields: Fields::Named {
⋮ named: [
⋮ Field {
- ⋮ vis: Public(
- ⋮ VisPublic,
- ⋮ ),
+ ⋮ vis: Visibility::Public,
⋮ ident: Some("ident"),
⋮ colon_token: Some,
⋮ ty: Type::Path {
@@ -81,9 +77,7 @@
⋮ },
⋮ },
⋮ Field {
- ⋮ vis: Public(
- ⋮ VisPublic,
- ⋮ ),
+ ⋮ vis: Visibility::Public,
⋮ ident: Some("attrs"),
⋮ colon_token: Some,
⋮ ty: Type::Path {