From 446d1e14c5e3f1791f3e1c1f4282e2e708c3914c Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 23 Feb 2026 15:53:13 +1100 Subject: [PATCH 1/3] Sort `rustc_middle::query::modifiers` --- compiler/rustc_middle/src/query/modifiers.rs | 52 +++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_middle/src/query/modifiers.rs b/compiler/rustc_middle/src/query/modifiers.rs index 81b9f0da6446c..68a3c0d84fb93 100644 --- a/compiler/rustc_middle/src/query/modifiers.rs +++ b/compiler/rustc_middle/src/query/modifiers.rs @@ -2,10 +2,12 @@ #![allow(unused, non_camel_case_types)] // FIXME: Update and clarify documentation for these modifiers. -/// # `desc` query modifier +// tidy-alphabetical-start +// +/// # `anon` query modifier /// -/// The description of the query. This modifier is required on every query. -pub struct desc; +/// Generate a dep node based on the dependencies of the query +pub struct anon; /// # `arena_cache` query modifier /// @@ -17,51 +19,46 @@ pub struct arena_cache; /// Cache the query to disk if the `Block` returns true. pub struct cache_on_disk_if; -/// # `cycle_fatal` query modifier -/// -/// A cycle error for this query aborting the compilation with a fatal error. -pub struct cycle_fatal; - /// # `cycle_delay_bug` query modifier /// /// A cycle error results in a delay_bug call pub struct cycle_delay_bug; +/// # `cycle_fatal` query modifier +/// +/// A cycle error for this query aborting the compilation with a fatal error. +pub struct cycle_fatal; + /// # `cycle_stash` query modifier /// /// A cycle error results in a stashed cycle error that can be unstashed and canceled later pub struct cycle_stash; -/// # `no_hash` query modifier +/// # `depth_limit` query modifier /// -/// Don't hash the result, instead just mark a query red if it runs -pub struct no_hash; +/// Whether the query has a call depth limit +pub struct depth_limit; -/// # `anon` query modifier +/// # `desc` query modifier /// -/// Generate a dep node based on the dependencies of the query -pub struct anon; +/// The description of the query. This modifier is required on every query. +pub struct desc; /// # `eval_always` query modifier /// /// Always evaluate the query, ignoring its dependencies pub struct eval_always; -/// # `depth_limit` query modifier -/// -/// Whether the query has a call depth limit -pub struct depth_limit; - -/// # `separate_provide_extern` query modifier -/// -/// Use a separate query provider for local and extern crates -pub struct separate_provide_extern; - /// # `feedable` query modifier /// /// Generate a `feed` method to set the query's value from another query. pub struct feedable; +/// # `no_hash` query modifier +/// +/// Don't hash the result, instead just mark a query red if it runs +pub struct no_hash; + /// # `return_result_from_ensure_ok` query modifier /// /// When this query is called via `tcx.ensure_ok()`, it returns @@ -75,3 +72,10 @@ pub struct feedable; /// Can only be applied to queries with a return value of /// `Result<_, ErrorGuaranteed>`. pub struct return_result_from_ensure_ok; + +/// # `separate_provide_extern` query modifier +/// +/// Use a separate query provider for local and extern crates +pub struct separate_provide_extern; + +// tidy-alphabetical-end From ab0576b7fed7657cd8322681b397d178c88e7a51 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 23 Feb 2026 15:54:19 +1100 Subject: [PATCH 2/3] Make dummy modifier items non-pub This massively speeds up find-all-references in rust-analyzer, from taking several seconds to being near-instant. --- compiler/rustc_middle/src/query/modifiers.rs | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_middle/src/query/modifiers.rs b/compiler/rustc_middle/src/query/modifiers.rs index 68a3c0d84fb93..30396a1c83539 100644 --- a/compiler/rustc_middle/src/query/modifiers.rs +++ b/compiler/rustc_middle/src/query/modifiers.rs @@ -7,57 +7,57 @@ /// # `anon` query modifier /// /// Generate a dep node based on the dependencies of the query -pub struct anon; +pub(crate) struct anon; /// # `arena_cache` query modifier /// /// Use this type for the in-memory cache. -pub struct arena_cache; +pub(crate) struct arena_cache; /// # `cache_on_disk_if` query modifier /// /// Cache the query to disk if the `Block` returns true. -pub struct cache_on_disk_if; +pub(crate) struct cache_on_disk_if; /// # `cycle_delay_bug` query modifier /// /// A cycle error results in a delay_bug call -pub struct cycle_delay_bug; +pub(crate) struct cycle_delay_bug; /// # `cycle_fatal` query modifier /// /// A cycle error for this query aborting the compilation with a fatal error. -pub struct cycle_fatal; +pub(crate) struct cycle_fatal; /// # `cycle_stash` query modifier /// /// A cycle error results in a stashed cycle error that can be unstashed and canceled later -pub struct cycle_stash; +pub(crate) struct cycle_stash; /// # `depth_limit` query modifier /// /// Whether the query has a call depth limit -pub struct depth_limit; +pub(crate) struct depth_limit; /// # `desc` query modifier /// /// The description of the query. This modifier is required on every query. -pub struct desc; +pub(crate) struct desc; /// # `eval_always` query modifier /// /// Always evaluate the query, ignoring its dependencies -pub struct eval_always; +pub(crate) struct eval_always; /// # `feedable` query modifier /// /// Generate a `feed` method to set the query's value from another query. -pub struct feedable; +pub(crate) struct feedable; /// # `no_hash` query modifier /// /// Don't hash the result, instead just mark a query red if it runs -pub struct no_hash; +pub(crate) struct no_hash; /// # `return_result_from_ensure_ok` query modifier /// @@ -71,11 +71,11 @@ pub struct no_hash; /// /// Can only be applied to queries with a return value of /// `Result<_, ErrorGuaranteed>`. -pub struct return_result_from_ensure_ok; +pub(crate) struct return_result_from_ensure_ok; /// # `separate_provide_extern` query modifier /// /// Use a separate query provider for local and extern crates -pub struct separate_provide_extern; +pub(crate) struct separate_provide_extern; // tidy-alphabetical-end From e9ee5f869c580d7dfda51001b98cdb746c0c8096 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 23 Feb 2026 15:57:46 +1100 Subject: [PATCH 3/3] More explanation of what the dummy items in `modifiers` are for --- compiler/rustc_middle/src/query/modifiers.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_middle/src/query/modifiers.rs b/compiler/rustc_middle/src/query/modifiers.rs index 30396a1c83539..44aaa6a3ce3d9 100644 --- a/compiler/rustc_middle/src/query/modifiers.rs +++ b/compiler/rustc_middle/src/query/modifiers.rs @@ -1,4 +1,8 @@ //! This contains documentation which is linked from query modifiers used in the `rustc_queries!` proc macro. +//! +//! The dummy items in this module are used to enable hover documentation for +//! modifier names in the query list, and to allow find-all-references to list +//! all queries that use a particular modifier. #![allow(unused, non_camel_case_types)] // FIXME: Update and clarify documentation for these modifiers.