-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Shared<T> does not forward Sync #31456
Comments
I'm not sure that the definition of
The Nomicon has more details. |
That is an unsafe operation however, so the usual rules don’t apply.
|
Since you can't access Edit to clarify: I see no reason to forward Sync. |
@alexreg In that case, why is |
From the nomicon link you posted: "Doing anything useful with a raw pointer requires dereferencing it, which is already unsafe. In that sense, one could argue that it would be "fine" for them to be marked as thread safe." ;) |
Anyway, if we’re going to use the argument “it can only be accessed unsafely”, then I think
|
Documentation for
|
This rather misses the point, since you can alias raw pointers anyway. I think it’s all a big lie to be talking about guarantees with unsafe pointers anyway. Why not make this explicit by not pretending there are by implementing these traits?
|
Being utility building blocks, it only makes sense to change them if you show why changed properties would be a better for their use case (current uses in libstd as well as cases in non-libstd code). For example, if a property of either Unique or Shared would make it easy to create bugs. Note that
so the suggested change is a correct default for neither Rc nor Arc. |
Based on #27730 (tracking issue) and #41064 (comment), we explicitly do not want to implement Sync for |
While it's correct for it not to forward the
Send
trait, because it could violate mutability rules, there seems to be no reason it shouldn't forward theSync
trait (asUnique<T>
does).The text was updated successfully, but these errors were encountered: