9916 Commits

Author SHA1 Message Date
Josh Stone d0b5e61fe7 Revert "Stabilize assert_matches"
This reverts commit 2f3b952349.
2026-04-08 14:10:50 -07:00
León Orell Valerian Liehr bdc1b3ffa8 [beta] Don't look for non-type-level assoc consts when checking trait object types 2026-03-17 01:54:26 +01:00
Jonathan Brouwer 3eafea8d3a Rollup merge of #153120 - Zalathar:execute, r=nnethercote
Clean up some code related to `QueryVTable::execute_query_fn`

This PR is an assortment of small cleanups to code that interacts with `execute_query_fn` in the query vtable.

I also experimented with trying to replace the macro-generated `__rust_end_short_backtrace` functions with a single shared generic function, but I couldn't manage to avoid breaking short backtraces, so I left a note behind to document my attempt.

r? nnethercote (or compiler)
2026-02-26 09:57:06 +01:00
Jonathan Brouwer 8386f94903 Rollup merge of #153112 - nnethercote:query-key-stuff, r=nnethercote
Query key cleanups

The first three commits are simple. The last two are a bit more opinionated, see what you think.

r? @Zalathar
2026-02-26 09:57:05 +01:00
Jonathan Brouwer c902bc1c7c Rollup merge of #153091 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Migration of `LintDiagnostic` - part 4

Follow-up of:
* https://github.com/rust-lang/rust/pull/152933
* https://github.com/rust-lang/rust/pull/153016
* rust-lang/rust#153051

More `LintDiagnostic` items being migrated to `Diagnostic`. Since there is no remaining `emit_node_span_lint` calls, I replaced the method with the code of `emit_diag_node_span_lint`.

r? @JonathanBrouwer
2026-02-26 09:57:04 +01:00
Jonathan Brouwer 90c93ab7c1 Move rustc_ast::AutoDiffAttrs to rustc_hir::RustcAutodiff 2026-02-26 09:41:21 +01:00
Guillaume Gomez 3f71fd001a Add new LintContext::opt_span_diag_lint and LintContext::emit_diag_lint methods 2026-02-26 09:31:30 +01:00
Guillaume Gomez 5edbf6a9f9 Remove unused TyCtxt::emit_node_lint method 2026-02-26 09:31:29 +01:00
Nicholas Nethercote 9ba101f44a Rename Storage as Cache.
Because `Storage` is a vague name that I've never liked.
2026-02-26 19:18:51 +11:00
Nicholas Nethercote 44994072d3 Merge trait QueryCacheKey into trait QueryKey.
We have two traits governing query keys, for no particular reason.
This commit combines them.
2026-02-26 19:18:51 +11:00
Nicholas Nethercote b284b04cc3 Remove unnecessary Clone bounds. 2026-02-26 19:18:51 +11:00
Nicholas Nethercote fbea6ddcd2 Rename trait Key as trait QueryKey`
Because `Key` is extremely generic and hard to search for.

Also rename `LocalKey` and `AsLocalKey` similarly, for consistency.
2026-02-26 19:18:48 +11:00
Nicholas Nethercote 6ba5b1ad9c Move trait DepNodeKey.
It's currently in `dep_node.rs`, along with a blanket impl. Specific
impls are in `dep_node_key.rs`. This commit moves the trait and the
blanket impl into `dep_node_key.rs`, so everything is in one place.
2026-02-26 19:09:46 +11:00
Zalathar cd7bbac7c6 Add some docs for QueryVTable::execute_query_fn
This function is tricky to document, and there's more that could be said here,
but I don't want to take up too much vertical space, or add too much risk of
details becoming inaccurate over time.
2026-02-26 18:53:50 +11:00
Zalathar 508801c95d Pass the QueryVTable to functions that were taking execute_query_fn
All three of these functions were previously taking `cache` and
`execute_query_fn` as separate arguments, but after some other recent
simplifications we can just pass `&'tcx QueryVTable<'tcx, C>` instead.

This makes it easier to see where `execute_query_fn` is actually called.
2026-02-26 17:39:31 +11:00
Jacob Pratt 236327e901 Rollup merge of #153092 - mu001999-contrib:cleanup/redundant-self, r=JonathanBrouwer
Remove redundant self usages

Extracted from https://github.com/rust-lang/rust/pull/152996.

r? petrochenkov
2026-02-25 21:42:58 -05:00
Jacob Pratt 49a98857e1 Rollup merge of #153078 - nnethercote:rm-QuerySystemFns, r=petrochenkov
Remove `QuerySystemFns`

Two small query-related cleanups.

r? petrochenkov
2026-02-25 21:42:54 -05:00
mu001999 ff0f239bb1 Remove redundant self usages 2026-02-25 22:51:53 +08:00
Nicholas Nethercote 608d85f989 Move two functions into hooks.
`QuerySystem` has two function pointers: `encode_query_results` and
`try_mark_green`. These exist so that `rustc_middle` can call functions
from upstream crates.

But we have a more general mechanism for that: hooks. So this commit
converts these two cases into hooks.
2026-02-25 17:30:47 +11:00
Nicholas Nethercote b76b26db3b Remove QuerySystemFns.
It has a single use and doesn't provide any real value. Removing it
allows the removal of two `for<'tcx>` qualifiers.
2026-02-25 17:30:17 +11:00
bors 58745ca3b0 Auto merge of #153074 - jhpratt:rollup-6aKDmTD, r=jhpratt
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#149169 (ptr::replace: make calls on ZST null ptr not UB)
 - rust-lang/rust#150562 (Fix doc link used in suggestion for pinning self)
 - rust-lang/rust#152418 (`BTreeMap::merge` optimized)
 - rust-lang/rust#152679 (rustc_expand: improve diagnostics for non-repeatable metavars)
 - rust-lang/rust#152952 (mGCA: improve ogca diagnostic message )
 - rust-lang/rust#152977 (Fix relative path handling for --extern-html-root-url)
 - rust-lang/rust#153017 (Implement debuginfo for unsafe binder types)
 - rust-lang/rust#152868 (delete some very old trivial `Box` tests)
 - rust-lang/rust#152922 (rustc_public: Make fields that shouldn't be exposed visible only in `rustc_public`)
 - rust-lang/rust#153032 (Fix attribute parser and kind names.)
 - rust-lang/rust#153051 (Migration of `LintDiagnostic` - part 3)
 - rust-lang/rust#153060 (Give a better error when updating a submodule fails)
