Replace make_dep_kind_name_array! with a slice constant
This commit is contained in:
parent
af6695c114
commit
17c5b7a4b5
4 changed files with 14 additions and 21 deletions
|
|
@ -940,7 +940,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> 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 =
|
||||
|
|
|
|||
|
|
@ -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<DepKind, ()> {
|
||||
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); )*
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TyCt
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct DepsType {
|
||||
pub dep_names: Vec<&'static str>,
|
||||
pub dep_names: &'static [&'static str],
|
||||
}
|
||||
|
||||
impl Deps for DepsType {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue