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 #138956

Merged
merged 28 commits into from
Mar 26, 2025
Merged

Rollup of 11 pull requests #138956

merged 28 commits into from
Mar 26, 2025

Conversation

jhpratt
Copy link
Member

@jhpratt jhpratt commented Mar 26, 2025

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

Kobzol and others added 28 commits March 22, 2025 14:00
PRs rust-lang#136842 (Add libstd support for Trusty targets), rust-lang#137793 (Stablize
anonymous pipe), and rust-lang#136929 (std: move process implementations to
`sys`) merged around the same time, so update Trusty to take them into
account.
The newly added pattern types validity tests fail on s390x and
presumably other big-endian systems, due to print of raw values
with padding bytes.

To fix the tests remove the raw output values in the error note by
`normalize-stderr`.
It uses `libname.a` instead of the standard MSVC naming `name.lib`.

Naming for import libraries isn't touched.
We intend to fix the outstanding issues on the target and eventually
promote it to tier 2. We have the capacity to maintain this target in
the future and already perform regular builds of rustc for this target.

Currently, all host tools except miri build fine, but I have a patch for
libffi-sys to make miri also compile fine for this target that is
pending review [1].

While at it, add an option for the musl root for this target.

[1]: tov/libffi-rs#100

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
add necessary lines

fix ui test error
There are a number of `is_empty` checks that can never fail. This commit
removes them.
I noticed that `PartialOrd` implementation for `bool` does not override the
individual operator methods, unlike the other primitive types like `char`
and integers.

This commit extracts these `PartialOrd` overrides shared by the other
primitive types into a macro and calls it on `bool` too.
…in-traits, r=oli-obk,traviscross

Stabilize `#![feature(precise_capturing_in_traits)]`

# Precise capturing (`+ use<>` bounds) in traits - Stabilization Report

Fixes rust-lang#130044.

## Stabilization summary

This report proposes the stabilization of `use<>` precise capturing bounds in return-position impl traits in traits (RPITITs). This completes a missing part of [RFC 3617 "Precise capturing"].

