Rollup of 16 pull requests - #162887
Closed
Zalathar wants to merge 36 commits into
Closed
Rollup of 16 pull requests#162887Zalathar wants to merge 36 commits into
Zalathar wants to merge 36 commits into
Conversation
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.
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
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.
Co-authored-by: Amanda Stjerna <amanda@stjerna.space> Co-authored-by: Jack Huey <31162821+jackh726@users.noreply.github.com>
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.
Generally `rustc_middle::query` has types while `rustc_query_impl` has operations. So this commit moves some operations from the former to the latter. Some of them are just moved, while others are inlined and removed.
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)
…ddle-query-job, r=Zalathar Move operations out of `rustc_middle::query::job` Generally `rustc_middle::query` has types while `rustc_query_impl` has operations. So this commit moves some operations from the former to the latter. Some of them are just moved, while others are inlined and removed. r? @Zalathar
…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
…s, r=adwinwhite Normalize non-rigid aliases in ty_known_to_outlive Fixes rust-lang#161067 `ty_known_to_outlive` directly registers a TypeOutlives region obligation without normalization. With the next solver, we do not expect non-rigid aliases in lexical region solving. Normalize non-rigid aliases before registering the obligation while avoiding trait solving for inputs that do not contain them.
…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
…BoxyUwU mgca: fix issue with mismatched array valtree/valtree tys fixes rust-lang#160553 reimplements rust-lang#158587 in a different way (please see that PR for context, much of this PR's diff is undoing that PR's diff) r? @BoxyUwU
…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.
Member
Author
|
Rollup of everything (excluding perf-sensitive PRs). @bors r+ rollup=never p=5 |
Contributor
Member
Author
|
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 |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 17, 2026
Rollup of 16 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
Contributor
Contributor
|
⌛ Testing commit 3f902cc with merge 51fad75... Workflow: https://github.com/rust-lang/rust/actions/runs/35204854384 |
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 17, 2026
Rollup of 16 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) - #162876 (Move operations out of `rustc_middle::query::job`) - #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`)) - #161246 (Normalize non-rigid aliases in ty_known_to_outlive) - #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`) - #162841 (enable asm tests for xtensa targets) - #162842 (reintroduce check RibKind::ConstParamTy did in direct consts) - #162845 (mgca: fix issue with mismatched array valtree/valtree tys) - #162856 (Stabilize CommandExt::show_window)
Contributor
|
PR #161246, which is a member of this rollup, changed its commit SHA. This rollup was thus unapproved due to being closed. Auto build was cancelled due to push. Cancelled workflows: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
rustc_middle::query::job#162876 (Move operations out ofrustc_middle::query::job)windows_process_extensions_main_thread_handle#160108 (Stabilizewindows_process_extensions_main_thread_handle)feature(trim_prefix_suffix)({str, [T], Path}::trim_prefixand{str, [T]}::trim_suffix) #160544 (Stabilizefeature(trim_prefix_suffix)({str, [T], Path}::trim_prefixand{str, [T]}::trim_suffix))must_uselint toExitCode#162805 (Addmust_uselint toExitCode)debug_closure_helpers#162825 (core: Add examples fordebug_closure_helpers)r? @ghost
Create a similar rollup