From 7acb82b3e5448fb4dc61bd0ccd62b3dd093343eb Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Wed, 4 Feb 2026 17:56:23 -0800 Subject: [PATCH] Remove unnecessary `Send + Sync` bounds from `Redaction` Follow-up to f680868 ("Don't use `Arc` in `Settings` unnecessarily"). Since `Settings` are stored in thread-local storage and wrapped in `Rc`, they can never cross thread boundaries. The `Send + Sync` bounds on `Redaction::Dynamic` and related functions were vestigial from when `Arc` was used for `DEFAULT_SETTINGS`. This relaxes the API to allow non-`Send` closures in dynamic redactions, which is now safe since those closures can never be sent to another thread. Co-Authored-By: Claude --- .gitignore | 2 +- insta/src/redaction.rs | 4 ++-- insta/src/settings.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6dfcc3af..08410ef4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,4 @@ WORKSPACE.bazel bazel-* # Emacs backups -*~ \ No newline at end of file +*~ diff --git a/insta/src/redaction.rs b/insta/src/redaction.rs index 61c7f67b..6f017aaa 100644 --- a/insta/src/redaction.rs +++ b/insta/src/redaction.rs @@ -54,7 +54,7 @@ pub enum Redaction { /// Static redaction with new content. Static(Content), /// Redaction with new content. - Dynamic(Box) -> Content + Sync + Send>), + Dynamic(Box) -> Content>), } macro_rules! impl_from { @@ -127,7 +127,7 @@ impl<'a> From<&'a [u8]> for Redaction { pub fn dynamic_redaction(func: F) -> Redaction where I: Into, - F: Fn(Content, ContentPath<'_>) -> I + Send + Sync + 'static, + F: Fn(Content, ContentPath<'_>) -> I + 'static, { Redaction::Dynamic(Box::new(move |c, p| func(c, p).into())) } diff --git a/insta/src/settings.rs b/insta/src/settings.rs index eb617c9b..ac82b207 100644 --- a/insta/src/settings.rs +++ b/insta/src/settings.rs @@ -413,7 +413,7 @@ impl Settings { pub fn add_dynamic_redaction(&mut self, selector: &str, func: F) where I: Into, - F: Fn(Content, ContentPath<'_>) -> I + Send + Sync + 'static, + F: Fn(Content, ContentPath<'_>) -> I + 'static, { self.add_redaction(selector, dynamic_redaction(func)); }