Conversation
The rules for casting `*mut X<dyn A>` -> `*mut Y<dyn B>` are as follows: - If `B` has a principal - `A` must have exactly the same principal (including generics) - Auto traits of `B` must be a subset of autotraits in `A` Note that `X<_>` and `Y<_>` can be identity, or arbitrary structs with last field being the dyn type. The lifetime of the trait object itself (`dyn ... + 'a`) is not checked. This prevents a few soundness issues with `#![feature(arbitrary_self_types)]` and trait upcasting. Namely, these checks make sure that vtable is always valid for the pointee.
I think it's fine, but let's ask T-lang separately.
...because it's very sketchy and causes FCWs. In this case it *is* actually sound, but still. I should write a better fork of anymap...
Co-authored-by: Michael Goulet <michael@errs.io>
…, r=compiler-errors,oli-obk,lnicola Make casts of pointers to trait objects stricter This is an attempt to `fix` rust-lang#120222 and rust-lang#120217. This is done by adding restrictions on casting pointers to trait objects. Before this PR the rules were as follows: > When casting `*const X<dyn A>` -> `*const Y<dyn B>`, principal traits in `A` and `B` must refer to the same trait definition (or no trait). With this PR the rules are changed to > When casting `*const X<dyn Src>` -> `*const Y<dyn Dst>` > - if `Dst` has a principal trait `DstP`, > - `Src` must have a principal trait `SrcP` > - `dyn SrcP` and `dyn DstP` must be the same type (modulo the trait object lifetime, `dyn T+'a` -> `dyn T+'b` is allowed) > - Auto traits in `Dst` must be a subset of auto traits in `Src` > - Not adhering to this is currently a FCW (warn-by-default + `FutureReleaseErrorReportInDeps`), instead of an error > - if `Src` has a principal trait `Dst` must as well > - this restriction will be removed in a follow up PR This ensures that 1. Principal trait's generic arguments match (no `*const dyn Tr<A>` -> `*const dyn Tr<B>` casts, which are a problem for [rust-lang#120222](rust-lang#120222)) 2. Principal trait's lifetime arguments match (no `*const dyn Tr<'a>` -> `*const dyn Tr<'b>` casts, which are a problem for [rust-lang#120217](rust-lang#120217)) 3. No auto traits can be _added_ (this is a problem for arbitrary self types, see [this comment](rust-lang#120248 (comment))) Some notes: - We only care about the metadata/last field, so you can still cast `*const dyn T` to `*const WithHeader<dyn T>`, etc - The lifetime of the trait object itself (`dyn A + 'lt`) is not checked, so you can still cast `*mut FnOnce() + '_` to `*mut FnOnce() + 'static`, etc - This feels fishy, but I couldn't come up with a reason it must be checked The diagnostics are currently not great, to say the least, but as far as I can tell this correctly fixes the issues. cc `@oli-obk` `@compiler-errors` `@lcnr`
Mark format! with must_use hint Uses unstable feature rust-lang#94745 Part of rust-lang#126475 First contribution to rust, please let me know if the blessing of tests is correct Thanks `@bjorn3` for the help
Verify that allocations output by GVN are sufficiently aligned. Fixes rust-lang#127396 r? `@oli-obk`
…pratt clarify `sys::unix::fd::FileDesc::drop` comment closes rust-lang#66876 simply clarifies some resource-relevant things regarding the `close` syscall to reduce the amount of search needed in other parts of the web.
…r=clubby789 bootstrap: once_cell::sync::Lazy -> std::sync::LazyLock Since rust-lang#121377 has landed on beta
|
@bors r+ rollup=never p=6 |
|
☀️ Test successful - checks-actions |
|
📌 Perf builds for each rolled up PR:
previous master: cfd7cf5a0e In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
|
Finished benchmarking commit (a06e9c8): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary 0.7%)This 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.
CyclesResults (primary -1.0%, secondary 2.3%)This 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.
Binary sizeResults (primary -0.0%, secondary 0.1%)This 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.
Bootstrap: 701.941s -> 700.067s (-0.27%) |
|
@rust-timer build 05413a8 |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (05413a8): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDInstruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary 1.1%)This 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.
CyclesResults (primary -0.9%, secondary 2.5%)This 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.
Binary sizeResults (primary -0.0%, secondary 0.1%)This 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.
Bootstrap: 701.941s -> 700.738s (-0.17%) |
|
Interesting, I did not expect #127355 to have any perf. effect. Maybe the macro change? |
Successful merges:
sys::unix::fd::FileDesc::dropcomment #127460 (clarifysys::unix::fd::FileDesc::dropcomment)Failed merges:
StructuredDiag#127357 (RemoveStructuredDiag)r? @ghost
@rustbot modify labels: rollup
Create a similar rollup