From 2246aada0c0425bcae62024ebf88587f5d7861e4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 05:18:35 +0000 Subject: [PATCH] Remove unused `EldritchFunction` trait and `impl_eldritch_fn!` macro The `EldritchFunction` trait, `call_stub` helper, and `impl_eldritch_fn!` macro in `eldritch-core/src/conversion.rs` were identified as unused code. These constructs appear to be a legacy mechanism for native function binding that has been superseded by the `#[eldritch_library]` macros. The existing code uses `FromValue` and `ToValue` traits directly within generated dispatch logic, rendering these function traits unnecessary. This change removes the dead code to clean up the codebase. --- .../eldritch-core/src/conversion.rs | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/implants/lib/eldritchv2/eldritch-core/src/conversion.rs b/implants/lib/eldritchv2/eldritch-core/src/conversion.rs index f94edbda4..3c50c07e9 100644 --- a/implants/lib/eldritchv2/eldritch-core/src/conversion.rs +++ b/implants/lib/eldritchv2/eldritch-core/src/conversion.rs @@ -205,19 +205,6 @@ where } } -// Function trait and adapter -pub trait EldritchFunction { - fn call(&self, args: &[Value]) -> Result; -} - -// Call stub helper -pub fn call_stub(f: F, args: &[Value]) -> Result -where - F: EldritchFunction, -{ - f.call(args) -} - // Helper to get type name (duplicate from utils but avoids public exposure of utils) fn get_type_name(v: &Value) -> &'static str { match v { @@ -239,45 +226,3 @@ fn get_type_name(v: &Value) -> &'static str { } } -// Macro to implement EldritchFunction for tuples of arguments -macro_rules! impl_eldritch_fn { - ($($arg:ident),*) => { - #[allow(non_snake_case)] - #[allow(unused_mut)] - #[allow(unused_variables)] - impl EldritchFunction<($($arg,)*)> for Func - where - Func: Fn($($arg),*) -> Ret, - Ret: IntoEldritchResult, - $($arg: FromValue),* - { - fn call(&self, args: &[Value]) -> Result { - // Count args - let expected_len = 0 $( + { let _ = stringify!($arg); 1 } )*; - if args.len() != expected_len { - return Err(format!("Expected {} arguments, got {}", expected_len, args.len())); - } - - let mut args_iter = args.iter(); - // We use a closure to capture errors during extraction - let res = self( - $( - match $arg::from_value(args_iter.next().unwrap()) { - Ok(v) => v, - Err(e) => return Err(e), - }, - )* - ); - res.into_eldritch_result() - } - } - } -} - -impl_eldritch_fn!(); -impl_eldritch_fn!(A); -impl_eldritch_fn!(A, B); -impl_eldritch_fn!(A, B, C); -impl_eldritch_fn!(A, B, C, D); -impl_eldritch_fn!(A, B, C, D, E); -impl_eldritch_fn!(A, B, C, D, E, F);