Commit Graph

665 Commits

Author SHA1 Message Date
Nicholas Nethercote
86c2ea09e1 Remove the crate's doc comment
It's out of date.
2026-08-11 12:54:31 +10:00
Nicholas Nethercote
d6c550356a Rename profiling_support.rs as self_profile.rs
It's a clearer name.
2026-08-11 12:54:24 +10:00
Nicholas Nethercote
ae1b655c80 Move some job-related stuff into job.rs 2026-08-11 12:54:24 +10:00
Nicholas Nethercote
b99843c7a2 Move GetQueryVTable into query_vtables.rs
It's a more sensible home than `lib.rs`.
2026-08-11 12:54:24 +10:00
Nicholas Nethercote
04df355d86 Rename plumbing.rs as incremental.rs
Because it now contains only things related to incremental. Also move
two functions relating to incremental from `execution.rs` to
`incremental.rs`.
2026-08-11 12:54:24 +10:00
Nicholas Nethercote
c0b0065f06 Move four functions from plumbing.rs to execution.rs
These four functions are all only used within `execution.rs`, so they no
longer need `pub(crate)`.

This is the first step toward eliminating `plumbing.rs`.
2026-08-11 12:54:24 +10:00
Nicholas Nethercote
9e37f3950e Rename query_impl.rs as query_vtables.rs
The current name is very generic and the file is mostly about query
vtables.
2026-08-11 12:54:24 +10:00
Nicholas Nethercote
9e2147f559 Move create_cycle_error to mod handle_cycle_error
It's a more sensible home than `mod job`.
2026-08-11 12:54:24 +10:00
Nicholas Nethercote
0f7dbc062c Fix a use item
`lib.rs` imports `DepNode`/`DepNodeIndex` even though it doesn't use
them directly. And then `execution.rs` uses that one. Weird.

This commit fixes things to be more normal.
2026-08-11 12:54:24 +10:00
Chris Denton
4641990929 Remove ensure_sufficient_stack 2026-08-09 19:58:29 +00:00
Jonathan Brouwer
57a359351d Rename rustc_query_impl/error.rs to diagnostics.rs 2026-08-08 14:50:23 +02:00
Jonathan Brouwer
8c0bfd589a Rollup merge of #160130 - xmakro:cleanup/deterministic-verify-sampling, r=cjgillot
Select cache values to verify by key fingerprint, not value fingerprint

rustc verifies ~1/32 of values loaded from the incremental cache by re-hashing them. The subset is selected by the value fingerprint, so it changes whenever a value changes and between any two compiler builds. That makes verification failures flaky to reproduce, and it moves the re-hashing cost around between the two builds rustc-perf compares, which is why rustc-perf forces `-Zincremental-verify-ich` on every benchmarked invocation.

This PR selects by the key fingerprint and the session count instead. Both are fixed for a given previous session, so re-running a failed build verifies the same nodes and a verification failure reproduces on retry. `to_smaller_hash` mixes both fingerprint halves because neither half is evenly distributed on its own: `DefPathHash` keys share the `StableCrateId`, `HirId` keys carry a sequential id.

The per-session sampling rate is unchanged at 1/32, and `-Zincremental-verify-ich` is unchanged. Coverage over time improves: the subset rotates with the session count and sweeps the entire cache every 32 sessions, while under value selection a node whose value never changed kept its roll forever, so 31/32 of unchanging values were never verified on a given toolchain.

Between two compiler builds the subset still differs, because key fingerprints incorporate the rustc version through `StableCrateId`. Pinning the version via `RUSTC_FORCE_RUSTC_VERSION` and `RUSTC_OVERRIDE_VERSION_STRING` makes corresponding sessions identical; session counts align because both builds run the same scenario sequence from a fresh incremental directory. That would let rustc-perf stop forcing full verification and measure the incremental configuration users actually run.

Coverage across compiler releases is unchanged: the version salt reshuffles the subset each release under either scheme, and compiletest forces full verification in all incremental tests.
2026-08-05 13:36:03 +02:00
Vadim Petrochenkov
2b4375dadc rustc: Support --jobs options for limiting parallelism in various parts of the compiler 2026-07-29 15:22:16 +03:00
Makro
012c35624e Select cache values to verify by key fingerprint, not value fingerprint 2026-07-29 09:00:38 +00:00
Jonathan Brouwer
0a1a25a0b6 Rollup merge of #159990 - nnethercote:predicate-to-clause, r=oli-obk
Many "predicate"-to-"clause" renamings

