-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Mention that it's not actually a data race #32538
Conversation
(Rust newbie here, just for context) Is it the compiler actually looking and saying: "well, I understand the wording being used is because of the nature of explaining concurrency -- which boils down to threads -- but it seems like it might be clearer to express it in the general terms that the Rust documentation seems to explain ownership.... so long as that's what the compiler sees. If the compiler actually can differentiate between where data is being accessed from, then I mostly take back this entire comment. :P Just a thought. |
Somewhat the latter, but not exactly. What the compiler sees (and what you should see too) is that |
The current wording feels like 75% about how a smart, outside observer can tell that the individual indices could be safely mutated without stepping on each other, and the other 25% is about what situation could actually cause a problem. The whole paragraph seems to ignore the explanation you posted above. Does my summary make sense to you? Do you think it would be clearer to make a small mention, something along the lines of: "while this program may not appear to overwrite individual indices, the compiler cannot infer which pieces of the data are being operated on, only that the variable has been moved elsewhere and isn't eligible for use when we go to spawn the second thread" ? |
I'd prefer if the program was modified so that it does conflict indices :) |
Ha! Given the section is about concurrency, fair enough. I guess I would just like to put in a suggestion/plea for any explanation of the "data moving" aspect. As a Rust newbie, the ownership system is consistently the hardest piece of Rust to understand/remember. If that's the actual/current reason why the compiler complains, then it seems fitting to tell that. At any rate, it's awesome to see the documentation be so quickly updated, driven by random comments on HN no less. :) |
The assumption here is that you've read the chapter on ownership and are very clear on what moving is by the time you reach this chapter 😄 (The full compiler error on this actually links to an extended explanation on ownership that is pretty nice too) |
Got me again! A fair point, indeed. :) |
☔ The latest upstream changes (presumably #32529) made this pull request unmergeable. Please resolve the merge conflicts. |
@Manishearth: this is out of date, but r=me whenever you rebase it :) |
Conflicts: src/doc/book/concurrency.md
6b3204d
to
a447124
Compare
@bors r=steveklabnik |
📌 Commit a447124 has been approved by |
@bors rollup |
…abnik Mention that it's not actually a data race The example can't cause a data race since different indices are accesed. (perhaps we should use an example where i iterates twice?) r? @steveklabnik
…abnik Mention that it's not actually a data race The example can't cause a data race since different indices are accesed. (perhaps we should use an example where i iterates twice?) r? @steveklabnik
…abnik Mention that it's not actually a data race The example can't cause a data race since different indices are accesed. (perhaps we should use an example where i iterates twice?) r? @steveklabnik
…abnik Mention that it's not actually a data race The example can't cause a data race since different indices are accesed. (perhaps we should use an example where i iterates twice?) r? @steveklabnik
Adds data race in docs Thanks for all your hard work! This is in reference to rust-lang#32733 I know there has been a discussion about this on PR rust-lang#32538 so you are welcome to keep the code as is or merge my documentation in. Let me know what you think and/or if you want me to modify anything!
Adds data race in docs Thanks for all your hard work! This is in reference to rust-lang#32733 I know there has been a discussion about this on PR rust-lang#32538 so you are welcome to keep the code as is or merge my documentation in. Let me know what you think and/or if you want me to modify anything!
The example can't cause a data race since different indices are accesed.
(perhaps we should use an example where i iterates twice?)
r? @steveklabnik