Clippy arc_with_non_send_sync (seems unjustified)

⚓ Rust    📅 2025-12-11    👤 surdeus    👁️ 3      

surdeus

Hello,

I have a clippy warning that is enabled and unfortunately I am unable to understand it.

I have a trait:

pub trait ValueChangeCallback {
    fn on_value_changed(&self, name: &str, value: &Variant);
}

I have another struct:

struct ValueChangeCallbackManager<'a> {
    callbacks: RwLock<HashMap<String, Box<dyn ValueChangeCallback + 'a + Send>>>,
}

I also have another struct:

pub struct Proxy<'a> {
    callbacks_member_change: Arc<ValueChangeCallbackManager<'a>>,
}

Bu, in RustRover on the line where I instanciate the Proxy structure:

let mut proxy = Proxy {
            callbacks_member_change: Arc::new(RwLock::new(ValueChangeCallbackManager::new())),
};

I get:

usage of an `Arc` that is not `Send` and `Sync`
Note: `Arc<ValueChangeCallbackManager<'_>>` is not `Send` and `Sync` as `ValueChangeCallbackManager<'_>` is not `Sync`
Help: if the `Arc` will not be used across threads replace it with an `Rc`
Help: otherwise make `ValueChangeCallbackManager<'_>` `Send` and `Sync` or consider a wrapper type such as `Mutex`
Help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#arc_with_non_send_sync
Note: `-D clippy::arc-with-non-send-sync` implied by `-D warnings`
Help: to override `-D warnings` add `#[allow(clippy::arc_with_non_send_sync)]`

What is the problem with my code ?

Thank you very much in advance for any help

7 posts - 4 participants

Read full topic

🏷️ Rust_feed