Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9fb9225
Disable debug_assert_not_in_new_nodes for multiple threads
zetanumbers Feb 15, 2026
448097d
Suggest async block instead of async closure when possible
chenyukang Jan 31, 2026
3736458
Fix async closure suggestion when no space between || and {
chenyukang Feb 5, 2026
d41e16b
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
af29989
Introduce --ci flag in tidy
Shunpoco Feb 28, 2026
d117486
Remove `DepKindVTable::is_anon`.
nnethercote Feb 26, 2026
f1789fa
Inline and remove `handle_cycle_error`.
nnethercote Feb 26, 2026
adf2d1e
Make `from_cycle_error` consume the `CycleError`.
nnethercote Feb 26, 2026
86e1af9
Avoid an early return in `try_execute_query`.
nnethercote Feb 26, 2026
f1c39fe
Merge two assertion blocks in `execute_job_non_incr`.
nnethercote Feb 26, 2026
e7dfd53
Remove three single-use type synonyms.
nnethercote Feb 26, 2026
2322cca
Replace two `abort_if_errors` calls.
nnethercote Feb 27, 2026
19b3617
Remove a duplicated comment.
nnethercote Feb 27, 2026
65b76a4
Rename trait `Value` as `FromCycleError`.
nnethercote Feb 27, 2026
fa5138b
Remove `FromCycleError` impl for `SymbolName`.
nnethercote Feb 27, 2026
8654366
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-…
matthiaskrgr Mar 1, 2026
b6faef2
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol
matthiaskrgr Mar 1, 2026
ca2655c
Rollup merge of #153169 - nnethercote:rm-is_anon-etc, r=petrochenkov
matthiaskrgr Mar 1, 2026
358ae92
Rollup merge of #152655 - zetanumbers:disable_debug_assert_151509, r=…
matthiaskrgr Mar 1, 2026
8e1ec75
Rollup merge of #153229 - BennoLossin:frt-fmt, r=ytmimi
matthiaskrgr Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,11 +174,6 @@ impl fmt::Debug for DepNode {
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindVTable<'tcx> {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub is_anon: bool,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::sync::{AtomicU64, Lock, is_dyn_thread_safe};
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::{assert_matches, outline};
use rustc_errors::DiagInner;
Expand DownExpand Up@@ -1302,7 +1302,9 @@ impl CurrentDepGraph {
prev_graph: &SerializedDepGraph,
prev_index: SerializedDepNodeIndex,
) {
if let Some(ref nodes_in_current_session) = self.nodes_in_current_session {
if !is_dyn_thread_safe()
&& let Some(ref nodes_in_current_session) = self.nodes_in_current_session
{
debug_assert!(
!nodes_in_current_session
.lock()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/queries.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir};
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate
// placeholder (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.
// as they will raise a fatal error on query cycles instead.
rustc_queries! {
/// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
/// The key is:
Expand Down
42 changes: 13 additions & 29 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,18 +62,6 @@ pub enum CycleErrorHandling {
Stash,
}

pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;

pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn(
tcx: TyCtxt<'tcx>,
key: &Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<Value>;

pub type IsLoadableFromDiskFn<'tcx, Key> =
fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool;

pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;

#[derive(Clone, Debug)]
Expand DownExpand Up@@ -128,7 +116,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
pub cycle_error_handling: CycleErrorHandling,
pub state: QueryState<'tcx, C::Key>,
pub cache: C,
pub will_cache_on_disk_for_key_fn: Option<WillCacheOnDiskForKeyFn<'tcx, C::Key>>,
pub will_cache_on_disk_for_key_fn: Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key) -> bool>,

/// Function pointer that calls `tcx.$query(key)` for this query and
/// discards the returned value.
Expand All@@ -144,11 +132,19 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
/// This should be the only code that calls the provider function.
pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value,

pub try_load_from_disk_fn: Option<TryLoadFromDiskFn<'tcx, C::Key, C::Value>>,
pub is_loadable_from_disk_fn: Option<IsLoadableFromDiskFn<'tcx, C::Key>>,
pub try_load_from_disk_fn: Option<
fn(
tcx: TyCtxt<'tcx>,
key: &C::Key,
prev_index: SerializedDepNodeIndex,
index: DepNodeIndex,
) -> Option<C::Value>,
>,
pub is_loadable_from_disk_fn:
Option<fn(tcx: TyCtxt<'tcx>, key: &C::Key, index: SerializedDepNodeIndex) -> bool>,
pub hash_result: HashResult<C::Value>,
pub value_from_cycle_error:
fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value,
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
pub format_value: fn(&C::Value) -> String,

/// Formats a human-readable description of this query and its key, as
Expand DownExpand Up@@ -213,7 +209,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
pub fn value_from_cycle_error(
&self,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
cycle_error: CycleError,
guar: ErrorGuaranteed,
) -> C::Value {
(self.value_from_cycle_error)(tcx, cycle_error, guar)
Expand DownExpand Up@@ -647,18 +643,6 @@ macro_rules! define_callbacks {
};
}

// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
// which memoizes and does dep-graph tracking, wrapping around the actual
// `Providers` that the driver creates (using several `rustc_*` crates).
//
// The result type of each query must implement `Clone`, and additionally
// `ty::query::values::Value`, which produces an appropriate placeholder
// (error) value if the query resulted in a query cycle.
// Queries marked with `cycle_fatal` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead.

mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};

Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_query_impl/src/dep_kind_vtables.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ mod non_query {
// We use this for most things when incr. comp. is turned off.
pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -26,7 +25,6 @@ mod non_query {
// We use this for the forever-red node.
pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| {
Expand All@@ -38,7 +36,6 @@ mod non_query {

pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
Expand All@@ -51,7 +48,6 @@ mod non_query {

pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
Expand All@@ -61,7 +57,6 @@ mod non_query {

pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: true,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -71,7 +66,6 @@ mod non_query {

pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -81,7 +75,6 @@ mod non_query {

pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
Expand All@@ -91,7 +84,6 @@ mod non_query {

pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
DepKindVTable {
is_anon: false,
is_eval_always: false,
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
Expand All@@ -117,7 +109,6 @@ where

if is_anon || !key_fingerprint_style.reconstructible() {
return DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: None,
Expand All@@ -126,7 +117,6 @@ where
}

DepKindVTable {
is_anon,
is_eval_always,
key_fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
Expand Down
54 changes: 19 additions & 35 deletions compiler/rustc_query_impl/src/execution.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use std::mem;
use rustc_data_structures::hash_table::{Entry, HashTable};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::{outline, sharded, sync};
use rustc_errors::{Diag, FatalError, StashKey};
use rustc_errors::{FatalError, StashKey};
use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex};
use rustc_middle::query::plumbing::QueryVTable;
use rustc_middle::query::{
Expand DownExpand Up@@ -108,24 +108,14 @@ fn mk_cycle<'tcx, C: QueryCache>(
cycle_error: CycleError,
) -> C::Value {
let error = report_cycle(tcx.sess, &cycle_error);
handle_cycle_error(query, tcx, &cycle_error, error)
}

fn handle_cycle_error<'tcx, C: QueryCache>(
query: &'tcx QueryVTable<'tcx, C>,
tcx: TyCtxt<'tcx>,
cycle_error: &CycleError,
error: Diag<'_>,
) -> C::Value {
match query.cycle_error_handling {
CycleErrorHandling::Error => {
let guar = error.emit();
query.value_from_cycle_error(tcx, cycle_error, guar)
}
CycleErrorHandling::Fatal => {
error.emit();
tcx.dcx().abort_if_errors();
unreachable!()
let guar = error.emit();
guar.raise_fatal();
}
CycleErrorHandling::DelayBug => {
let guar = error.delay_as_bug();
Expand DownExpand Up@@ -322,15 +312,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(

// Only call `wait_for_query` if we're using a Rayon thread pool
// as it will attempt to mark the worker thread as blocked.
return wait_for_query(query, tcx, span, key, latch, current_job_id);
}

let id = job.id;
drop(state_lock);
wait_for_query(query, tcx, span, key, latch, current_job_id)
} else {
let id = job.id;
drop(state_lock);

// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
// If we are single-threaded we know that we have cycle error,
// so we just return the error.
cycle_error(query, tcx, id, span)
}
}
ActiveKeyStatus::Poisoned => FatalError.raise(),
}
Expand DownExpand Up@@ -412,27 +402,21 @@ fn execute_job_non_incr<'tcx, C: QueryCache>(
) -> (C::Value, DepNodeIndex) {
debug_assert!(!tcx.dep_graph.is_fully_enabled());

// Fingerprint the key, just to assert that it doesn't
// have anything we don't consider hashable
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
}

let prof_timer = tcx.prof.query_provider();
// Call the query provider.
let result =
start_query(tcx, job_id, query.depth_limit, || (query.invoke_provider_fn)(tcx, key));
let dep_node_index = tcx.dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

// Similarly, fingerprint the result to assert that
// it doesn't have anything not considered hashable.
if cfg!(debug_assertions)
&& let Some(hash_result) = query.hash_result
{
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
// Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable.
if cfg!(debug_assertions) {
let _ = key.to_fingerprint(tcx);
if let Some(hash_result) = query.hash_result {
tcx.with_stable_hashing_context(|mut hcx| {
hash_result(&mut hcx, &result);
});
}
}

(result, dep_node_index)
Expand Down
Loading
Loading