From 69ad1ae4508df95bc73252799dcbb7f1882eec94 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Wed, 21 Oct 2026 14:12:58 -0400 Subject: [PATCH] solidcraft-smlib: the curve list carries nothing in a build without SMLib Without the native feature nothing reads a sweep's curve list, and clippy -D warnings refused its two fields as dead code. The list is built through List::new in both builds; only the native build keeps the slices the C API reads. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017itGh5fpMEousnZ91cYcVt --- crates/smlib/src/ffi/sweeps.rs | 24 ++++++++++++++++++++---- crates/smlib/src/sweeps.rs | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/smlib/src/ffi/sweeps.rs b/crates/smlib/src/ffi/sweeps.rs index d92ad9af0..1d20519db 100644 --- a/crates/smlib/src/ffi/sweeps.rs +++ b/crates/smlib/src/ffi/sweeps.rs @@ -22,11 +22,27 @@ pub const SWEEP_FOLLOW: i32 = 0; pub const SWEEP_TRANSLATE: i32 = 1; /// A curve list as the C API reads it: kinds (with a NURBS curve's degree and point count) and -/// each curve's numbers. Only the calls read them, which a build without SMLib does not have. -#[cfg_attr(not(feature = "native"), allow(dead_code))] +/// each curve's numbers. +#[cfg(feature = "native")] pub struct List<'a> { - pub kinds: &'a [i64], - pub reals: &'a [f64], + kinds: &'a [i64], + reals: &'a [f64], +} + +/// Without SMLib nothing reads the list, so it carries nothing. +#[cfg(not(feature = "native"))] +pub struct List<'a>(std::marker::PhantomData<&'a ()>); + +impl<'a> List<'a> { + #[cfg(feature = "native")] + pub fn new(kinds: &'a [i64], reals: &'a [f64]) -> Self { + List { kinds, reals } + } + + #[cfg(not(feature = "native"))] + pub fn new(_: &'a [i64], _: &'a [f64]) -> Self { + List(std::marker::PhantomData) + } } #[cfg(feature = "native")] diff --git a/crates/smlib/src/sweeps.rs b/crates/smlib/src/sweeps.rs index 01790f337..ae4758765 100644 --- a/crates/smlib/src/sweeps.rs +++ b/crates/smlib/src/sweeps.rs @@ -99,7 +99,7 @@ impl List { } fn raw(&self) -> ffi::sweeps::List<'_> { - ffi::sweeps::List { kinds: &self.kinds, reals: &self.reals } + ffi::sweeps::List::new(&self.kinds, &self.reals) } }