Lots of names weren't changed to account for the introduction of the `Clause` type as a specialized form of `Predicate`, presumably because it was tedious. This commit converts as many of them as I could find. It's mostly very tedious renamings of types, functions, variables, and queries. The more interesting ones are a couple of files (`predicates_of.rs`, `impossible_predicates.rs`) and a MIR pass (`ImpossiblePredicates`).

r? @oli-obk
2026-07-28 21:07:39 +02:00
Nicholas Nethercote
ff161b18b5 Many "predicate"-to-"clause" renamings
Lots of names weren't changed to account for the introduction of the
`Clause` type as a specialized form of `Predicate`, presumably because
it was tedious. This commit converts as many of them as I could find.
It's mostly very tedious renamings of types, functions, variables, and
queries. The more interesting ones are a couple of files
(`predicates_of.rs`, `impossible_predicates.rs`) and a MIR pass
(`ImpossiblePredicates`).
2026-07-28 11:48:45 +10:00
xmakro
1d85e5957b Skip query machinery when promoting disk-cached values 2026-07-23 20:13:41 +00:00
mejrs
ac91844c53 Fixup Limit imports 2026-07-21 15:26:08 +02:00
Daria Sukhonina
c60e5614e1 rustc: Avoid passing jobserver proxy around the compiler
It is used once, when marking a `rustc_thread_pool` worker thread as blocked.
`rustc_thread_pool` already has access to the jobserver proxy, so we can move its use from outside of `mark_blocked` to inside of it.
2026-07-16 17:22:47 +03:00
Jacob Pratt
c997ea45be Rollup merge of #158163 - xmakro:fix-variances-cycle-recovery-count, r=petrochenkov
Fix too-short variance slice in `variances_of` cycle recovery

This changes the cycle-error fallback in `variances_of` to size the slice the same way the provider does in [`variance/solve.rs:117`](32ea3615cc/compiler/rustc_hir_analysis/src/variance/solve.rs (L117)).

