Skip to content

Rollup of 12 pull requests - #162877

Closed
Zalathar wants to merge 28 commits into
rust-lang:mainfrom
Zalathar:rollup-BtsdVk0
Closed

Zalathar wants to merge 28 commits into
rust-lang:mainfrom
Zalathar:rollup-BtsdVk0

Conversation

@Zalathar

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

ChayimFriedman2 and others added 28 commits August 10, 2026 01:08
Giving access to `std::os::windows::process::ChildExt::main_thread_handle()`.
It does not look like these items are actually used by rustc.
This is to make it easy to update the static template, like its skeleton or style,
and add features there, instead of doing it all with rust code. The dynamic sections
are marked as dummy tokens and are replaced when dumping the MIR.
display a list of all the nodes each loan can reach (and whether the node's region
is live at the node's point)
Loan traces can be big and numerous, so we hide them by default. We instead
use a button to show a loan's trace.
margins and spacing, section separators, reachability layout, etc.
This API is in FCP, but there are no examples and much of it is
untested. Add examples here.
Item bounds already instantiate higher-ranked GAT arguments with identity parameters. Compare the bound self type with the identity alias directly, and treat any remaining bound region as static.
Right now things are undertested and underspecified.

Some of the library code would get in a loop if searcher starts
returning empty rejects.

And there's no tests for backwards multi byte char matchers. Pull
request I'm reviving had a problem implementing that, so making sure
it's tested before the actual code lands.

Right now it is possible to break both tests (and user code) without
breaking anything else in the test suite I think.
LLVM prior to 24 didn't do some optimizations around call slots on
pointers without `dereferenceable` set. A recent change enhanced the
optimizer so it can handle that case (at least in this test) so we relax
the checks here slightly. We still (from what I can tell) demonstrate
that `sse41_blend_nofeature` is not inlined, which seems to be the
import part of this region of the test.
coretests: Add more pattern tests.

Right now things are undertested and underspecified.

Some of the library code would get in a loop if searcher starts returning empty rejects.

And there's no tests for backwards multi byte char matchers. Pull request I'm reviving had a problem implementing that, so making sure it's tested before the actual code lands.

Right now it is possible to break both tests (and user code) without breaking anything else in the test suite I think.

This commit is extracted from rust-lang#160971 with slight modifications.

<!-- start jj-vine stack -->
This PR is part of a stack containing 16 PRs:

1. `main`
2. **"coretests: Add more pattern tests." (this PR)**
3. rust-lang#161606 ([Compare](https://github.com/pacak/rust/compare/more-pat-tests..generalize-pattern))
4. rust-lang#161754 ([Compare](https://github.com/pacak/rust/compare/generalize-pattern..push-qvvokrsvvqww))
5. rust-lang#161755 ([Compare](https://github.com/pacak/rust/compare/push-qvvokrsvvqww..push-wlxvvvxzrsly))
6. rust-lang#161756 ([Compare](https://github.com/pacak/rust/compare/push-wlxvvvxzrsly..push-lkvnuzsvuqzt))
7. rust-lang#161757 ([Compare](https://github.com/pacak/rust/compare/push-lkvnuzsvuqzt..push-wuxtmysppkst))
8. rust-lang#161758 ([Compare](https://github.com/pacak/rust/compare/push-wuxtmysppkst..push-tnkxmkmykopl))
9. rust-lang#161759 ([Compare](https://github.com/pacak/rust/compare/push-tnkxmkmykopl..push-umzmopsxmwry))
10. rust-lang#161760 ([Compare](https://github.com/pacak/rust/compare/push-umzmopsxmwry..push-ptqpwloxpyru))
11. rust-lang#161761 ([Compare](https://github.com/pacak/rust/compare/push-ptqpwloxpyru..push-rksmzopsvzlk))
12. rust-lang#161762 ([Compare](https://github.com/pacak/rust/compare/push-rksmzopsvzlk..push-mkxpywoqusmn))
13. rust-lang#161608 ([Compare](https://github.com/pacak/rust/compare/push-mkxpywoqusmn..flavor-pattern))
14. rust-lang#161763 ([Compare](https://github.com/pacak/rust/compare/flavor-pattern..push-xoslomrztmly))
15. rust-lang#161764 ([Compare](https://github.com/pacak/rust/compare/push-xoslomrztmly..push-pqpumynltyml))
16. rust-lang#161765 ([Compare](https://github.com/pacak/rust/compare/push-pqpumynltyml..push-svrvnxkpuqul))
17. rust-lang#161610 ([Compare](https://github.com/pacak/rust/compare/push-svrvnxkpuqul..osstr-pattern-tip))
<!-- end jj-vine stack -->
…oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
Add loan reachability traces to polonius MIR dumps

This expands the Polonius MIR dumps to add traces of all the nodes a loan traverses (and if the region it reaches is live at that point). This helps with debugging and analyzing borrow-checking, of soundness issues in particular, as they manifest as a *lack* of reachability in the localized outlives graph.

Since there can be many loans and the traces can be big, they're hidden by default until a button is clicked. I've uploaded an [example here](https://gistpreview.github.io/?b8b9218f6565f3b13f91a63859ad776e) so it's easier to test.

<sub>This feels like a good enough start, but there's definitely many expansions I'd like to make to this feature in future PRs. Some of which I've already done in [older prototypes](https://gistpreview.github.io/?4098d51d4f4e12e2a61a673b60d94690).</sub>

More easily reviewed per commit.
r? @jackh726

(also cc @amandasystems as we were all discussing things like this to help with the unsoundness analyses)
…fonthey

Guarantee 8 bytes of alignment of RawWakerVTable

This is similar to an earlier PR I made for `Thread::into_raw`: rust-lang#143859.

When using `AtomicPtr` for synchronization it's incredibly useful when you've got a couple bits you can stuff metadata in. By guaranteeing that `RawWakerVTable` is aligned to 8 bytes everyone can use the bottom 3 bits to signal other things, such as a critical section, etc. In particular, this can be used to portably implement an `AtomicWaker` which is always two pointers in size, no more.

On almost all platforms the align is already 8 bytes, and on other platforms it might cause an infinitesimal increase in size. This guarantee is thus very useful and costs us essentially nothing.

---

r? libs-api

Like last time since this adds a guarantee this probably needs a FCP.
…ead-windows, r=clarfonthey

Stabilize `windows_process_extensions_main_thread_handle`

I propose we stabilize the library feature `windows_process_extensions_main_thread_handle` (tracking issue rust-lang#96723).

## Stabilization Report

### Implementation History

This feature was added in rust-lang#96725, and not changed since.

### API Summary

```rust
// std::os::windows::process

pub trait ChildExt: Sealed {
    fn main_thread_handle(&self) -> BorrowedHandle<'_>;
}
```

This method gives access to the handle to the main thread of a spawned child process on Windows. It is not possible to get after spawning using documented APIs, and it's useful for example for resuming a process that started as suspended (while it's possible to enumerate all threads and resume them all, that's slower and more complicated).

### Experience Report

My personal reason for this is wanting to use it for this case exactly (resuming a suspended process) in rust-analyzer, see rust-lang/rust-analyzer#22763 (comment). Other people seem to want this for the same reason as well (for example in the tracking issue). [Searching GitHub for `.main_thread_handle()` gives 269 results](https://github.com/search?q=%22.main_thread_handle%28%29%22+language%3Arust&type=code). Some are for resuming processes, but there are also others - for example, [injecting a DLL](https://github.com/garyttierney/me3/blob/a1e26958d8e141864d3adfcbbef4f2f669b5c8ef/crates/launcher/src/game.rs#L98). I [even found a project](https://github.com/GitFlameAI/GitFlame-CodeRAG/blob/3684d2dc846831f9805bec4486e60296c232f974/datasets/repositories/repo_020_hyperfine/code/src/timer/windows_timer.rs#L71) that gates using this method behind a feature, and if it's not set, uses an undocumented Windows API instead.

### Unresolved Questions

There are two unresolved questions:

 - The naming - should it be the "main thread" or the "primary thread". Microsoft's documentation refers to it as the "primary thread", but our own docs mention "main thread" (https://doc.rust-lang.org/std/thread/index.html), as stated in rust-lang#96723 (comment). I left it as "main thread".
 - Should it return `Option<BorrowedHandle<'_>>`? This will enable conversion from a handle to `std::process::Child` (such conversion is not supported currently). Such conversion is not supported for any OS currently though, and making this function returning `Option` will complicate code using it, so I chose to not do that.

r? libs-api
…eness, r=adwinwhite

traits: Fix rigid alias liveness matching

Fixes rust-lang#160206

The ICE happens while borrowck computes liveness for an opaque return type with an associated type bound. In the repro, that bound looks like `<impl Foo<'x> as Foo<'x>>::Out: 'static`. The query passes unnormalized item bounds to `extract_verify_if_eq`, which expects rigid aliases with the next solver, and hits its debug assertion.

Item-bound collection already maps higher-ranked GAT arguments to the GAT's identity parameters. That means this query can compare the bound's self type directly with the identity alias. A bound on a nested projection, like the associated type in the repro, doesn't match the opaque itself and gets skipped. It doesn't tell us that the opaque is `'static`.

For bounds that do match, we keep the outlives region unless it's still bound. For example, `for<'b> Self::Assoc<'b>: 'b` becomes a non higher ranker item bound `Self::Assoc<'param>: 'param`, so that param region still matters for liveness. With `for<'b> Self::Assoc: 'b`, the same associated type has to outlive every choice of `'b`, including `'static`. We handle that case directly.

I think this is a better fit for the query because it uses the work item-bound collection already did. It removes the matcher call from this path and keeps the shared matcher's rigidity checks intact. The separate call for function bounds stays, since it still needs to match against the alias's concrete arguments. There's no extra normalization in liveness.

The original repro covers the case that triggered the assertion: an item bound on a nested projection must be skipped when computing liveness for the opaque itself.
…ix, r=clarfonthey

Stabilize `feature(trim_prefix_suffix)` (`{str, [T], Path}::trim_prefix` and `{str, [T]}::trim_suffix`)

Closes rust-lang#142312 (tracking issue)

FCP completed [here](rust-lang#142312 (comment)). There was discussion during FCP about a possibly adding `strip_circumfix`, but that wasn't mentioned as blocking.

r? libs-api
…jackh726

Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha

Fixes: rust-lang#160670

The soundness issue is caused by (as suggested by the text extruder) the incorrect variance for a region, which is supposed to be bidirectional (invariant) but is registered as contravariant.

Starting with this example (from the issue):
```rust
use std::fmt::Debug;

struct D<T: HasArg>(T::Arg);

trait HasArg {
    type Arg: Debug;
}
impl<'a, T: Debug> HasArg for fn(&'a T) {
    type Arg = &'a T;
}
impl<T: HasArg> Drop for D<T> {
    fn drop(&mut self) {
        println!("{:?}", self.0);
    }
}
fn mk<'a, T: Debug>(r: &'a T) -> D<fn(&'a T)> {
    D(r)
}

fn main() {
    let b = Box::new(vec![vec![1]]);
    let d;
    d = mk(&*b);
    drop(b); // ERROR: move out of borrowed...
}
```

This generates a path through MIR on the way to a drop that looks like this:

```MIR
_1 = move _2

/// ...

drop(_1)
```
In this instance, the types of `_1` and `_2` are `D<fn(&'?1 Vec<...>)` and `D<fn(&'?2 Vec<...>)` respectively.

During liveness computation (in `liveness::trace`) region liveness is computed from drop liveness and use liveness. Additionally, for each live region (drop-live or use-live), region variance is computed for Polonius' loan propagation. Variance determines the direction of propagation across program flow.

For drop-live locals (variables), the types reported in ` DropckOutlivesResult::kinds` are used to register drop live regions and compute their variances. However, instead of using the full type `D<...>` for the left-hand side of this assignment statement, `kinds` starts with a `Binder {...}` and the function type inside of it. From that it finds region `'?1` and records it as contravariant (backwards propagated).

This PR addresses the issue by using the entire type of the drop-live local to compute the variance of any regions referenced inside it, at the cost of potentially doing unnecessary extra work, ~~either when iteration continues over `DropckOutlivesResult::kinds`  (which should be redundant with it in most cases), or~~ if the local contains a region whose variance is actually not needed for computation or in regard to drop liveness (assuming that ever happens).

It also adds some debug statements that helped me debug the issue, and a ui test for the soundness issue.
…rget-feature, r=nikic

tests: accept LLVM 24 optimization in this test

LLVM prior to 24 didn't do some optimizations around call slots on pointers without `dereferenceable` set. A [recent change](llvm/llvm-project@8a4a0f26704b) enhanced the optimizer so it can handle that case (at least in this test) so we relax the checks here slightly. We still (from what I can tell) demonstrate that `sse41_blend_nofeature` is not inlined, which seems to be the import part of this region of the test.

@rustbot label: +llvm-main
…jhpratt

Add `must_use` lint to `ExitCode`

An [`ExitCode`](https://doc.rust-lang.org/nightly/std/process/struct.ExitCode.html) is intended to be returned from `main` (or used in other ways of terminating a process). It's also a `Result` like type in that it has success and error values. It's *probably* a mistake if it's ignored but if not it makes sense to require users to explicitly acknowledge that ignoring it is intentional (e.g. with `let _ = ...`).
…=clarfonthey

core: Add examples for `debug_closure_helpers`

This API is in FCP, but there are no examples and much of it is untested. Add examples here.
…ow-window, r=jhpratt

Stabilize CommandExt::show_window

Stabilize `std::os::windows::process::CommandExt::show_window`.

The final comment period of rust-lang#127544 was completed.
rust-lang#127544 (comment)

I have been using this function for 2 years. I want to use this function on stable Rust.
So, I open a pull request.

`windows_process_extensions_show_window` feature appears only in the location I modified.

```
> rg 'windows_process_extensions_show_window'
src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs
17165:        label: "windows_process_extensions_show_window",
17166:        description: r##"# `windows_process_extensions_show_window`

library/std/src/os/windows/process.rs
191:    #[stable(feature = "windows_process_extensions_show_window", since = "CURRENT_RUSTC_VERSION")]
```

LLM disclosure: I asked an ChatGPT for the steps and manually created a commit. I handled the searching for the code to modify (using `rg`) and the actual editing (using `nano`) myself.
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Sep 17, 2026
@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Sep 17, 2026
@rustbot rustbot added O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 17, 2026
@Zalathar

Copy link
Copy Markdown
Member Author

Rollup of everything.

@bors r+ rollup=never p=5

@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d535617 has been approved by Zalathar

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Sep 17, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Rollup of 12 pull requests

Successful merges:

 - #161596 (coretests: Add more pattern tests.)
 - #162796 (libtest: do not early exit from test runners)
 - #162844 (Add loan reachability traces to polonius MIR dumps)
 - #158186 (Guarantee 8 bytes of alignment of RawWakerVTable)
 - #160108 (Stabilize `windows_process_extensions_main_thread_handle`)
 - #160212 (traits: Fix rigid alias liveness matching)
 - #160544 (Stabilize `feature(trim_prefix_suffix)` (`{str, [T], Path}::trim_prefix` and `{str, [T]}::trim_suffix`))
 - #161305 (Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha)
 - #161838 (tests: accept LLVM 24 optimization in this test)
 - #162805 (Add `must_use` lint to `ExitCode`)
 - #162825 (core: Add examples for `debug_closure_helpers`)
 - #162856 (Stabilize CommandExt::show_window)
@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 17, 2026
@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 1d10c78 failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-stdlib-semver-check failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
[TIMING:end] doc::Std { build_compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, format: Json, crates: [] } -- 37.588
Checking semver compatibility of core
cargo-semver-checks found semver breakage in core
    Checking <unknown> v1.100.0-nightly (923c95cdf 2026-09-16) -> v1.100.0-nightly (1d10c78b1 2026-09-17) (assume minor change)
     Checked [   3.272s] 196 checks: 195 pass, 1 fail, 0 warn, 58 skip

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [   4.402s] <unknown>


--- failure repr_align_added: repr(align) added ---

Description:
repr(align(N)) was added to a type. This changes its alignment and prevents it from being used inside repr(packed) types.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#repr-align-add
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/repr_align_added.ron

Failed in:
  struct RawWakerVTable in library/core/src/task/wake.rs:113

Bootstrap failed while executing `test std-semver-check --set rust.stdlib-semver-baseline=923c95cdf5ba65cea505aa2ea829f578e1506ed8`

Important

For more information how to resolve CI failures of this job, visit this link.

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 17, 2026
@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

PR #158186, which is a member of this rollup, was unapproved.

@Zalathar Zalathar closed this Sep 17, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 17, 2026
@Zalathar
Zalathar deleted the rollup-BtsdVk0 branch September 17, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. O-windows Operating system: Windows rollup A PR which is a rollup T-clippy Relevant to the Clippy team. 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.