2026-02-25 05:49:40 +00:00
Nicholas Nethercote 4a5ee0421f Rename PerQueryVTables as QueryVTables.
The `Per` isn't really necessary.
2026-02-25 08:26:28 +11:00
Nicholas Nethercote 2bc5167e99 Merge QueryEngine into QueryVTable.
`QueryEngine` is a struct with one function pointer per query. This
commit removes it by moving each function pointer into the relevant
query's vtable, which is already a collection of function pointers for
that query. This makes things simpler.
2026-02-25 08:26:27 +11:00
Nicholas Nethercote 06cd823158 Rename some Cache type variables as C.
Currently type variables that impl `QueryCache` are called either `C` or
`Cache`. I find the former clearer because single char type variables
names are very common and longer type variable names are easy to mistake
for type or trait names -- e.g. I find the trait bound `C: QueryCache`
much easier and faster to read than `Cache: QueryCache`.
2026-02-25 08:26:26 +11:00
Nicholas Nethercote e45224c4af Improve how QueryCaches and QueryStates are stored.
`QuerySystem` has these fields:
```
pub states: QueryStates<'tcx>,
pub caches: QueryCaches<'tcx>,
pub query_vtables: PerQueryVTables<'tcx>,
```
Each one has an entry for each query.

Some methods that take a query-specific `QueryVTable` need to access the
corresponding query-specific states and/or caches. So `QueryVTable`
stores the *byte offset* to the relevant fields within `states` and
`caches`, and uses that to (with `unsafe`) access the fields. This is
bizarre, and I hope it made sense in the past when the code was
structured differently.

This commit moves `QueryState` and `QueryCache` inside `QueryVTable`. As
a result, the query-specific states and/or caches are directly
accessible, and no unsafe offset computations are required. Much simpler
and more normal. Also, `QueryCaches` and `QueryStates` are no longer
needed, which makes `define_callbacks!` a bit simpler.

The commit also rename the fields and their getters to `states` and
`caches`.
2026-02-25 08:13:56 +11:00
Guillaume Gomez 8fa1fca9f6 Apply new change from lint_level into diag_lint_level 2026-02-24 20:34:23 +01:00
Guillaume Gomez 2bb3b01af2 Replace TyCtxt::emit_node_span_lint with emit_diag_node_span_lint 2026-02-24 20:34:22 +01:00
Guillaume Gomez 8f63c00038 Migrate rustc_passes to use TyCtxt::emit_diag_node_span_lint 2026-02-24 20:12:43 +01:00
Jonathan Brouwer 68bff20d1d Rollup merge of #153033 - Zalathar:ensure, r=nnethercote
Clarify how "ensure" queries check whether they can skip execution

