-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn). #77722
Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn). #77722
Conversation
Replacing the UnsafeCell by a Cell simplifies things and makes it all safe.
Replacing the UnsafeCell by a Cell makes it all safe.
(rust_highfive has picked a reviewer for you, use r? to override) |
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
Could you add a comment on both introduced Cells that they're for platforms without threads so there's no need for synchronization? The UnsafeCell would've wanted that comment too, I feel. It seems a bit unfortunate that we implement Sync for the Mutex/RwLock in sys/unsupported -- do we really need to do that? It's obviously untrue... it seems like maybe ideally Rust would provide a cfg(no_threads) or whatever for us. |
Sure. Will add a comment.
Well they're safe to share between all the threads your program can have on those platforms: just the one main thread. ^^' Without |
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
Yes, I mean that it would be better if (for example) the compiler removed Sync bounds on statics, for example, on single-threaded platforms. But that would require lang approval and design :) @bors r+ |
📌 Commit b26aa5d has been approved by |
…ported-locks, r=Mark-Simulacrum Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn). Replacing `UnsafeCell`s by a `Cell`s simplifies things and makes the mutex and rwlock implementations safe. Other than that, only unsafety in strlen() contained unsafe code. @rustbot modify labels: +F-unsafe-block-in-unsafe-fn +C-cleanup
Failed in https://github.com/rust-lang-ci/rust/runs/1248784774:
@bors r- |
Ah, apparently |
f92b36a
to
af414dc
Compare
@bors r=Mark-Simulacrum rollup=iffy |
📌 Commit af414dc has been approved by |
⌛ Testing commit af414dc with merge 772eaeb38d5203c0efb95201b52b2bbaa780c734... |
💔 Test failed - checks-actions |
@bors retry |
Ah, thanks! Was just about to post a comment because I didn't understand what failed. By the way, looks like all the relevant platforms for this PR passed their tests, so |
Rollup of 14 pull requests Successful merges: - rust-lang#77239 (Enable building Cargo for aarch64-apple-darwin) - rust-lang#77569 (BTreeMap: type-specific variants of node_as_mut and cast_unchecked) - rust-lang#77719 (Remove unnecessary rustc_const_stable attributes.) - rust-lang#77722 (Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn).) - rust-lang#77725 (Add regression issue template) - rust-lang#77776 ( Give an error when running `x.py test --stage 0 src/test/ui`) - rust-lang#77786 (Mention rustdoc in `x.py setup`) - rust-lang#77825 (`min_const_generics` diagnostics improvements) - rust-lang#77868 (Include `llvm-dis`, `llc` and `opt` in `llvm-tools-preview` component) - rust-lang#77884 (Use Option::unwrap_or instead of open-coding it) - rust-lang#77886 (Replace trivial bool matches with the `matches!` macro) - rust-lang#77892 (Replace absolute paths with relative ones) - rust-lang#77895 (Include aarch64-apple-darwin in the dist manifests) - rust-lang#77909 (bootstrap: set correct path for the build-manifest binary) Failed merges: - rust-lang#77902 (Include aarch64-pc-windows-msvc in the dist manifests) r? `@ghost`
Replacing
UnsafeCell
s by aCell
s simplifies things and makes the mutex and rwlock implementations safe. Other than that, only unsafety in strlen() contained unsafe code.@rustbot modify labels: +F-unsafe-block-in-unsafe-fn +C-cleanup