Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arc_with_non_send_sync could indicate why inner type needs to become Send + Sync #12608

Open
hfiguiere opened this issue Apr 1, 2024 · 1 comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@hfiguiere
Copy link

Description

warning: usage of an `Arc` that is not `Send` and `Sync`

    = note: `Arc<NiepceApplication>` is not `Send` and `Sync` as:
    = note: - the trait `Send` is not implemented for `NiepceApplication`
    = note: - the trait `Sync` is not implemented for `NiepceApplication`
    = help: consider using an `Rc` instead. `Arc` does not provide benefits for non `Send` and `Sync` types
    = note: if you intend to use `Arc` with `Send` and `Sync` traits
    = note: wrap the inner type with a `Mutex` or implement `Send` and `Sync` for `NiepceApplication`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync

The suggestion of using Rc is unhelpful because the intent is really to have Arc.

What would be great is diagnostic info telling me why it isn't Send + Sync by recursively telling me which inner type isn't, and why.

Version

rustc 1.77.1 (7cf61ebde 2024-03-27)
binary: rustc
commit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97
commit-date: 2024-03-27
host: x86_64-unknown-linux-gnu
release: 1.77.1
LLVM version: 17.0.6

Additional Labels

No response

@sdroege
Copy link

sdroege commented Apr 1, 2024

Related to this is rust-av/dav1d-rs#95. Here the type around the Arc is implementing Send+Sync, and blindly applying clippy's suggestion (instead of ignoring it or implementing it on the inner type) would be unsound.

@J-ZhengLi J-ZhengLi added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Apr 3, 2024
bors added a commit that referenced this issue Apr 4, 2024
…rcho

Reword `arc_with_non_send_sync` note and help messages

Addresses #12608 (comment)

Makes the note more concise and reframes the `Rc` suggestion around whether it crosses threads currently due to a manual `Send`/`Sync` impl or may do in the future

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

3 participants