diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 12a6a616d64f..1684b7535e68 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -940,7 +940,7 @@ pub fn create_and_enter_global_ctxt FnOnce(TyCtxt<'tcx>) -> T>( let outputs = util::build_output_filenames(&pre_configured_attrs, sess); - let dep_type = DepsType { dep_names: rustc_query_impl::dep_kind_names() }; + let dep_type = DepsType { dep_names: rustc_middle::dep_graph::DEP_KIND_NAMES }; let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id, &dep_type); let cstore = diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 3ee1db67911f..a815a03c6458 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -24,15 +24,6 @@ macro_rules! define_dep_nodes { ($mod:ident) => {[ $($mod::$variant()),* ]}; } - #[macro_export] - macro_rules! make_dep_kind_name_array { - ($mod:ident) => { - vec! { - $(*$mod::$variant().name),* - } - }; - } - /// This enum serves as an index into arrays built by `make_dep_kind_array`. // This enum has more than u8::MAX variants so we need some kind of multi-byte // encoding. The derived Encodable/Decodable uses leb128 encoding which is @@ -68,20 +59,24 @@ macro_rules! define_dep_nodes { deps.len() as u16 }; + /// List containing the name of each dep kind as a static string, + /// indexable by `DepKind`. + pub const DEP_KIND_NAMES: &[&str] = &[ + $( self::label_strs::$variant, )* + ]; + pub(super) fn dep_kind_from_label_string(label: &str) -> Result { match label { - $(stringify!($variant) => Ok(dep_kinds::$variant),)* + $( self::label_strs::$variant => Ok(self::dep_kinds::$variant), )* _ => Err(()), } } /// Contains variant => str representations for constructing /// DepNode groups for tests. - #[allow(dead_code, non_upper_case_globals)] + #[expect(non_upper_case_globals)] pub mod label_strs { - $( - pub const $variant: &str = stringify!($variant); - )* + $( pub const $variant: &str = stringify!($variant); )* } }; } diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index b24ea4acc6b7..2fef7b5a9781 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -8,7 +8,9 @@ use crate::ty::{self, TyCtxt}; #[macro_use] mod dep_node; -pub use dep_node::{DepKind, DepNode, DepNodeExt, dep_kind_from_label, dep_kinds, label_strs}; +pub use dep_node::{ + DEP_KIND_NAMES, DepKind, DepNode, DepNodeExt, dep_kind_from_label, dep_kinds, label_strs, +}; pub(crate) use dep_node::{make_compile_codegen_unit, make_compile_mono_item, make_metadata}; pub use rustc_query_system::dep_graph::debug::{DepNodeFilter, EdgeFilter}; pub use rustc_query_system::dep_graph::{ @@ -22,7 +24,7 @@ pub type DepKindStruct<'tcx> = rustc_query_system::dep_graph::DepKindStruct, + pub dep_names: &'static [&'static str], } impl Deps for DepsType { diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 67ab1114af62..d6d1dc781f3e 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -921,9 +921,5 @@ macro_rules! define_queries { pub fn query_callbacks<'tcx>(arena: &'tcx Arena<'tcx>) -> &'tcx [DepKindStruct<'tcx>] { arena.alloc_from_iter(rustc_middle::make_dep_kind_array!(query_callbacks)) } - - pub fn dep_kind_names() -> Vec<&'static str> { - rustc_middle::make_dep_kind_name_array!(query_callbacks) - } } }