The current `check_cache: bool` field in QueryMode is confusing for a few reasons:

- It actually refers to checking the *disk cache*, not the in-memory cache.
- It gives no indication of what condition is being checked, or why.
- It obscures the link between `tcx.ensure_ok()` and `tcx.ensure_done()`, and the actual check.

This PR replaces that field with an `EnsureMode` enum that distinguishes between ensure-ok and ensure-done, and leaves the actual check as an implementation detail of the ensure-done mode.

This PR also renames `ensure_must_run` → `check_if_ensure_can_skip_execution`, and uses a return struct to more clearly indicate how this helper function gives permission for its caller to skip execution of a query that would otherwise be executed. This also inverts the sense of the returned boolean, which was previously “must run” but is now ”skip execution”.

r? nnethercote (or compiler)
2026-02-24 14:41:58 +01:00
Jonathan Brouwer 0c18ab7ea8 Rollup merge of #153009 - nnethercote:rm-define_feedable, r=oli-obk
Remove `rustc_feedable_queries` and `define_feedable` macros.

The can be folded into `rustc_with_all_queries` and `define_callbacks`. Details in individual commits.

r? @oli-obk
2026-02-24 14:41:53 +01:00
Zalathar bf0f5115c3 Clarify how "ensure" queries check whether they can skip execution 2026-02-24 15:19:38 +11:00
bors 0028f344ce Auto merge of #153026 - JonathanBrouwer:rollup-PAPpAYW, r=JonathanBrouwer
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#153007 (`rust-analyzer` subtree update)
 - rust-lang/rust#152670 (Simplify ThinLTO handling)
 - rust-lang/rust#152768 (Enable autodiff in ci for all major os)
 - rust-lang/rust#152908 (Enable rust.remap-debuginfo in the dist profile)
 - rust-lang/rust#152999 (Check importing `crate`/`$crate`/`super` after handling `self`)
 - rust-lang/rust#152003 (Reflection TypeId::trait_info_of)
 - rust-lang/rust#152976 (Revert relative paths for std links in rustc-docs)
 - rust-lang/rust#152985 (Port `#[feature]` to the new attribute system)
 - rust-lang/rust#152989 (Port `#[rustc_inherit_overflow_checks]` to the new attribute parsers)
 - rust-lang/rust#152991 (fix interpreter tracing output)
 - rust-lang/rust#153004 (Superficial tweaks to the query modifier docs in `rustc_middle::query::modifiers`)
 - rust-lang/rust#153008 (bootstrap.compiler.toml: update name of primary branch)
 - rust-lang/rust#153016 (Migration of `LintDiagnostic` - part 2)
 - rust-lang/rust#153020 (rustdoc: Improve sentence for documented empty impl blocks)

Failed merges:

 - rust-lang/rust#152988 (Port `#[register_tool]` to the new attribute system)
2026-02-24 03:43:46 +00:00
Nicholas Nethercote 8ac769f9d0 Remove rustc_feedable_queries and define_feedable macros.
`rustc_queries!` produces two macros: `rustc_with_all_queries` and
`rustc_feedable_queries`. The latter is similar to the former but only
includes feedable queries.

But feedable queries don't need a separate mechanism because we can
identify feedable queries within `define_callbacks!` by just looking for
the `feedable` modifier. (That's what we do with every modifier other
than `feedable`.)

This commit removes the special handling and treats feedable queries
like everything else.

Note that this commit exposes and fixes a latent doc bug. The doc
comment for query `explicit_predicates_of` links to
`Self::predicates_of`. `explicit_predicates_of` is a feedable query but
`predicates_of` is not, so for `TyCtxtFeed` this link is invalid. This
wasn't manifesting because `TyCtxtFeed` wasn't getting doc comments
attached. It now is, so I changed the link to `TyCtxt::predicates_of`.
2026-02-24 08:09:44 +11:00
Jonathan Brouwer b55a3e403b Rollup merge of #153016 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer,Kivooeo
Migration of `LintDiagnostic` - part 2

Follow-up of https://github.com/rust-lang/rust/pull/152933.

More `LintDiagnostic` items being migrated to `Diagnostic`.

r? @JonathanBrouwer
2026-02-23 20:46:15 +01:00
Jonathan Brouwer 5370cdd88f Rollup merge of #153004 - Zalathar:tweak-modifiers, r=wesleywiser
Superficial tweaks to the query modifier docs in `rustc_middle::query::modifiers`

This PR sorts the dummy items in the `modifiers` module, makes them non-pub to speed up find-all-references, and adds some extra explanation of what the dummy modifier items are for.