This can otherwise ICE under the parallel frontend in `relate_args_with_variances` for items that inherit their generics from a parent (like a tuple struct constructor). See https://github.com/rust-lang/rust/issues/154560#issuecomment-4749155547
2026-06-27 22:13:50 -04:00
Adwin White
3dbe96a5a1 add IsRigid marker to TyKind::Alias and constants 2026-06-25 17:12:10 +08:00
xmakro
c2c6cb43e8 Fix too-short variance slice in variances_of cycle recovery 2026-06-19 19:54:29 -07:00
John Kåre Alsaker
218a0755ae Remove ensure_done execution path 2026-06-13 01:28:47 +02:00
Esteban Küber
2c7186a725 Reduce verbosity of cycle errors when possible
When pointing at each step of cycle errors, do not include the code snippet when the note points at the same place as the previous one (by setting the note's span to DUMMY_SP).
2026-06-04 16:10:12 +00:00
xmakro
2a52dc4fbe Avoid leaking the query-job collection warning into panic output
`collect_active_query_jobs` with `CollectActiveJobsKind::PartialAllowed`
is only used to print the query stack when the compiler panics. It
intentionally skips any query state shard whose lock it cannot take
without waiting, since a complete job map is not needed for that.

Under the parallel front-end another thread can still hold a shard lock
while the panic is being reported, so the skip happens nondeterministically
and the `warn!` was printed into the panic output. Because warnings are
shown by default, this leaked a "Failed to collect active jobs" line into
the diagnostics of panicking compilations and made their output unstable.

Lower the message to `debug!` so it stays available with `RUSTC_LOG` but
no longer pollutes the default output.
2026-06-02 18:13:50 -07:00
Daria Sukhonina
9d82fcee10 Formatter 2026-05-26 12:01:50 +03:00
Daria Sukhonina
0a36812006 Fix and update changes 2026-05-26 12:01:03 +03:00
Daria Sukhonina
76c099caf4 Rename helper QueryVTable method back 2026-05-26 11:50:32 +03:00
Daria Sukhonina
239e4dd9e8 Remove will_cache_on_disk_for_key_fn and AsLocalQueryKey 2026-05-26 11:42:48 +03:00
John Kåre Alsaker
8aafed8a17 Add sync option to -Z threads to force synchronization on one thread 2026-05-07 02:06:18 +02:00
teor
dafb6bb801 Refactor FnDecl and FnSig flags into packed structs 2026-04-16 07:08:08 +10:00
bors
17584a1819 Auto merge of #155253 - JonathanBrouwer:rollup-lERdTAB, r=JonathanBrouwer
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155162 (relnotes for 1.95)
 - rust-lang/rust#140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - rust-lang/rust#153604 (Fix thread::available_parallelism on WASI targets with threads)
 - rust-lang/rust#154193 (Implement EII for statics)
 - rust-lang/rust#154389 (Add more robust handling of nested query cycles)
 - rust-lang/rust#154435 (resolve: Some import resolution cleanups)
 - rust-lang/rust#155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - rust-lang/rust#155243 (cg_ssa: transmute between scalable vectors)
 - rust-lang/rust#153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - rust-lang/rust#154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - rust-lang/rust#154624 (Make `DerefPure` dyn-incompatible)
 - rust-lang/rust#154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - rust-lang/rust#154944 (Small refactor of `arena_cache` query values)
 - rust-lang/rust#155055 (UI automation)
 - rust-lang/rust#155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - rust-lang/rust#155131 (Stabilize feature `uint_bit_width`)
 - rust-lang/rust#155147 (Stabilize feature `int_lowest_highest_one`)
 - rust-lang/rust#155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - rust-lang/rust#155194 (Fix manpage version replacement and use verbose version)
2026-04-13 18:32:47 +00:00
Jonathan Brouwer
2f607ee662 Rollup merge of #153997 - nnethercote:closure-consistency, r=petrochenkov
Use closures more consistently in `dep_graph.rs`.

This file has several methods that take a `FnOnce() -> R` closure:
- `DepGraph::with_ignore`
- `DepGraph::with_query_deserialization`
- `DepGraph::with_anon_task`
- `DepGraphData::with_anon_task_inner`

It also has two methods that take a faux closure via an `A` argument and a `fn(TyCtxt<'tcx>, A) -> R` argument:
- DepGraph::with_task
- DepGraphData::with_task

The rationale is that the faux closure exercises tight control over what state they have access to. This seems silly when (a) they are passed a `TyCtxt`, and (b) when similar nearby functions take real closures. And they are more awkward to use, e.g. requiring multiple arguments to be gathered into a tuple. This commit changes the faux closures to real closures.

r? @Zalathar
2026-04-13 14:02:35 +02:00
John Kåre Alsaker
6442b48dee Add more robust handling of nested query cycles 2026-04-12 14:38:43 +02:00
Jonathan Brouwer
79a4c77744 Rollup merge of #155080 - nnethercote:salvage, r=petrochenkov
Simplify `try_load_from_disk_fn`.

`try_load_from_disk_fn` has a single call site. We can move some of the stuff within it to its single call site, which simplifies it, and also results in all of the query profiling code ending up in the same module. Details in individual commits.

r? @Zalathar
2026-04-10 15:33:10 +02:00
Nicholas Nethercote
4fb83f6e56 Move profiling of query loading outwards.
From `plumbing.rs` to `execution.rs`, which is where most of the other
query profiling occurs. It also avoids eliminates some fn parameters.

This means the `provided_to_erased` call in `try_from_load_disk_fn` is
now included in the profiling when previously it wasn't. This is
good because `provided_to_erased` is included in other profiling calls
(e.g. calls to `invoke_provider_fn`).
2026-04-10 14:00:28 +10:00
Nicholas Nethercote
3afb618592 Move the cache_on_disk check out of try_load_from_disk_fn.
It doesn't need to be in there, it can instead be at the single call
site. Removing it eliminates one parameter, makes `define_queries!`
smaller (which is always good), and also enables the next commit which
tidies up profiling.

This commit also changes how `value` and `verify` are initialized,
because I don't like the current way of doing it after the declaration.
2026-04-10 13:47:27 +10:00
John Kåre Alsaker
690d1938a7 Break a single query cycle in the deadlock handler 2026-04-08 20:43:31 +02:00
Jonathan Brouwer
180f3237d4 Rollup merge of #154146 - Zoxc:cycle-split-diag, r=petrochenkov
Split out the creation of `Cycle` to a new `process_cycle` function

This splits out the creation of `CycleError` to a new `process_cycle` function. This makes it a bit clearer which operations are done for diagnostic purposes vs. what's needed to break cycles.
2026-04-07 17:26:21 +02:00
Jonathan Brouwer
20bed53566 Rollup merge of #153999 - Zoxc:rem-TaggedQueryKey-def_kind-uses, r=petrochenkov
Remove `TaggedQueryKey::def_kind`

This removes `TaggedQueryKey::def_kind` by accessing the relevant query keys directly.
2026-04-07 17:26:20 +02:00
Nicholas Nethercote
15c6e6e092 Add a handle_cycle_error query modifier.
This modifier indicates that a query has a custom handler for cycles.
That custom handler must be found at
`rustc_query_impl::handle_cycle_error::$name`.

This eliminates the need for `specialize_query_vtables`, which is the
current hack to install custom handlers. It's more lines of code in
total, but indicating special treatment of a query via a modifier in
`queries.rs` is more consistent with how other aspects of queries are
handled.
2026-04-03 13:44:12 +11:00
Nicholas Nethercote
d913766757 Remove the _description_fns module.
`rustc_queries` generates a macro and two modules. One of the modules
looks like this:
```
mod _description_fns {
    ...

    #[allow(unused_variables)]
    pub fn hir_module_items<'tcx>(tcx: TyCtxt<'tcx>, key: LocalModDefId) -> String {
	format!("getting HIR module items in `{}`", tcx.def_path_str(key))
    }

    ...
}
```
Members of this module are then used in `TaggedQueryKey::description`.

This commit removes the `_description_fns` module entirely. For each
query we now instead generate a description closure that is used
instead. This closure is passed in the modifiers list.

This change simplifies `rustc_queries` quite a bit. It requires adding
another query modifier, but query modifiers are how other query-specific
details are already passed to the declarative macros, so it's more
consistent.
2026-04-03 13:44:10 +11:00
Jonathan Brouwer
b11b685a3f Rollup merge of #153960 - Zoxc:fatal-layout-of-cycles, r=TaKO8Ki
Make `layout_of` cycles fatal errors

This makes `layout_of` cycles fatal errors.

This is a step towards removing query cycle recovery.
2026-04-02 22:13:49 +02:00
Nicholas Nethercote
deb901c896 Use closures more consistently in dep_graph.rs.
This file has several methods that take a `FnOnce() -> R` closure:
- `DepGraph::with_ignore`
- `DepGraph::with_query_deserialization`
- `DepGraph::with_anon_task`
- `DepGraphData::with_anon_task_inner`

It also has two methods that take a faux closure via an `A` argument and
a `fn(TyCtxt<'tcx>, A) -> R` argument:
- DepGraph::with_task
- DepGraphData::with_task

The rationale is that the faux closure exercises tight control over what
state they have access to. This seems silly when (a) they are passed a
`TyCtxt`, and (b) when similar nearby functions take real closures. And
they are more awkward to use, e.g. requiring multiple arguments to be
gathered into a tuple. This commit changes the faux closures to real
closures.
2026-03-31 20:21:05 +11:00
Zalathar
076dc9b06e Remove the tcx parameter from will_cache_on_disk_for_key_fn 2026-03-31 17:16:10 +11:00
Zalathar
a7d2a68378 Simplify the cache_on_disk_if modifier to just cache_on_disk
Queries with both `cache_on_disk` and `separate_provide_extern` will only
disk-cache values for local keys.

Other queries with `cache_on_disk` will disk-cache all values unconditionally.
2026-03-31 17:16:10 +11:00
John Kåre Alsaker
043bd76768 Make layout_of cycles fatal errors 2026-03-24 18:25:21 +01:00
John Kåre Alsaker
3d9452681c Split out the creation of Cycle to a new process_cycle function 2026-03-24 18:17:53 +01:00
John Kåre Alsaker
e6098df4d0 Remove TaggedQueryKey::def_kind 2026-03-24 17:51:43 +01:00
bors
9df83179a4 Auto merge of #154289 - jhpratt:rollup-JFDweJT, r=jhpratt
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#153964 (Fix `doc_cfg` not working as expected on trait impls)
 - rust-lang/rust#153979 (Rename various query cycle things.)
 - rust-lang/rust#154132 (Add missing num_internals feature gate to coretests/benches)
 - rust-lang/rust#154153 (core: Implement `unchecked_funnel_{shl,shr}`)
 - rust-lang/rust#154236 (Clean up query-forcing functions)
 - rust-lang/rust#154252 (Don't store current-session side effects in `OnDiskCache`)
 - rust-lang/rust#154017 ( Fix invalid add of duplicated call locations for the rustdoc scraped examples feature)
 - rust-lang/rust#154163 (enzyme submodule update)
 - rust-lang/rust#154264 (Update books)
 - rust-lang/rust#154282 (rustc-dev-guide subtree update)
2026-03-24 04:54:28 +00:00