summary refs log tree commit diff
path: root/compiler/rustc_query_system
AgeCommit message (Collapse)AuthorLines
2025-04-10Revert "Remove `prev_index_to_index` field from `CurrentDepGraph`"John Kåre Alsaker-144/+185
This reverts commit 60e4a1b8f37c48cfc4c8c78aaafc5ff2f8d02ca1.
2025-03-27Rollup merge of #138844 - petrochenkov:cfgtrace2, r=nnethercoteJacob Pratt-1/+1
expand: Leave traces when expanding `cfg` attributes This is the same as https://github.com/rust-lang/rust/pull/138515, but for `cfg(true)` instead of `cfg_attr`. The difference is that `cfg(true)`s already left "traces" after themselves - the `cfg` attributes themselves, with `expanded_inert_attrs` set to true, with full tokens, available to proc macros. This is not a reasonably expected behavior, but it could not be removed without a replacement, because a [major rustdoc feature](https://github.com/rust-lang/rfcs/pull/3631) and a number of clippy lints rely on it. This PR implements a replacement. This needs a crater run, because it changes observable behavior (in an intended way) - proc macros can no longer see expanded `cfg(true)` attributes. (Some minor unnecessary special casing for `sym::cfg_attr` is also removed in this PR.) r? `@nnethercote`
2025-03-27Rollup merge of #138672 - Zoxc:deferred-queries-in-deadlock-handler, r=oli-obkStuart Cook-100/+217
Avoiding calling queries when collecting active queries This PR changes active query collection to no longer call queries. Instead the fields needing queries have their computation delayed to when an cycle error is emitted or when printing the query backtrace in a panic. This is done by splitting the fields in `QueryStackFrame` needing queries into a new `QueryStackFrameExtra` type. When collecting queries `QueryStackFrame` will contain a closure that can create `QueryStackFrameExtra`, which does make use of queries. Calling `lift` on a `QueryStackFrame` or `CycleError` will convert it to a variant containing `QueryStackFrameExtra` using those closures. This also only calls queries needed to collect information on a cycle errors, instead of information on all active queries. Calling queries when collecting active queries is a bit odd. Calling queries should not be done in the deadlock handler at all. This avoids the out of memory scenario in https://github.com/rust-lang/rust/issues/124901.
2025-03-26Auto merge of #138824 - Zoxc:dep-graph-no-prev-map, r=oli-obkbors-185/+144
Remove `prev_index_to_index` field from `CurrentDepGraph` The dep graph currently has 2 ways to map a previous index into a current index. The `prev_index_to_index` map stores the current index equivalent of a previous index. For indices which are marked green, we also store the same information in the `DepNodeColorMap`. We actually only need to known the mapping for green nodes however, so this PR removes `prev_index_to_index` and instead makes use of the `DepNodeColorMap`. To avoid racing when promoting a node from the previous session, the encoder lock is now used to ensure only one thread encodes the promoted node. This was previously done by the lock in `prev_index_to_index`. This also changes `nodes_newly_allocated_in_current_session` used to detect duplicate dep nodes to contain both new and previous nodes, which is simpler and can better catch duplicates. The dep node index encoding used in `DepNodeColorMap` is tweak to avoid subtraction / addition to optimize accessing the current equivalent of a previous index. r? `@oli-obk`
2025-03-26expand: Leave traces when expanding `cfg` attributesVadim Petrochenkov-1/+1
2025-03-26Use a function to create `QueryStackDeferred` to ensure context is CopyJohn Kåre Alsaker-3/+7
2025-03-26Avoiding calling queries when collecting active queriesJohn Kåre Alsaker-100/+213
2025-03-25Rollup merge of #138874 - Zoxc:waiter-race, r=SparrowLii,davidtwcoJacob Pratt-25/+12
Batch mark waiters as unblocked when resuming in the deadlock handler This fixes a race when resuming multiple threads to resolve query cycles. This now marks all threads as unblocked before resuming any of them. Previously if one was resumed and marked as unblocked at a time. The first thread resumed could fall asleep then Rayon would detect a second false deadlock. Later the initial deadlock handler thread would resume further threads. This also reverts the workaround added in https://github.com/rust-lang/rust/pull/137731. cc `@SparrowLii` `@lqd`
2025-03-25Rollup merge of #138581 - Zoxc:abort-handler-if-locked, r=SparrowLiiMatthias Krüger-4/+12
Abort in deadlock handler if we fail to get a query map Resolving query cycles requires the complete active query map, or it may miss query cycles. We did not check that the map is completely constructed before. If there is some error collecting the map, something has gone wrong already. This adds a check to abort/panic if we fail to construct the complete map. This can help differentiate errors from the `deadlock detected` case if constructing query map has errors in practice. An `Option` is not used for `collect_active_jobs` as the panic handler can still make use of a partial map.
2025-03-24Remove `prev_index_to_index` field from `CurrentDepGraph`John Kåre Alsaker-185/+144
2025-03-24Auto merge of #138629 - Zoxc:graph-anon-hashmap, r=oli-obkbors-49/+115
Only use the new node hashmap for anonymous nodes This is a rebase of https://github.com/rust-lang/rust/pull/112469. cc `@cjgillot`
2025-03-24Remove `QueryWaiter::notify`John Kåre Alsaker-8/+2
2025-03-24Batch mark waiters as unblocked when resuming in the deadlock handlerJohn Kåre Alsaker-2/+8
2025-03-24Revert "resume one waiter at a call"John Kåre Alsaker-15/+2
This reverts commit cc1e4ede9388d87750c3751f41e8c6c4f6cae995.
2025-03-21Address commentsJohn Kåre Alsaker-4/+8
2025-03-21Use hashbrown from crates.ioJohn Kåre Alsaker-2/+5
2025-03-21Optimize hash map operations in the query systemJohn Kåre Alsaker-29/+43
2025-03-21Update commentsJohn Kåre Alsaker-0/+3
2025-03-21Abort in deadlock handler if we fail to get a query mapJohn Kåre Alsaker-4/+5
2025-03-20Use `-Wunused_crate_dependencies` for compiler crates.Nicholas Nethercote-1/+0
It's very useful. There are some false positives involving integration tests in `rustc_pattern_analysis` and `rustc_serialize`. There is also a false positive involving `rustc_driver_impl`'s `rustc_randomized_layouts` feature. And I removed a `rustc_span` mention in a doc comment in `rustc_log` because it wasn't integral to the comment but caused a dev-dependency.
2025-03-19Allow duplicates for side effect nodesJohn Kåre Alsaker-2/+5
2025-03-19Pass in dep kind names to the duplicate dep node checkJohn Kåre Alsaker-4/+7
2025-03-19Rename `intern_new_node` to `alloc_new_node`John Kåre Alsaker-4/+4
2025-03-19Use `ShardedHashMap` for `anon_node_to_index`John Kåre Alsaker-28/+9
2025-03-19Use `nodes_newly_allocated_in_current_session` to lookup forbidden readsJohn Kåre Alsaker-5/+18
2025-03-19Check for duplicate dep nodes when creating the indexJohn Kåre Alsaker-1/+8
2025-03-19Add fixmeJohn Kåre Alsaker-0/+1
2025-03-19Outline some cold code and turn on hash collision detection with ↵John Kåre Alsaker-16/+21
debug_assertions
2025-03-19Only use the new node hashmap for anonymous nodes.Camille GILLOT-48/+101
2025-03-15Fix `record_diagnostic`John Kåre Alsaker-2/+6
2025-03-14Add commentsJohn Kåre Alsaker-0/+9
2025-03-14Rename `QuerySideEffects` to `QuerySideEffect`John Kåre Alsaker-17/+25
2025-03-14Represent diagnostic side effects as dep nodesJohn Kåre Alsaker-120/+107
2025-03-12Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, ↵Matthias Krüger-1/+0
r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed #138084. Fixes #138106. r? ````@jieyouxu````
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Convert `ShardedHashMap` to use `hashbrown::HashTable`Josh Stone-31/+15
The `hash_raw_entry` feature has finished fcp-close, so the compiler should stop using it to allow its removal. Several `Sharded` maps were using raw entries to avoid re-hashing between shard and map lookup, and we can do that with `hashbrown::HashTable` instead.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-3/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-09Auto merge of #138267 - matthiaskrgr:rollup-vt76bhs, r=matthiaskrgrbors-7/+8
Rollup of 12 pull requests Successful merges: - #136127 (Allow `*const W<dyn A> -> *const dyn A` ptr cast) - #136968 (Turn order dependent trait objects future incompat warning into a hard error) - #137319 (Stabilize `const_vec_string_slice`) - #137885 (tidy: add triagebot checks) - #138040 (compiler: Use `size_of` from the prelude instead of imported) - #138084 (Use workspace lints for crates in `compiler/`) - #138158 (Move more layouting logic to `rustc_abi`) - #138160 (depend more on attr_data_structures and move find_attr! there) - #138192 (crashes: couple more tests) - #138216 (bootstrap: Fix stack printing when a step cycle is detected) - #138232 (Reduce verbosity of GCC build log) - #138242 (Revert "Don't test new error messages with the stage 0 compiler") r? `@ghost` `@rustbot` modify labels: rollup
2025-03-09Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxuMatthias Krüger-1/+3
Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? ``@jieyouxu``
2025-03-09Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, ↵Matthias Krüger-6/+5
r=compiler-errors compiler: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. Apply this change across the compiler. These functions were added to all preludes in Rust 1.80. r? ``@compiler-errors``
2025-03-09Auto merge of #137563 - FractalFir:dep_graph_cap, r=nnethercotebors-2/+1
Change TaskDeps to start preallocated with 128 capacity This is a tiny change that makes `TaskDeps::read_set` start preallocated with capacity for 128 elements. From local profiling, it looks like `TaskDeps::read_set` is one of the most-often resized hash-sets in `rustc`.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-08Specify rust lints for `compiler/` crates via Cargo.Nicholas Nethercote-0/+3
By naming them in `[workspace.lints.rust]` in the top-level `Cargo.toml`, and then making all `compiler/` crates inherit them with `[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`, because they're a bit different.) The advantages of this over the current approach: - It uses a standard Cargo feature, rather than special handling in bootstrap. So, easier to understand, and less likely to get accidentally broken in the future. - It works for proc macro crates. It's a shame it doesn't work for rustc-specific lints, as the comments explain.
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-6/+5
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-05Rollup merge of #137731 - SparrowLii:waiter, r=nnethercote许杰友 Jieyou Xu (Joe)-2/+15
Resume one waiter at once in deadlock handler When multiple query loop errors occur in the code, only one waiter should be resumed at a time to avoid waking up multiple waiters at the same time and causing deadlock due to thread grabbing. This fixes the UI failures in #132051 cc `@Zoxc` `@cjgillot` `@nnethercote` `@bjorn3` `@Kobzol` Zulip discussion [here](https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fwg-parallel-rustc/topic/Deadlocks.20and.20Rayon) Edit: We can't reproduce these bugs with the existing test suits, so we keep them until we merge #132051 UPDATES #129912 UPDATES #120757 UPDATES #129911
2025-03-05resume one waiter at a callroot-2/+15
2025-03-03Remove some unnecessary aliases from `rustc_data_structures::sync`Zalathar-1/+1
With the removal of `cfg(parallel_compiler)`, these are always shared references and `std::sync::OnceLock`.
2025-02-27Changed the dependency graph to start preallocated with 128 capacityMichał Kostrubiec-2/+1
2025-02-24Introduce new parsing infrastructure and types for parsed attributesJana Dönszelmann-14/+6
fixup docs in parser
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-1/+1