Skip to content

Rollup of 8 pull requests - #162869

Closed
JonathanBrouwer wants to merge 20 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-OT8VyaC
Closed

JonathanBrouwer wants to merge 20 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-OT8VyaC

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

ChayimFriedman2 and others added 20 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.
Co-authored-by: Amanda Stjerna <amanda@stjerna.space>
Co-authored-by: Jack Huey <31162821+jackh726@users.noreply.github.com>
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.
…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
…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
…=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 16, 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. labels Sep 16, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r+ p=5

Trying commonly failed jobs
@bors try jobs=dist-various-1,test-various,test-x86_64-gnu-aux,test-x86_64-gnu-llvm-21-3,test-x86_64-msvc-1,test-aarch64-apple-1,test-aarch64-apple-2,test-x86_64-mingw-1,test-i686-msvc,test-armhf-gnu

@rust-bors

rust-bors Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 03a46dc has been approved by JonathanBrouwer

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 16, 2026
@rust-bors

This comment has been minimized.

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


try-job: dist-various-1
try-job: test-various
try-job: test-x86_64-gnu-aux
try-job: test-x86_64-gnu-llvm-21-3
try-job: test-x86_64-msvc-1
try-job: test-aarch64-apple-1
try-job: test-aarch64-apple-2
try-job: test-x86_64-mingw-1
try-job: test-i686-msvc
try-job: test-armhf-gnu
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 16, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #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`)
 - #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)
 - #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 16, 2026
@rust-bors

rust-bors Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 9ba947a 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: [] } -- 46.929
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 (9ba947a4f 2026-09-16) (assume minor change)
     Checked [   4.198s] 196 checks: 195 pass, 1 fail, 0 warn, 58 skip

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [   5.659s] <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 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 46663a4 (46663a48b9bfd93ff3bbb5810114374601f7d651)
Base parent: 923c95c (923c95cdf5ba65cea505aa2ea829f578e1506ed8)

@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.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.