Precise capturing in traits was not ready for stabilization when the first subset was proposed for stabilization (namely, RPITs on free and inherent functions - rust-lang#127672) since this feature has a slightly different implementation, and it hadn't yet been implemented or tested at the time. It is now complete, and the type system implications of this stabilization are detailed below.

## Motivation

Currently, RPITITs capture all in-scope lifetimes, according to the decision made in the ["lifetime capture rules 2024" RFC](https://rust-lang.github.io/rfcs/3498-lifetime-capture-rules-2024.html#return-position-impl-trait-in-trait-rpitit). However, traits can be designed such that some lifetimes in arguments may not want to be captured. There is currently no way to express this.

## Major design decisions since the RFC

No major decisions were made. This is simply an extension to the RFC that was understood as a follow-up from the original stabilization.

## What is stabilized?

Users may write `+ use<'a, T>` bounds on their RPITITs. This conceptually modifies the desugaring of the RPITIT to omit the lifetimes that we would copy over from the method. For example,

```rust
trait Foo {
    fn method<'a>(&'a self) -> impl Sized;

    // ... desugars to something like:
    type RPITIT_1<'a>: Sized;
    fn method_desugared<'a>(&'a self) -> Self::RPITIT_1<'a>;

    // ... whereas with precise capturing ...
    fn precise<'a>(&'a self) -> impl Sized + use<Self>;

    // ... desugars to something like:
    type RPITIT_2: Sized;
    fn precise_desugared<'a>(&'a self) -> Self::RPITIT_2;
}
```

And thus the GAT doesn't name `'a`. In the compiler internals, it's not implemented exactly like this, but not in a way that users should expect to be able to observe.

#### Limitations on what generics must be captured

Currently, we require that all generics from the trait (including the `Self`) type are captured. This is because the generics from the trait are required to be *invariant* in order to do associated type normalization.

And like regular precise capturing bounds, all type and const generics in scope must be captured.

Thus, only the in-scope method lifetimes may be relaxed with this syntax today.

## What isn't stabilized? (a.k.a. potential future work)

See section above. Relaxing the requirement to capture all type and const generics in scope may be relaxed when rust-lang#130043 is implemented, however it currently interacts with some underexplored corners of the type system (e.g. unconstrained type bivariance) so I don't expect it to come soon after.

## Implementation summary

This functionality is implemented analogously to the way that *opaque type* precise capturing works.

Namely, we currently use *variance* to model the capturedness of lifetimes. However, since RPITITs are anonymous GATs instead of opaque types, we instead modify the type relation of GATs to consider variances for RPITITs (along with opaque types which it has done since rust-lang#103491).

https://github.com/rust-lang/rust/blob/30f168ef811aec63124eac677e14699baa9395bd/compiler/rustc_middle/src/ty/util.rs#L954-L976

https://github.com/rust-lang/rust/blob/30f168ef811aec63124eac677e14699baa9395bd/compiler/rustc_type_ir/src/relate.rs#L240-L244

Using variance to model capturedness is an implementation detail, and in the future it would be desirable if opaques and RPITITs simply did not include the uncaptured lifetimes in their generics. This can be changed in a forwards-compatible way, and almost certainly would not be observable by users (at least not negatively, since it may indeed fix some bugs along the way).

## Tests

* Test that the lifetime isn't actually captured: `tests/ui/impl-trait/precise-capturing/rpitit.rs` and `tests/ui/impl-trait/precise-capturing/rpitit-outlives.rs` and `tests/ui/impl-trait/precise-capturing/rpitit-outlives-2.rs`.
* Technical test for variance computation: `tests/ui/impl-trait/in-trait/variance.rs`.
* Test that you must capture all trait generics: `tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.rs`.
* Test that you cannot capture more than what the trait specifies: `tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs` and `tests/ui/impl-trait/precise-capturing/rpitit-impl-captures-too-much.rs`.
* Undercapturing (refinement) lint: `tests/ui/impl-trait/in-trait/refine-captures.rs`.

### What other unstable features may be exposed by this feature?

I don't believe that this exposes any new unstable features indirectly.

## Remaining bugs and open issues

Not aware of any open issues or bugs.

## Tooling support

Rustfmt: ✅ Supports formatting `+ use<>` everywhere.

Clippy: ✅ No support needed, unless specific clippy lints are impl'd to care for precise capturing itself.

Rustdoc: ✅ Rendering `+ use<>` precise capturing bounds is supported.

Rust-analyzer: ✅ Parser support, and then lifetime support isn't needed rust-lang#138128 (comment) (previous: ~~:question: There is parser support, but I am unsure of rust-analyzer's level of support for RPITITs in general.~~)

## History

Tracking issue: rust-lang#130044

* rust-lang#131033
* rust-lang#132795
* rust-lang#136554
…=marcoieni

Group test diffs by stage in post-merge analysis

I think that this is clearer than including the stage in the test name.

To test e.g. on [this PR](rust-lang#138523):
```bash
$ curl https://ci-artifacts.rust-lang.org/rustc-builds/282865097d138c7f0f7a7566db5b761312dd145c/metrics-aarch64-gnu.json > metrics.json
$ cargo run --manifest-path src/ci/citool/Cargo.toml postprocess-metrics metrics.json --job-name aarch64-gnu --parent d9e5539 > out.md
```

r? `@marcoieni`
linker: Fix staticlib naming for UEFI

And one minor refactoring in the second commit.
…idtwco

Batch mark waiters as unblocked when resuming in the deadlock handler

This fixes a race when resuming multiple threads to resolve query cycles. This now marks all threads as unblocked before resuming  any of them. Previously if one was resumed and marked as unblocked at a time. The first thread resumed could fall asleep then Rayon would detect a second false deadlock. Later the initial deadlock handler thread would resume further threads.

This also reverts the workaround added in rust-lang#137731.

cc `@SparrowLii` `@lqd`
…Poison,saethlin

Trusty: Fix build for anonymous pipes and std::sys::process

PRs rust-lang#136842 (Add libstd support for Trusty targets), rust-lang#137793 (Stablize anonymous pipe), and rust-lang#136929 (std: move process implementations to `sys`) merged around the same time, so update Trusty to take them into account.

cc `@randomPoison`
…for-doctests, r=notriddle

Ignore doctests only in specified targets

Quick fix for rust-lang#138863

FIxes  rust-lang#138863

cc `@yotamofek` `@notriddle`
…compiler-errors

Fix ui pattern_types test for big-endian platforms

The newly added pattern types validity tests fail on s390x and presumably other big-endian systems, due to print of raw values with padding bytes.

To fix the tests remove the raw output values in the error note by `normalize-stderr`.
…musl-maintainer, r=compiler-errors

Add target maintainer information for powerpc64-unknown-linux-musl

We intend to fix the outstanding issues on the target and eventually promote it to tier 2. We have the capacity to maintain this target in the future and already perform regular builds of rustc for this target.

Currently, all host tools except miri build fine, but I have a patch for libffi-sys to make miri also compile fine for this target that is [pending review](tov/libffi-rs#100).

While at it, add an option for the musl root for this target.

I also added a kernel version requirement, which is rather arbitrarily chosen, but it matches our tier 2 powerpc64le-unknown-linux-musl target so I think it is a good fit.
…li-obk

Allow defining opaques in statics and consts

r? oli-obk

Fixes rust-lang#138902
…, r=GuillaumeGomez

rustdoc: remove useless `Symbol::is_empty` checks.

There are a number of `is_empty` checks that can never fail. This commit removes them, in support of rust-lang#137978.

r? `@GuillaumeGomez`
…, r=scottmcm

Override PartialOrd methods for bool

I noticed that `PartialOrd` implementation for `bool` does not override the individual operator methods, unlike the other primitive types like `char` and integers.

This commit extracts these `PartialOrd` overrides shared by the other primitive types into a macro and calls it on `bool` too.

CC `@scottmcm` for our recent adventures in `PartialOrd` land
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc labels Mar 26, 2025
@rustbot rustbot added 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) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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 Mar 26, 2025
@jhpratt
Copy link
Member Author

jhpratt commented Mar 26, 2025

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Mar 26, 2025

📌 Commit deb987b has been approved by jhpratt

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 Mar 26, 2025
@bors
Copy link
Contributor

bors commented Mar 26, 2025

⌛ Testing commit deb987b with merge 6e8abb5...

@bors
Copy link
Contributor

bors commented Mar 26, 2025

☀️ Test successful - checks-actions
Approved by: jhpratt
Pushing 6e8abb5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 26, 2025
@bors bors merged commit 6e8abb5 into rust-lang:master Mar 26, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 26, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 068609c (parent) -> 6e8abb5 (this PR)

Test differences

Show 52 test diffs

Stage 1

  • [ui] tests/rustdoc-ui/doctest/per-target-ignores.rs: [missing] -> ignore (only executed when the architecture is aarch64) (J1)
  • [ui] tests/ui/feature-gates/feature-gate-precise_capturing_in_traits.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/define-via-const.rs: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/define-via-extern.rs: [missing] -> pass (J1)
  • errors::verify_ast_lowering_no_precise_captures_on_rpitit_35: pass -> [missing] (J2)
  • errors::verify_ast_lowering_yield_in_closure_35: [missing] -> pass (J2)
  • errors::verify_ast_lowering_yield_in_closure_36: pass -> [missing] (J2)

Stage 2

  • [ui] tests/ui/feature-gates/feature-gate-precise_capturing_in_traits.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/define-via-const.rs: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/define-via-extern.rs: [missing] -> pass (J0)
  • [ui] tests/rustdoc-ui/doctest/per-target-ignores.rs: [missing] -> ignore (only executed when the architecture is aarch64) (J3)
  • [ui] tests/rustdoc-ui/doctest/per-target-ignores.rs: [missing] -> pass (J4)

Additionally, 40 doctest diffs were found. These are ignored, as they are noisy.

Job group index

  • J0: aarch64-apple, aarch64-gnu, arm-android, armhf-gnu, dist-i586-gnu-i586-i686-musl, i686-gnu-1, i686-gnu-nopt-1, i686-msvc-1, test-various, x86_64-apple-2, x86_64-gnu, x86_64-gnu-llvm-18-1, x86_64-gnu-llvm-18-2, x86_64-gnu-llvm-19-1, x86_64-gnu-llvm-19-2, x86_64-gnu-nopt, x86_64-gnu-stable, x86_64-mingw-1, x86_64-msvc-1
  • J1: x86_64-gnu-llvm-18-3, x86_64-gnu-llvm-19-3
  • J2: aarch64-apple, aarch64-gnu, i686-gnu-2, i686-gnu-nopt-2, i686-mingw-2, i686-mingw-3, i686-msvc-2, x86_64-apple-1, x86_64-gnu, x86_64-gnu-llvm-18-3, x86_64-gnu-llvm-19-3, x86_64-gnu-nopt, x86_64-gnu-stable, x86_64-mingw-2, x86_64-msvc-2
  • J3: i686-gnu-1, i686-gnu-nopt-1, i686-msvc-1, x86_64-apple-1, x86_64-gnu, x86_64-gnu-llvm-18-1, x86_64-gnu-llvm-18-2, x86_64-gnu-llvm-19-1, x86_64-gnu-llvm-19-2, x86_64-gnu-nopt, x86_64-gnu-stable, x86_64-mingw-1, x86_64-msvc-1
  • J4: aarch64-apple, aarch64-gnu

@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#138128 Stabilize #![feature(precise_capturing_in_traits)] b5b242b9fac1fc2204ca59ef02cb3bb93a0d4114 (link)
#138834 Group test diffs by stage in post-merge analysis 7c30b99c77642e9438bb454cd38dcbff065f6704 (link)
#138867 linker: Fix staticlib naming for UEFI b09105b48c34a73068e821d49850024eb7c2d84c (link)
#138874 Batch mark waiters as unblocked when resuming in the deadlo… b93a909906e379f68db86b9ece7ed3c1c6fae3b5 (link)
#138875 Trusty: Fix build for anonymous pipes and std::sys::process 6527fe35ecf02a48cfd3918c323aabc0d34eea15 (link)
#138877 Ignore doctests only in specified targets 16a6e93e06cfdf75a077afdc7609af0395ce1e9a (link)
#138885 Fix ui pattern_types test for big-endian platforms b96455cdad5c9f08d00c87919e23966e0a459e15 (link)
#138905 Add target maintainer information for powerpc64-unknown-lin… 1aa952898ccf21b9d162afd7fcaa5144be5f4111 (link)
#138911 Allow defining opaques in statics and consts bb54dfef0b4624f2a7f1bf482ce9f122bd881c30 (link)
#138917 rustdoc: remove useless Symbol::is_empty checks. 42fdbc939188407dff11741db60dcec90a75f37a (link)
#138945 Override PartialOrd methods for bool 3c19993038b85f8285fa31481694a7f16b494fed (link)

previous master: 068609ce76

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 (6e8abb5): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

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
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.7%, secondary 1.6%)

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
Regressions ❌
(secondary)
1.6% [1.6%, 1.7%] 3
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.7% [-2.7%, -2.7%] 1

Cycles

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

Binary size

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

Bootstrap: 777.496s -> 777.215s (-0.04%)
Artifact size: 365.89 MiB -> 365.89 MiB (0.00%)

@jhpratt jhpratt deleted the rollup-6g7ppwd branch March 27, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. 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-infra Relevant to the infrastructure 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.

None yet