(These dummy items mostly just exist to carry documentation, and have no actual effect on compiler behaviour.)
2026-02-23 20:46:14 +01:00
Jonathan Brouwer 5835df0f03 Rollup merge of #152991 - RalfJung:interpret-step-trace, r=Kivooeo
fix interpreter tracing output

https://github.com/rust-lang/rust/pull/144708 accidentally changed the output of `MIRI_LOG=info <miri run>` in two ways:
- by adding `stmt=`/`terminator=` prefixes
- by changing the statement printing to be a verbose debug version instead of MIR pretty-printing

This fixes both of these:
- use explicit format strings to avoid the prefixes
- fix inconsistency in Debug impls for MIR types: now both TerminatorKind and StatementKind are pretty-printed, and Terminator and Statement just forward to the *Kind output
2026-02-23 20:46:14 +01:00
bors b3869b94cd Auto merge of #152791 - nnethercote:rm-const-FLAGS, r=Zalathar
Remove `const FLAGS`.

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152791)*

The performance wins provided by these types are meagre, and I don't think they justify the code complexity they introduce.

r? @Zalathar
2026-02-23 19:11:54 +00:00
Guillaume Gomez 266fe958ed Return earlier in diag_lint_level to prevent cases where a printed ty in a Diagnostic message is not emitted 2026-02-23 15:20:04 +01:00
Guillaume Gomez 9436e6e7d0 Add TyCtxt::emit_diag_node_span_lint method 2026-02-23 11:30:53 +01:00
bors eeb94be79a Auto merge of #149366 - cjgillot:gvn-primitive, r=RalfJung
GVN: consider constants of primitive types as deterministic

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/149366)*

GVN separates MIR constants into deterministic and non-deterministic constants. Deterministic constants are defined here as: gives the exact same value each time it is evaluated.

This was mainly useful because of `ConstValue::Slice` that generated an extra `AllocId` each time it appeared in the MIR. That variant has been removed. This is still useful for valtrees that hold references, which generate a fresh `AllocId` for each evaluation.

This PR proposes to consider all constants of primitive type to be deterministic. If a constant of primitive type passes validation, then it does not contain provenance, so we have no risk of having a reference becoming different `AllocId`s. In particular, valtrees only are leaves.

r? @ghost for perf
2026-02-23 06:19:36 +00:00
Zalathar e9ee5f869c More explanation of what the dummy items in modifiers are for 2026-02-23 15:59:28 +11:00
Zalathar ab0576b7fe Make dummy modifier items non-pub
This massively speeds up find-all-references in rust-analyzer, from taking
several seconds to being near-instant.
2026-02-23 15:59:28 +11:00
Zalathar 446d1e14c5 Sort rustc_middle::query::modifiers 2026-02-23 15:59:28 +11:00
Stuart Cook 8c96521c99 Rollup merge of #152987 - Zoxc:hashstable-derives, r=JonathanBrouwer
Use `HashStable` derive in more places

This applies `HashStable` derive in a couple more places. Also `stable_hasher` is declared for `HashStable_NoContext`.
2026-02-23 13:32:01 +11:00
John Kåre Alsaker 9f7d502d64 Remove deterministic picking from query cycle handling 2026-02-23 01:31:59 +01:00
Ralf Jung 5b87b994d8 fix interpreter tracing output 2026-02-22 22:38:46 +01:00
Nicholas Nethercote 6c12694b64 Remove SemiDynamicQueryDispatcher and QueryFlags.
`SemiDynamicQueryDispatcher` is just a `QueryVTable` wrapper with an
additional `const FLAGS: QueryFlags` generic parameter that contains
three booleans. This arrangement exists as a performance optimization.
But the performance effects are very small and it adds quite a bit of
complexity to an already overly-complex part of the codebase. If it
didn't exist and somebody proposed adding it and asked me to review, I
almost certainly wouldn't approve it.

This commit removes it. The three booleans in `QueryFlags` are moved
into `QueryVTable` The non-trivial methods of
`SemiDynamicQueryDispatcher` become methods of `QueryVTable`.
2026-02-23 07:20:21 +11:00
John Kåre Alsaker 912c7d31d2 Use HashStable derive in more places 2026-02-22 21:01:27 +01:00
Camille Gillot 38c68517c1 Move methods to gvn.rs.
Elaborate comments.

Co-authored-by: Ralf Jung <post@ralfj.de>
2026-02-22 19:43:57 +00:00
Camille Gillot 4953a8bc12 Constants of primitive types are always deterministic. 2026-02-22 19:43:57 +00:00