-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Rollup of 6 pull requests #103105
Rollup of 6 pull requests #103105
Conversation
Signed-off-by: Alex Saveau <[email protected]>
…yout, r=Amanieu Add documentation about the memory layout of `UnsafeCell<T>` The documentation for `UnsafeCell<T>` currently does not make any promises about its memory layout. This PR adds this documentation, namely that the memory layout of `UnsafeCell<T>` is the same as the memory layout of its inner `T`. # Use case Without this layout promise, the following cast would not be legally possible: ```rust fn example<T>(ptr: *mut T) -> *const UnsafeCell<T> { ptr as *const UnsafeCell<T> } ``` A use case where this can come up involves FFI. If Rust receives a pointer over a FFI boundary which provides shared read-write access (with some form of custom synchronization), and this pointer is managed by some Rust struct with lifetime `'a`, then it would greatly simplify its (internal) API and safety contract if a `&'a UnsafeCell<T>` can be created from a raw FFI pointer `*mut T`. A lot of safety checks can be done when receiving the pointer for the first time through FFI (non-nullness, alignment, initialize uninit bytes, etc.) and these properties can then be encoded into the `&UnsafeCell<T>` type. Without this documentation guarantee, this is not legal today outside of the standard library. # Caveats Casting in the opposite direction is still not valid, even with this documentation change: ```rust fn example2<T>(ptr: &UnsafeCell<T>) -> &mut T { let t = ptr as *const UnsafeCell<T> as *mut T; unsafe { &mut *t } } ``` This is because the only legal way to obtain a mutable pointer to the contents of the shared reference is through [`UnsafeCell::get`](https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.get) and [`UnsafeCell::raw_get`](https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.raw_get). Although there might be a desire to also make this legal at some point in the future, that part is outside the scope of this PR. Also see this relevant [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/transmuting.20.26.20-.3E.20.26mut). # Alternatives Instead of adding a new documentation promise, it's also possible to add a new method to `UnsafeCell<T>` with signature `pub fn from_ptr_bikeshed(ptr: *mut T) -> *const UnsafeCell<T>` which indirectly only allows one-way casting to `*const UnsafeCell<T>`.
…r=scottmcm Add MaybeUninit array transpose From impls See discussion in rust-lang#101179 and rust-lang#96097. I believe this solution offers the simplest implementation with minimal future API regret. `@RalfJung` mind doing a correctness review?
Update pkg-config I'd like to be able to cross-compile rustc in a scenario where it'd be really helpful to have rust-lang/pkg-config-rs@cd3ccca. I've done some test builds of the compiler on x86_64 linux, targeting x86_64 linux and aarch64 linux.
…imes, r=cjgillot pretty: fix to print some lifetimes on HIR pretty-print HIR pretty-printer doesn't seem to print some lifetimes in types. This PR fixes that. Closes rust-lang#85089
Surround type with backticks Very smol PR. :)
…r=notriddle Fix settings page Thanks to rust-lang#103060, I discovered that the settings page was badly rendered. This PR fixes it. Before: ![Screenshot from 2022-10-15 16-02-41](https://user-images.githubusercontent.com/3050060/195990668-42e0b16b-3146-4864-b822-6f6a80fb77a5.png) After: ![Screenshot from 2022-10-15 16-02-31](https://user-images.githubusercontent.com/3050060/195990664-20f967df-8989-4336-bca9-be52baab8e81.png) r? ```@notriddle```
@bors r+ rollup=never p=6 |
☀️ Test successful - checks-actions |
📌 Perf builds for each rolled up PR: previous master: 75dbd5b8c3 In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
Finished benchmarking commit (e928a46): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
Successful merges:
UnsafeCell<T>
#101717 (Add documentation about the memory layout ofUnsafeCell<T>
)Failed merges:
r? @ghost
@rustbot modify labels: rollup
Create a similar rollup