Skip to content
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 11 pull requests #137573

Merged
merged 27 commits into from
Feb 25, 2025
Merged

Rollup of 11 pull requests #137573

merged 27 commits into from
Feb 25, 2025

Conversation

compiler-errors
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

aviraxp and others added 27 commits February 21, 2025 00:13
Since commit aosp-mirror/platform_frameworks_base@d5ccb03, `TMPDIR` will be set to application's cache dir when app starts.
On MIPS the DWARF version is stored in 2 bytes with the `.2byte`
assembler directive.
Type lowering can give non-fatal errors that dropck then uses to suppress its own errors. Assume this is the cases when we can't find the error in borrowck.
…_dispatch, r=oli-obk

Remove `feature(dyn_compatible_for_dispatch)` from the compiler

This PR proposes the removal of `feature(dyn_compatible_for_dispatch)` from the compiler.

* As far as I can tell from the tracking issue, there's very little demand for this feature. I think that if this feature becomes useful in the future, then a fresh implementation from a fresh set of eyes, with renewed understanding of how this feature fits into the picture of Rust as it exists **today** would be great to have; however, in the absence of this demand, I don't see a particularly good reason to keep this implementation around.

* The RFC didn't receive very much discussion outside of the lang team, and while the discussion it received seemed to suggest that this feature was aiming to simplify the language and improve expressibility, I don't think this feature has really demonstrated either of those goals in practice. Furthermore, nobody seems to have owned this feature for quite some time or express desire to push for its stabilization.

* Relatedly, I find some of the RFC discussion like "when we make things impossible it's often presumptuous"[^1] and "I tend to want to take a 'we are all adults here' attitude toward unsafe code"[^2] to be particularly uncompelling. Of course this is no criticism to the authors of those comments since they're pretty old comments now, but type soundness is (IMO) the primary goal of the types team. This feature doesn't really do much other than further complicating the story of where we must validate object safety for soundness, along making dyn-incompatible trait object types *almost* seem useful, but very much remain UB to create and misleading to users who don't know better.

* Dyn compatibility's story has gotten more complicated since the feature was proposed in 2017, and now it needs to interact with things like associated consts, GATs, RPITITs, trait upcasting, `dyn*`, etc. While some of this is exercised in the codebase today, I'm not confident all of the corners of this feature have been hammered out. Reducing the "surface area" for what can go wrong in the compiler, especially around a side of the language (`dyn Trait`) that has been known to be particularly unsound in the past, seems good enough motivation to get rid of this for now.

[^1]: rust-lang/rfcs#2027 (comment)
[^2]: rust-lang/rfcs#2027 (comment)

cc `@rust-lang/types` `@rust-lang/lang`

Tracking:

- rust-lang#43561

