-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Mutex<T> should be Share even if T isn't #13125
Comments
In an opt-in kind world, this would probably be an |
There is still an issue if the wrapped type is not safe to access from a different thread than the one it was created on. |
I talked with @nikomatsakis about this on IRC. He thinks that struct Mutex<T> {
lock: RawMutex,
data: Unsafe<T>
}
impl<T: Send> Share for Mutex<T> {} Today's compiler would reject this code because it does not think that |
@eddyb Methods on |
I'll make sure to do this as part of the opt-in |
FWIW, I've updated the RFC to include text about this. |
With the removal of cc @Ms2ger |
@larsbergstrom As mentioned in my previous comment, with few changes The issue is already assigned to me, I'm happy to tackle it asap if needed. |
@flaper87 Thanks! I think the biggest things we're hoping for are:
I appreciate the offer, but don't need to you drop everything you're doing and work on this, especially since it sounds invasive enough that we probably couldn't cherry-pick it and we would like to finish off this Rust upgrade before we start in on yet another. |
@larsbergstrom if you can pay for an extra allocation, I've worked around this issue for now by representing an |
@sfackler Thanks! That seems totally reasonable. We'll just have to make sure to clean it up when the fix lands, which we don't always do :-/ |
This patch adds a special rule for `Unsafe<T>` and makes it `Share` regardless of whether T is `Share`. [breaking-change] Closes rust-lang#13125
This patch adds a special rule for `Unsafe<T>` and makes it `Share` regardless of whether T is `Share`. [breaking-change] Closes #13125 cc @nikomatsakis
Changelog for Clippy 1.80 🌞 Roses are red, Violets are blue, Summer is fun, So much sun --- ### The cat of this release is *Maunzer* submitted by `@llogiq:` <img height=500 src="https://github.com/rust-lang/rust-clippy/assets/4200835/a1da6948-446d-4ccf-95a7-c816a8afdc3f" alt="The cats of this Clippy release" /> Cats for the next release can be nominated in the comments :D --- changelog: none I wish everyone reading this a beautiful and happy day =^.^=
I think it's sound? It seems like a straightforward solution would be to add a
#[force_share]
attribute. We could also add anUnsafeForceShare
marker type, but I think that'd be a bit strange since unlike the other markers, this one would remove a restriction on the type, not add one.The current situation requires some gross workarounds like this: sfackler/rust-postgres@98c92c1
The text was updated successfully, but these errors were encountered: