Commit graph

316560 commits

Author SHA1 Message Date
Zalathar
2a96ea0bee Make QueryDispatcher::Qcx an associated type 2026-01-29 10:59:58 +11:00
bors
de6d33c033 Auto merge of #151550 - petrochenkov:packhyg2, r=nnethercote
resolve: Replace `Macros20NormalizedIdent` with `IdentKey`

This is a continuation of https://github.com/rust-lang/rust/pull/150741 and https://github.com/rust-lang/rust/pull/150982 based on the ideas from https://github.com/rust-lang/rust/pull/151491#issuecomment-3784421866.

Before this PR `Macros20NormalizedIdent` was used as a key in various "identifier -> its resolution" maps in `rustc_resolve`.
`Macros20NormalizedIdent` is a newtype around `Ident` in which `SyntaxContext` (packed inside `Span`) is guaranteed to be normalized using `normalize_to_macros_2_0`.
This type is also used in a number of functions looking up identifiers in those maps.
`Macros20NormalizedIdent` still contains span locations, which are useless and ignored during hash map lookups and comparisons due to `Ident`'s special `PartialEq` and `Hash` impls.

This PR replaces `Macros20NormalizedIdent` with a new type called `IdentKey`, which contains only a symbol and a normalized unpacked syntax context. (E.g. `IdentKey` == `Macros20NormalizedIdent` minus span locations.)
So we avoid keeping additional data and doing some syntax context packing/unpacking.

Along with `IdentKey` you can often see `orig_ident_span: Span` being passed around.
This is an unnormalized span of the original `Ident` from which `IdentKey` was obtained.
It is not used in map keys, but it is used in a number of other scenarios:
- diagnostics
- edition checks
- `allow_unstable` checks

This is because `normalize_to_macros_2_0` normalization is lossy and the normalized spans / syntax contexts no longer contain parts of macro backtraces, while the original span contains everything.
2026-01-28 18:31:51 +00:00
bors
1e5065a4d9 Auto merge of #150945 - scottmcm:tweak-slice-partial-eq, r=Mark-Simulacrum
Tweak `SlicePartialEq` to allow MIR-inlining the `compare_bytes` call

rust-lang/rust#150265 disabled this because it was a net perf win, but let's see if we can tweak the structure of this to allow more inlining on this side while still not MIR-inlining the loop when it's not just `memcmp` and thus hopefully preserving the perf win.

This should also allow MIR-inlining the length check, which was previously blocked, and thus might allow some obvious non-matches to optimize away as well.
2026-01-28 14:31:41 +00:00
bors
a234ae6b65 Auto merge of #151778 - Zalathar:rollup-A0breU3, r=Zalathar
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#151239 (Support trait objects in type info reflection)
 - rust-lang/rust#150893 (offload: move (un)register lib into global_ctors)
 - rust-lang/rust#151013 (Add some clarifications and fixes for fmt syntax)
 - rust-lang/rust#151666 (compiler: Rename several types/traits for per-query vtables)
 - rust-lang/rust#151738 (Add `extern crate core` to diagnostic tests)
 - rust-lang/rust#151747 (Update `askama` version to `0.15.2`)
 - rust-lang/rust#151759 (Update `browser-ui-test` version to `0.23.3`)
 - rust-lang/rust#151763 (Add FileCheck annotations to simplify_match.rs)
 - rust-lang/rust#151766 (Fix `x fix`, again)
2026-01-28 11:21:46 +00:00
Stuart Cook
4d2c8e3030
Rollup merge of #151766 - ferrocene:jyn/x-fix, r=jieyouxu
Fix `x fix`, again

This was refactored incorrectly at some point and would run `cargo check` even for `x fix`.
2026-01-28 19:03:54 +11:00
Stuart Cook
c6ea8ab66d
Rollup merge of #151763 - AndrewTKent:add-filecheck-simplify-match, r=dianqk
Add FileCheck annotations to simplify_match.rs

Remove `skip-filecheck` and add FileCheck directives to verify that GVN propagates the constant `false` and eliminates the match entirely.

The test now verifies:
- The debug info shows `x` as `const false` (constant propagation)
- No `switchInt` remains (match elimination)
- The function body is just `return` (dead code elimination)

Part of rust-lang/rust#116971.