r? types
…ors, r=oli-obk

Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`

Firstly, this PR consolidates and reworks the error diagnostics for `CoercePointee` and `DispatchFromDyn`. There was a ton of duplication for no reason -- this reworks both the errors and also the error codes, since they can be shared between both traits since they report the same thing.

Secondly, when encountering a struct with multiple fields that must be coerced, point out the field spans, rather than mentioning the fields by name. This makes the error message clearer, but also means that we don't mention the `__S` dummy parameter for `derive(CoercePointee)`.

Thirdly, emit a custom error message when we encounter a trait error that comes from the recursive field `CoerceUnsized`/`DispatchFromDyn` trait check. **Note:** This is the only one I'm not too satisfied with -- I think it could use some more refinement, but ideally it explains that the field must be an unsize-able pointer... Feedback welcome.

Finally, don't emit `DispatchFromDyn` validity errors if we detect `CoerceUnsized` validity errors from an impl of the same ADT.

This is best reviewed per commit.

r? `@oli-obk` perhaps?

cc `@dingxiangfei2009` -- sorry for making my own attempt at this PR, but I wanted to see if I could implement a fix for rust-lang#136796 in a less complicated way, since communicating over github review comments can be a bit slow. I'll leave comments inline to explain my thinking about the diagnostics changes.
Correct doc about `temp_dir()` behavior on Android

Since commit aosp-mirror/platform_frameworks_base@d5ccb03, `TMPDIR` will be set to application's cache dir when app starts.
rustc_target: Add more RISC-V atomic-related features

This is a continuation of rust-lang#130877 and adds a few target features, including `zacas`, which was experimental in LLVM 19 and marked non-experimental in LLVM 20.

This adds the following target features to unstable riscv_target_feature:

- `za64rs` (Za64rs Extension 1.0): Reservation Set Size of at Most 64 Bytes
  ([definition in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0-rc2/llvm/lib/Target/RISCV/RISCVFeatures.td#L227-L228), [available since LLVM 18](llvm/llvm-project@8649328))
- `za128rs` (Za128rs Extension 1.0): Reservation Set Size of at Most 128 Bytes
  ([definition in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0-rc2/llvm/lib/Target/RISCV/RISCVFeatures.td#L230-L231), [available since LLVM 18](llvm/llvm-project@8649328))
  - IIUC, `za*rs` can be referenced when implementing helpers to reduce contention in synchronization primitives, like [`crossbeam_utils::CachePadded`](https://docs.rs/crossbeam-utils/latest/crossbeam_utils/struct.CachePadded.html). (relevant discussion: riscv/riscv-profiles#79)
- `zacas` (Zacas Extension 1.0): Atomic Compare-And-Swap Instructions (`amocas.{w,d,q}{,.aq,.rl,.aqrl}` and `amocas.{b,h}{,.aq,.rl,.aqrl}` when `zabha` is also enabled)
  ([definition in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0-rc2/llvm/lib/Target/RISCV/RISCVFeatures.td#L240-L243), [available as non-experimental since LLVM 20](llvm/llvm-project@614aeda))
  - This implies `zaamo`.
  - This is used to optimize CAS in existing atomics and/or implement 64-bit/128-bit atomics on riscv32/riscv64 (e.g., taiki-e/portable-atomic#173).
  - Note that [LLVM does not automatically use this instruction for 64-bit/128-bit atomics on riscv32/riscv64 even if this feature is enabled, because doing it changes the ABI](https://github.com/llvm/llvm-project/blob/876174ffd7533dc220f94721173bb767b659fa7f/llvm/docs/RISCVUsage.rst#riscv-zacas-note). (If the ability to do that is provided by LLVM in the future, it should probably be controlled by another ABI feature similar to `forced-atomics`.)
- `zama16b` (Zama16b Extension 1.0): Atomic 16-byte misaligned loads, stores and AMOs
  ([definition in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0-rc2/llvm/lib/Target/RISCV/RISCVFeatures.td#L255-L256), [available since LLVM 19](llvm/llvm-project@b090569))
  - IIUC, unlike AArch64 FEAT_LSE2 which also makes 16-byte aligned ldp ({i,u}128 load) atomic, this extension only affects instructions that already considered atomic if they were naturally aligned. i.e., fld (f64 load) on riscv32 would not be atomic with or without this extension ([relevant QEMU code](https://github.com/qemu/qemu/blob/b69801dd6b1eb4d107f7c2f643adf0a4e3ec9124/target/riscv/insn_trans/trans_rvd.c.inc#L50-L62)).
- `zawrs` (Zawrs Extension 1.0): Wait on Reservation Set (`wrs.nto` and `wrs.sto`)
  ([definition in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0-rc2/llvm/lib/Target/RISCV/RISCVFeatures.td#L258), [available as non-experimental since LLVM 17](llvm/llvm-project@d41a73a))
  - This is used to optimize synchronization primitives (e.g., Linux uses this for spinlocks (torvalds/linux@b8ddb0d)).

Btw, the question of whether `zaamo` is implied by `zabha` or not, which was discussed in rust-lang#130877, has been resolved in LLVM 20, since LLVM now treats `zaamo` as implied by `zabha`/`zacas` (llvm/llvm-project#115694), just like GCC and rustc.

r? `@Amanieu`

`@rustbot` label +O-riscv +A-target-feature
…ust_be_overridden, r=oli-obk

remove `#[rustc_intrinsic_must_be_overridde]`

In rust-lang#135031, we gained support for just leaving away the body. Now that the bootstrap compiler got bumped, stop using the old style and remove support for it.

r? `@oli-obk`

There are a few more mentions of this attribute in RA code that I didn't touch; Cc `@rust-lang/rust-analyzer`
…, r=jieyouxu

DWARF mixed versions with LTO on MIPS

On MIPS the DWARF version is stored in 2 bytes with the `.2byte` assembler directive.
std: Fix another new symlink test on Windows

Checking for `got_symlink_permission` first is a standard procedure for such tests.
Pass correct `TypingEnv` to `InlineAsmCtxt`

Fixes rust-lang#137512

r? oli-obk
…ing-dropck-error, r=compiler-errors

Don't immediately panic if dropck fails without returning errors

This span_bug was a little too optimistic. I've decided that matching on the ErrorGuaranteed is a little more sensible than a delay bug that will always be ignored.

closes rust-lang#137329
r? `@compiler-errors`
Update books

## rust-lang/book

2 commits in d4d2c18cbd20876b2130a546e790446a8444cb32..4a01a9182496f807aaa5f72d93a25ce18bcbe105
2025-02-24 14:48:34 UTC to 2025-02-13 19:29:47 UTC

- Fix typos in chapter 17 (rust-lang/book#4238)
- NoStarch backports (rust-lang/book#4224)

## rust-lang/edition-guide

2 commits in 8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9..daa4b763cd848f986813b5cf8069e1649f7147af
2025-02-22 14:58:51 UTC to 2025-02-21 02:30:17 UTC

- Remove precise capturing features (rust-lang/edition-guide#362)
- use same name as previous example (rust-lang/edition-guide#360)

## rust-lang/nomicon

1 commits in 336f75835a6c0514852cc65aba9a698b699b13c8..8f5c7322b65d079aa5b242eb10d89a98e12471e1
2025-02-19 13:16:47 UTC to 2025-02-19 13:16:47 UTC

- other-reprs: do not make it sound like we are making ABI promises for repr(int) enums (rust-lang/nomicon#461)

## rust-lang/reference

4 commits in 6195dbd70fc6f0980c314b4d23875ac570d8253a..615b4cec60c269cfc105d511c93287620032d5b0
2025-02-18 23:01:53 UTC to 2025-02-13 15:12:49 UTC

- Add rule identifiers to names chapters (rust-lang/reference#1737)
- Switch from AVX to SSE in the example (rust-lang/reference#1735)
- Remove attributes from struct field rest patterns (rust-lang/reference#1736)
- Update reference for target_feature_11. (rust-lang/reference#1720)
…c, r=oli-obk

rename simd_shuffle_generic → simd_shuffle_const_generic

I've been confused by this name one time too often. ;)

r? `@oli-obk`
@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 25, 2025
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. rollup A PR which is a rollup labels Feb 25, 2025
@compiler-errors
Copy link
Member Author

@bors r+ rollup=never p=10

@bors
Copy link
Contributor

bors commented Feb 25, 2025

📌 Commit 6c1f959 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2025
@bors
Copy link
Contributor

bors commented Feb 25, 2025

⌛ Testing commit 6c1f959 with merge f5729cf...

@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #137573!

Tested on commit f5729cf.
Direct link to PR: #137573

🎉 edition-guide on windows: test-fail → test-pass (cc @ehuss).
🎉 edition-guide on linux: test-fail → test-pass (cc @ehuss).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Feb 25, 2025
Tested on commit rust-lang/rust@f5729cf.
Direct link to PR: <rust-lang/rust#137573>

🎉 edition-guide on windows: test-fail → test-pass (cc @ehuss).
🎉 edition-guide on linux: test-fail → test-pass (cc @ehuss).
@bors
Copy link
Contributor

bors commented Feb 25, 2025

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing f5729cf to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 25, 2025
@bors bors merged commit f5729cf into rust-lang:master Feb 25, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Feb 25, 2025
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#136522 Remove feature(dyn_compatible_for_dispatch) from the comp… 27d0df5a1640f9ce19f1bb79d3e96bf6614437ee (link)
#137289 Consolidate and improve error messaging for CoerceUnsized f8edf60974a6eb3baf2fed94702a4b367503834d (link)
#137321 Correct doc about temp_dir() behavior on Android 1790a32acab5c73ce6164278b4954f6ce8248289 (link)
#137417 rustc_target: Add more RISC-V atomic-related features 238a324fa54d439d4fd71e0b26a469a4729858bc (link)
#137489 remove #[rustc_intrinsic_must_be_overridde] 6757be0afea5668e0656eba1ba2589b7727dce48 (link)
#137530 DWARF mixed versions with LTO on MIPS 9219af8c2c586845dfe173569ad4c4da6940b56c (link)
#137543 std: Fix another new symlink test on Windows a3ac5eabd5eca77217c46da910da4dacf64ad466 (link)
#137548 Pass correct TypingEnv to InlineAsmCtxt e1e9deeeb130f8c6979a3ed27e1fbf2efd268a5f (link)
#137550 Don't immediately panic if dropck fails without returning e… 7e44cb84c87684294518d63b8f42000ddfb504af (link)
#137552 Update books d34479b5f8f5877f11c7eab959a589e82cab598c (link)
#137556 rename simd_shuffle_generic → simd_shuffle_const_generic aaf9dd9eefb56a6bb43fa62336a6037645a387f9 (link)

previous master: 7d8c6e781d

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f5729cf): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.5% [0.3%, 0.7%] 3
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) 0.5% [0.3%, 0.7%] 3

Max RSS (memory usage)

Results (primary -0.1%, secondary -0.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.

mean range count
Regressions ❌
(primary)
0.9% [0.4%, 2.8%] 32
Regressions ❌
(secondary)
0.7% [0.4%, 2.3%] 28
Improvements ✅
(primary)
-0.8% [-3.4%, -0.4%] 52
Improvements ✅
(secondary)
-1.0% [-2.6%, -0.4%] 81
All ❌✅ (primary) -0.1% [-3.4%, 2.8%] 84

Cycles

Results (primary -0.3%, secondary 0.0%)

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.

mean range count
Regressions ❌
(primary)
0.7% [0.4%, 2.0%] 23
Regressions ❌
(secondary)
1.0% [0.4%, 3.4%] 66
Improvements ✅
(primary)
-1.2% [-5.0%, -0.4%] 23
Improvements ✅
(secondary)
-1.2% [-4.4%, -0.4%] 55
All ❌✅ (primary) -0.3% [-5.0%, 2.0%] 46

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 772.781s -> 772.351s (-0.06%)
Artifact size: 362.01 MiB -> 361.91 MiB (-0.03%)

@rustbot rustbot added the perf-regression Performance regression. label Feb 25, 2025
@rylev
Copy link
Member

rylev commented Feb 25, 2025

Results are too small to warrant an investigation.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.