UnsafePinned: update get() docs and signature to allow shared mutation#142162
UnsafePinned: update get() docs and signature to allow shared mutation#142162bors merged 2 commits intorust-lang:masterfrom
Conversation
|
rustbot has assigned @workingjubilee. Use |
| /// This can be cast to a pointer of any kind. | ||
| /// Ensure that the access is unique (no active references, mutable or not) | ||
| /// when casting to `&mut T`, and ensure that there are no mutations | ||
| /// or mutable aliases going on when casting to `&T`. |
There was a problem hiding this comment.
Nit. This would be better, I'd suggest, mechanically wrapped.
There was a problem hiding this comment.
I personally prefer semantic linebreaks, since the primary way this will be read is in the actual compiled documentation form and so the internal format of our docs is best-off organized around tracking history.
I don't usually quibble much over it though.
There was a problem hiding this comment.
We use auto-wrapping almost everywhere, and semantic wrapping doesn't go well with out 100 column limit, so I think I'll re-wrap this.
| /// when casting to `&mut T`, and ensure that there are no mutations | ||
| /// or mutable aliases going on when casting to `&T`. |
There was a problem hiding this comment.
I'd suggest wording here along the lines of "...ensure that there are no ongoing mutations or live mutable references when casting to &T."
There was a problem hiding this comment.
FWIW this paragraph is copied verbatim from UnsafeCell::get. I was hoping we could just reuse it without spending a lot of time on editing.^^
| /// Ensure that the access is unique (no active references, mutable or not) | ||
| /// when casting to `&mut T`, and ensure that there are no mutations |
There was a problem hiding this comment.
Since the second half of this, about casting to &T, makes note about ensuring there are no ongoing foreign writes (i.e. even if no active references exist), perhaps the first half should as well, since I'd expect casting to &mut T to have this same precondition.
| /// when casting to `&mut T`, and ensure that there are no mutations | ||
| /// or mutable aliases going on when casting to `&T`. | ||
| /// | ||
| /// All the usual caveats around mutation shared state apply, see [`UnsafeCell`]. |
There was a problem hiding this comment.
| /// All the usual caveats around mutation shared state apply, see [`UnsafeCell`]. | |
| /// All the usual caveats around mutation of shared state apply, see [`UnsafeCell`]. |
| /// This can be cast to a pointer of any kind. | ||
| /// Ensure that the access is unique (no active references, mutable or not) | ||
| /// when casting to `&mut T`, and ensure that there are no mutations | ||
| /// or mutable aliases going on when casting to `&T`. |
There was a problem hiding this comment.
I wonder if we can apply the deduplicating technique of #141609 or if it's even worth it here? Probably not, it's just a few lines.
|
I've replaced the paragraph in question with a reference to the |
|
@bors r=traviscross
|
…iscross UnsafePinned: update get() docs and signature to allow shared mutation Follow-up to rust-lang#140638, making `get` consistent with the fact that there's an `UnsafeCell` inside this type now by returning `*mut T` instead of `*const T`. Cc `@rust-lang/libs-api` Tracking issue: rust-lang#125735
Rollup of 11 pull requests Successful merges: - #140774 (Affirm `-Cforce-frame-pointers=off` does not override) - #141001 (Make NonZero<char> possible) - #141700 (Atomic intrinsics : use const generic ordering, part 2) - #142008 (const-eval error: always say in which item the error occurred) - #142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`) - #142089 (Replace all uses of sysroot_candidates with get_or_default_sysroot) - #142108 (compiler: Add track_caller to AbiMapping::unwrap) - #142132 (`tests/ui`: A New Order [6/N]) - #142162 (UnsafePinned: update get() docs and signature to allow shared mutation) - #142171 (`tests/ui`: A New Order [7/N]) - #142179 (store `target.min_global_align` as an `Align`) r? `@ghost` `@rustbot` modify labels: rollup
…ingjubilee,traviscross UnsafePinned: update get() docs and signature to allow shared mutation Follow-up to rust-lang#140638, making `get` consistent with the fact that there's an `UnsafeCell` inside this type now by returning `*mut T` instead of `*const T`. Cc `@rust-lang/libs-api` Tracking issue: rust-lang#125735
Rollup of 12 pull requests Successful merges: - #141803 (Remove rustc's notion of "preferred" alignment AKA `__alignof`) - #142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`) - #142089 (Replace all uses of sysroot_candidates with get_or_default_sysroot) - #142108 (compiler: Add track_caller to AbiMapping::unwrap) - #142132 (`tests/ui`: A New Order [6/N]) - #142162 (UnsafePinned: update get() docs and signature to allow shared mutation) - #142171 (`tests/ui`: A New Order [7/N]) - #142179 (store `target.min_global_align` as an `Align`) - #142183 (Added test for 30904) - #142194 (Remove all unused feature gates from the compiler) - #142199 (Do not free disk space in the `mingw-check-tidy` job) - #142210 (Run `mingw-check-tidy` on auto builds) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #142162 - RalfJung:unsafe-pinned-get, r=workingjubilee,traviscross UnsafePinned: update get() docs and signature to allow shared mutation Follow-up to #140638, making `get` consistent with the fact that there's an `UnsafeCell` inside this type now by returning `*mut T` instead of `*const T`. Cc ``@rust-lang/libs-api`` Tracking issue: #125735
Rollup of 12 pull requests Successful merges: - rust-lang/rust#141803 (Remove rustc's notion of "preferred" alignment AKA `__alignof`) - rust-lang/rust#142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`) - rust-lang/rust#142089 (Replace all uses of sysroot_candidates with get_or_default_sysroot) - rust-lang/rust#142108 (compiler: Add track_caller to AbiMapping::unwrap) - rust-lang/rust#142132 (`tests/ui`: A New Order [6/N]) - rust-lang/rust#142162 (UnsafePinned: update get() docs and signature to allow shared mutation) - rust-lang/rust#142171 (`tests/ui`: A New Order [7/N]) - rust-lang/rust#142179 (store `target.min_global_align` as an `Align`) - rust-lang/rust#142183 (Added test for 30904) - rust-lang/rust#142194 (Remove all unused feature gates from the compiler) - rust-lang/rust#142199 (Do not free disk space in the `mingw-check-tidy` job) - rust-lang/rust#142210 (Run `mingw-check-tidy` on auto builds) r? `@ghost` `@rustbot` modify labels: rollup
…ingjubilee,traviscross UnsafePinned: update get() docs and signature to allow shared mutation Follow-up to rust-lang#140638, making `get` consistent with the fact that there's an `UnsafeCell` inside this type now by returning `*mut T` instead of `*const T`. Cc ``@rust-lang/libs-api`` Tracking issue: rust-lang#125735
…ark-Simulacrum UnsafePinned::raw_get: sync signature with get This was forgotten in rust-lang#142162. Tracking issue: rust-lang#125735.
…ark-Simulacrum UnsafePinned::raw_get: sync signature with get This was forgotten in rust-lang#142162. Tracking issue: rust-lang#125735.
…ark-Simulacrum UnsafePinned::raw_get: sync signature with get This was forgotten in rust-lang#142162. Tracking issue: rust-lang#125735.
Rollup of 12 pull requests Successful merges: - rust-lang/rust#141803 (Remove rustc's notion of "preferred" alignment AKA `__alignof`) - rust-lang/rust#142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`) - rust-lang/rust#142089 (Replace all uses of sysroot_candidates with get_or_default_sysroot) - rust-lang/rust#142108 (compiler: Add track_caller to AbiMapping::unwrap) - rust-lang/rust#142132 (`tests/ui`: A New Order [6/N]) - rust-lang/rust#142162 (UnsafePinned: update get() docs and signature to allow shared mutation) - rust-lang/rust#142171 (`tests/ui`: A New Order [7/N]) - rust-lang/rust#142179 (store `target.min_global_align` as an `Align`) - rust-lang/rust#142183 (Added test for 30904) - rust-lang/rust#142194 (Remove all unused feature gates from the compiler) - rust-lang/rust#142199 (Do not free disk space in the `mingw-check-tidy` job) - rust-lang/rust#142210 (Run `mingw-check-tidy` on auto builds) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang/rust#141803 (Remove rustc's notion of "preferred" alignment AKA `__alignof`) - rust-lang/rust#142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`) - rust-lang/rust#142089 (Replace all uses of sysroot_candidates with get_or_default_sysroot) - rust-lang/rust#142108 (compiler: Add track_caller to AbiMapping::unwrap) - rust-lang/rust#142132 (`tests/ui`: A New Order [6/N]) - rust-lang/rust#142162 (UnsafePinned: update get() docs and signature to allow shared mutation) - rust-lang/rust#142171 (`tests/ui`: A New Order [7/N]) - rust-lang/rust#142179 (store `target.min_global_align` as an `Align`) - rust-lang/rust#142183 (Added test for 30904) - rust-lang/rust#142194 (Remove all unused feature gates from the compiler) - rust-lang/rust#142199 (Do not free disk space in the `mingw-check-tidy` job) - rust-lang/rust#142210 (Run `mingw-check-tidy` on auto builds) r? `@ghost` `@rustbot` modify labels: rollup
Follow-up to #140638, making
getconsistent with the fact that there's anUnsafeCellinside this type now by returning*mut Tinstead of*const T.Cc @rust-lang/libs-api
Tracking issue: #125735