r? cjgillot
2026-01-28 19:03:54 +11:00
Stuart Cook
5c0b0643ca
Rollup merge of #151759 - GuillaumeGomez:update-browser-ui-test, r=GuillaumeGomez
Update `browser-ui-test` version to `0.23.3`

Should fix https://github.com/rust-lang/rust/pull/151704#issuecomment-3801832170.
Should help with https://github.com/rust-lang/rust/issues/93784.

r? ghost
2026-01-28 19:03:53 +11:00
Stuart Cook
0f63f2a77e
Rollup merge of #151747 - GuillaumeGomez:update-askama, r=jieyouxu
Update `askama` version to `0.15.2`

Link to new release is [here](https://github.com/askama-rs/askama/releases/tag/v0.15.2). Basically improves a few things and remove some warnings.

r? @jieyouxu
2026-01-28 19:03:53 +11:00
Stuart Cook
54e60dc225
Rollup merge of #151738 - JonathanBrouwer:fix, r=Kivooeo
Add `extern crate core` to diagnostic tests

We do this to solve the `failed to resolve: you might be missing crate core` messages that were previously visible in the stderr.
We also split off `subdiagnostic-derive-2` from the main `subdiagnostic-derive`, because the error for this test is now generated post-expansion.
2026-01-28 19:03:52 +11:00
Stuart Cook
384a569072
Rollup merge of #151666 - Zalathar:query-vtable, r=Kivooeo
compiler: Rename several types/traits for per-query vtables

- Follow-up to https://github.com/rust-lang/rust/pull/151577
---

This is another round of renaming for some subtle types and traits used by the query system, to hopefully make them easier to understand.

Key renames:
- struct `DynamicQuery` → `QueryVTable` (the actual vtable-like structure)
- struct `DynamicQueries` → `PerQueryVTables` (holds a vtable for each query)
- trait `QueryConfig` → `QueryDispatcher`
  - (used by generic functions in `rustc_query_system` to interact with query vtables)
- struct `DynamicConfig` → `SemiDynamicQueryDispatcher`
  - (implements `QueryDispatcher` by combining a vtable with some compile-time boolean flags for improved perf)
- trait `QueryConfigRestored` → `UnerasedQueryDispatcher`
  - (provides a `QueryDispatcher` while also remembering the query's unerased value type; allows some per-query code to be moved out of macros and into generic functions)

This was trickier than `DepKindVTable`, because there are more types and traits involved, and it's harder to come up with distinctive and useful names for all of them.

There should be no change to compiler behaviour.

r? Kivooeo (or compiler)
2026-01-28 19:03:52 +11:00
Stuart Cook
a9118046f4
Rollup merge of #151013 - ehuss:fmt-clarification, r=joboet
Add some clarifications and fixes for fmt syntax

This tries to clarify a few things regarding fmt syntax:

- The comment on `Parser::word` seems to be wrong, as that underscore-prefixed words are just fine. This was changed in https://github.com/rust-lang/rust/pull/66847.
- I struggled to follow the description of the width argument. It referred to a "second argument", but I don't know what second argument it is referring to (which is the first?). Either way, I rewrote the paragraph to try to be a little more explicit, and to use shorter sentences.
- The description of the precision argument wasn't really clear about the distinction of an Nth argument and a named argument. I added a sentence to try to emphasize the difference.
- `IDENTIFIER_OR_KEYWORD` was changed recently in https://github.com/rust-lang/reference/pull/2049 to include bare `_`. But fmt named arguments are not allowed to be a bare `_`.
2026-01-28 19:03:51 +11:00
Stuart Cook
3d102a7812
Rollup merge of #150893 - ZuseZ4:move-un-register-lib, r=oli-obk
offload: move (un)register lib into global_ctors

Right now we initialize the openmp/offload runtime before every single offload call, and tear it down directly afterwards.
What we should rather do is initialize it once in the binary startup code, and tear it down at the end of the binary execution. Here I implement these changes.

Together, our generated IR has a lot less usage of globals, which in turn simplifies the refactoring in https://github.com/rust-lang/rust/pull/150683, where I introduce a new variant of our offload intrinsic.

r? oli-obk
2026-01-28 19:03:51 +11:00
Stuart Cook
f488671fb0
Rollup merge of #151239 - izagawd:comptime-reflection-dyn-trait-variant, r=oli-obk
Support trait objects in type info reflection

Tracking issue: https://github.com/rust-lang/rust/issues/146922

Adds type_info support for trait object types by introducing a DynTrait variant

~~I can't seem to get it to work correctly with `dyn for<'a> Foo<'a>`, though it works fine for normal `dyn Foo` trait objects~~

r? @oli-obk
2026-01-28 19:03:50 +11:00
bors
466ea4e6c3 Auto merge of #150722 - nikic:llvm-22, r=cuviper
Update to LLVM 22

Scheduled release date: Feb 24
1.94 becomes stable: Mar 5

Changes:
 * Update to rc2, with one patch to work around our outdated illumos sysroot (41256ab128).
 * Update the host toolchain as well, otherwise we lose cross-language LTO, in particular for jemalloc.
 * Adjust one loongarch assembly test. The split into r and s variants is based on the suggestion in https://github.com/rust-lang/rust/pull/151134.

Depends on:

 * [x] https://github.com/rust-lang/rust/pull/151410
 * [ ] https://github.com/rust-lang/rust/issues/150756
 * [x] https://github.com/llvm/llvm-project/issues/175190
 * [x] https://github.com/llvm/llvm-project/pull/175912
 * [x] https://github.com/llvm/llvm-project/issues/175965
 * [x] https://github.com/llvm/llvm-project/pull/176195
 * [x] https://github.com/llvm/llvm-project/issues/157073
 * [x] https://github.com/llvm/llvm-project/issues/176421
 * [x] https://github.com/llvm/llvm-project/pull/176925
 * [x] https://github.com/llvm/llvm-project/pull/177187
2026-01-28 08:01:21 +00:00
theiz
a1893d3187 Add support for trait object types in type_info reflection 2026-01-27 19:49:09 -04:00
Jynn Nelson
6165b72b5f Fix x fix, again
This was refactored incorrectly at some point and would run `cargo check`
even for `x fix`.
2026-01-27 17:57:55 -05:00
andrewtkent
31d011a399 Add FileCheck annotations to simplify_match.rs
Remove `skip-filecheck` and add FileCheck directives to verify that GVN
propagates the constant `false` and eliminates the match entirely.

The test now verifies:
- The debug info shows `x` as `const false` (constant propagation)
- No `switchInt` remains (match elimination)
- The function body is just `return` (dead code elimination)
2026-01-27 13:37:31 -08:00
Guillaume Gomez
83dcfc8803 Update browser-ui-test version to 0.23.3 2026-01-27 21:14:25 +01:00
Manuel Drehwald
1f11bf6649 Leave note to drop tgt_init_all_rtls in the future 2026-01-27 10:43:22 -08:00
Manuel Drehwald
35ce8ab120 adjust testcase for new logic 2026-01-27 10:43:21 -08:00
Manuel Drehwald
7eae36f017 Add an early return if handling multiple offload calls 2026-01-27 10:43:03 -08:00
bors
e96bb7e44f Auto merge of #151749 - JonathanBrouwer:rollup-IRCTaVD, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#151161 (std: move time implementations to `sys`)
 - rust-lang/rust#151694 (more `proc_macro` bridge cleanups)
 - rust-lang/rust#151711 (stdarch subtree update)
 - rust-lang/rust#150557 (Don't try to evaluate const blocks during constant promotion)
2026-01-27 17:40:26 +00:00
Jonathan Brouwer
4a0c044c63
Update stderrs 2026-01-27 17:11:47 +01:00
Jonathan Brouwer
53fb684f84
Rollup merge of #150557 - dianne:no-const-block-eval-in-promotion, r=lcnr
Don't try to evaluate const blocks during constant promotion

As of https://github.com/rust-lang/rust/pull/138499, trying to evaluate a const block in anything depended on by borrow-checking will result in a query cycle. Since that could happen in constant promotion, this PR adds a check for const blocks there to stop them from being evaluated.

Admittedly, this is a hack. See https://github.com/rust-lang/rust/issues/124328 for discussion of a more principled fix: removing cases like this from constant promotion altogether. To simplify the conditions under which promotion can occur, we probably shouldn't be implicitly promoting division or array indexing at all if possible. That would likely require a FCW and migration period, so I figure we may as well patch up the cycle now and simplify later.

Fixes rust-lang/rust#150464

I'll also lang-nominate this for visibility. I'm not sure there's much to discuss about this PR specifically, but it does represent a change in semantics. In Rust 1.87, the code below compiled. In Rust 1.88, it became a query cycle error. After this PR, it fails to borrow-check because the temporaries can no longer be promoted.

```rust
let (x, y, z);
// We only promote array indexing if the index is known to be in-bounds.
x = &([0][const { 0 }] & 0);
// We only promote integer division if the divisor is known not to be zero.
y = &(1 / const { 1 });
// Furthermore, if the divisor is `-1`, we only promote if the dividend is
// known not to be `int::MIN`.
z = &(const { 1 } / -1);
// The borrowed temporaries can't be promoted, so they were dropped at the ends
// of their respective statements.
(x, y, z);
```
2026-01-27 17:00:54 +01:00
Jonathan Brouwer
7d11720fd3
Rollup merge of #151711 - folkertdev:stdarch-sync-2026-01-26, r=folkertdev
stdarch subtree update

Subtree update of `stdarch` to 9ba0a3f392.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-01-27 17:00:54 +01:00
Jonathan Brouwer
84bb764741
Rollup merge of #151694 - cyrgani:more-pm-cleanup, r=petrochenkov
more `proc_macro` bridge cleanups

Some followups made possible by rust-lang/rust#151505.
2026-01-27 17:00:53 +01:00
Jonathan Brouwer
80102f389d
Rollup merge of #151161 - joboet:move-pal-time, r=tgross35
std: move time implementations to `sys`

This is probably the most complex step of rust-lang/rust#117276 so far. Unfortunately, quite some of the internal time logic defined in the PAL is also used in other places like the filesystem code, so this isn't just a series of simple moves. I've left all that logic inside the PAL and only moved the actual `SystemTime`/`Instant` implementations.

While there are no functional changes, this PR also contains some slight code cleanups on Windows and Hermit, these are explained in the relevant commits.

For additional details see the individual commits, I've tried to make the messages as helpful as possible about what's going on.
2026-01-27 17:00:52 +01:00
Guillaume Gomez
4ae692df6f Update askama version to 0.15.2 2026-01-27 16:47:26 +01:00
Vadim Petrochenkov
5726e37819 resolve: Replace Macros20NormalizedIdent with IdentKey 2026-01-27 18:11:52 +03:00
dianne
4039cef09e Don't evaluate const blocks in constant promotion 2026-01-27 04:31:57 -08:00
Jonathan Brouwer
c8975a2468
Add extern core to diagnostic tests 2026-01-27 13:05:27 +01:00
Nikita Popov
e015fc820d Adjust loongarch assembly test
This generates different code on loongarch32r now.
2026-01-27 12:09:39 +01:00
Nikita Popov
749a27975c Update host toolchain 2026-01-27 12:09:39 +01:00
Nikita Popov
3510a9ad0c Update to LLVM 22 2026-01-27 12:09:39 +01:00
Zalathar
2c9175d73d Rename trait QueryConfig to QueryDispatcher 2026-01-27 21:58:29 +11:00
Zalathar
89d7695040 Rename DynamicQuery to QueryVTable 2026-01-27 21:57:18 +11:00
bors
94a0cd15f5 Auto merge of #151683 - Zalathar:compiler-kind, r=jieyouxu
compiletest: Add `CompilerKind` to distinguish between rustc and rustdoc

This PR slightly improves `TestCx::make_compile_args` by using `CompilerKind` to explicitly distinguish between rustc and rustdoc.

The resulting code could still use more attention, but I think this is a good incremental improvement.

There *should* (hopefully) be no change to overall compiletest behaviour.
2026-01-27 10:12:01 +00:00
joboet
5a98a51987
hardcode some Windows constants in miri
The `std` paths are subject to change, but the values themselves will never
change.
2026-01-27 10:52:25 +01:00
joboet
fe51f9debc
std: move time implementations to sys (Hermit)
Last on the list: Hermit. Since I anticipate that Hermit will share the UNIX
implementation in the future, I've left `Timespec` in the PAL to maintain a
similar structure. Also, I noticed that some public `Instant` methods were
redefined on the internal `Instant`. But the networking code can just use the
public `Instant`, so I've removed them.
2026-01-27 10:52:25 +01:00
joboet
eec058eacc
std: move time implementations to sys (WASI/TEEOS)
WASI and TEEOS share the UNIX implementation. Since `Timespec` lives in the
PAL, this means that the `#[path]` imports of `unix/time.rs` still remain for
these two, unfortunately. Maybe we'll solve that in the future by always
including the UNIX PAL for these remotely UNIXy platforms. But that's a story
for another time...
2026-01-27 10:52:25 +01:00
joboet
05bbfa2593
std: move time implementations to sys (UNIX)
Now for UNIX: `Timespec` is also used for things like futex or `Condvar`
timeouts, so it stays in the PAL along with some related definitions.
Everything else is `SystemTime`- and `Instant`-specific, and is thus moved to
`sys::time`.
2026-01-27 10:52:25 +01:00
joboet
6cb343bfb2
std: move time implementations to sys (Windows)
Windows has a similar problem as UEFI: some internals are also used for
implementing other things. Thus I've left everything except for the actual
`Instant` and `SystemTime` implementations inside the PAL.

I've also taken the liberty of improving the code clarity a bit: there were a
number of manual `SystemTime` conversions (including one that masked an `i64`
to 32-bits before casting to `u32`, yikes) that now just call `from_intervals`.
Also, defining a `PerformanceCounterInstant` just to convert it to a regular
`Instant` immediately doesn't really make sense to me. I've thus changed the
`perf_counter` module to contain only free functions that wrap system
functionality. The actual conversion now happens in `Instant::now`.
2026-01-27 10:28:06 +01:00
joboet
963f6029ce
std: move time implementations to sys (UEFI)
Next up: UEFI. Unfortunately the time conversion internals are also required by
the filesystem code, so I've left them in the PAL. The `Instant` internals
however are only used for the `Instant` implementation, so I've moved them to
`sys` (for now).
2026-01-27 10:27:59 +01:00
joboet
bd754c7119
std: move time implementations to sys (Solid)
On SOLID, the conversion functions are also used to implement helpers for
timeout conversion, so these stay in the PAL. The `Instant` (µITRON) and
`SystemTime` (SOLID-specific) implementations are merged into one. While it was
nice to have the µITRON parts in a separate module, there really isn't a need
for this currently, as there is no other µITRON target. Let's not worry about
this until such a target gets added...

Note that I've extracted the `get_tim` call from `Instant` into a wrapper
function in the PAL to avoid the need to make the inner `Instant` field public
for use in the PAL.
2026-01-27 10:27:43 +01:00
joboet
5978e19456
std: move time implementations to sys (VEX)
Now that the `unsupported` module exists, we can use it for VEX. VEX actually
supports `Instant` though, so the implementation-select needs to combine that
with the `unsupported` module.
2026-01-27 10:27:30 +01:00
joboet
29b16c0a55
std: move time implementations to sys (small platforms)
Let's start with the easy ones:
* Motor just reexports its platform library
* The SGX code is just a trivial move
* Trusty, WASM and ZKVM are unsupported, this is very trivial. And we can get
  rid of some `#[path = ...]`s, yay!
2026-01-27 10:26:54 +01:00
joboet
814d902c50
std: move time implementations to sys (preparation) 2026-01-27 10:26:45 +01:00
Scott McMurray
51de309db2 Tweak SlicePartialEq to allow MIR-inlining the compare_bytes call
150265 disabled this because it was a net perf win, but let's see if we can tweak the structure of this to allow more inlining on this side while still not MIR-inlining the loop when it's not just `memcmp`.

This should also allow MIR-inlining the length check, which was previously blocked.
2026-01-27 00:10:12 -08:00
bors
78df2f92de Auto merge of #151727 - Zalathar:rollup-goIJldt, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#151692 (Try to reduce rustdoc GUI tests flakyness)
 - rust-lang/rust#147436 (slice/ascii: Optimize `eq_ignore_ascii_case` with auto-vectorization)
 - rust-lang/rust#151390 (Reintroduce `QueryStackFrame` split.)
 - rust-lang/rust#151097 (Use an associated type default for `Key::Cache`.)
 - rust-lang/rust#151702 (Omit standard copyright notice)
2026-01-27 06:37:15 +00:00
Stuart Cook
6ec16a4099
Rollup merge of #151702 - xtqqczze:omit-copyright-notice, r=jieyouxu
Omit standard copyright notice

Remove copyright notices for files licensed under the standard terms (MIT OR Apache-2.0).
2026-01-27 17:36:37 +11:00