From b9f60ee160829f299aba41c7b86b9ccae539614a Mon Sep 17 00:00:00 2001 From: Xenira <1288524+Xenira@users.noreply.github.com> Date: Mon, 14 Jul 2025 19:44:13 +0200 Subject: [PATCH] chore(stubs): revert breaking change in RustClosure stubs This reverts commit 31c9d9968662e66df7933a824a2f712b8937f187. --- src/args.rs | 1 - src/describe/mod.rs | 69 +++++--------------------------------------- src/describe/stub.rs | 4 --- 3 files changed, 7 insertions(+), 67 deletions(-) diff --git a/src/args.rs b/src/args.rs index b6bebb5ff1..187e6fbade 100644 --- a/src/args.rs +++ b/src/args.rs @@ -203,7 +203,6 @@ impl From> for Parameter { name: val.name.into(), ty: Some(val.r#type).into(), nullable: val.allow_null, - variadic: val.variadic, default: val.default_value.map(abi::RString::from).into(), } } diff --git a/src/describe/mod.rs b/src/describe/mod.rs index fe22acd9bb..8abf2592e1 100644 --- a/src/describe/mod.rs +++ b/src/describe/mod.rs @@ -76,17 +76,6 @@ pub struct Module { impl From> for Module { fn from(builder: ModuleBuilder) -> Self { let functions = builder.functions; - - #[allow(unused_mut)] - let mut classes = builder - .classes - .into_iter() - .map(|c| c().into()) - .collect::>(); - - #[cfg(feature = "closure")] - classes.push(Class::closure()); - Self { name: builder.name.into(), functions: functions @@ -94,7 +83,12 @@ impl From> for Module { .map(Function::from) .collect::>() .into(), - classes: classes.into(), + classes: builder + .classes + .into_iter() + .map(|c| c().into()) + .collect::>() + .into(), constants: builder .constants .into_iter() @@ -157,8 +151,6 @@ pub struct Parameter { pub ty: Option, /// Whether the parameter is nullable. pub nullable: bool, - /// Whether the parameter is variadic. - pub variadic: bool, /// Default value of the parameter. pub default: Option, } @@ -183,43 +175,6 @@ pub struct Class { pub constants: Vec, } -#[cfg(feature = "closure")] -impl Class { - /// Creates a new class representing a Rust closure used for generating - /// the stubs if the `closure` feature is enabled. - #[must_use] - pub fn closure() -> Self { - Self { - name: "RustClosure".into(), - docs: DocBlock(StdVec::new().into()), - extends: Option::None, - implements: StdVec::new().into(), - properties: StdVec::new().into(), - methods: vec![Method { - name: "__invoke".into(), - docs: DocBlock(StdVec::new().into()), - ty: MethodType::Member, - params: vec![Parameter { - name: "args".into(), - ty: Option::Some(DataType::Mixed), - nullable: false, - variadic: true, - default: Option::None, - }] - .into(), - retval: Option::Some(Retval { - ty: DataType::Mixed, - nullable: false, - }), - r#static: false, - visibility: Visibility::Public, - }] - .into(), - constants: StdVec::new().into(), - } - } -} - impl From for Class { fn from(val: ClassBuilder) -> Self { Self { @@ -471,8 +426,6 @@ impl From<(String, Box, DocComments)> for Constant { #[cfg(test)] mod tests { #![cfg_attr(windows, feature(abi_vectorcall))] - use cfg_if::cfg_if; - use super::*; use crate::{args::Arg, test::test_function}; @@ -507,13 +460,7 @@ mod tests { let module: Module = builder.into(); assert_eq!(module.name, "test".into()); assert_eq!(module.functions.len(), 1); - cfg_if! { - if #[cfg(feature = "closure")] { - assert_eq!(module.classes.len(), 1); - } else { - assert_eq!(module.classes.len(), 0); - } - } + assert_eq!(module.classes.len(), 0); assert_eq!(module.constants.len(), 0); } @@ -532,7 +479,6 @@ mod tests { name: "foo".into(), ty: Option::Some(DataType::Long), nullable: false, - variadic: false, default: Option::None, }] .into() @@ -622,7 +568,6 @@ mod tests { name: "foo".into(), ty: Option::Some(DataType::Long), nullable: false, - variadic: false, default: Option::None, }] .into() diff --git a/src/describe/stub.rs b/src/describe/stub.rs index d0bff00d9b..58c7428743 100644 --- a/src/describe/stub.rs +++ b/src/describe/stub.rs @@ -154,10 +154,6 @@ impl ToStub for Parameter { write!(buf, " ")?; } - if self.variadic { - write!(buf, "...")?; - } - write!(buf, "${}", self.name) } }