diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-02 19:44:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-02 19:44:14 +0200 |
| commit | 3c5ee8d5f9e8bf742e2160405c7d1241c5a39a87 (patch) | |
| tree | 731c68be0fdd1535b4782ddde36e82afe07ca36a | |
| parent | ad8db11b94d381ae73fb8f2fa406aa40ab1136fe (diff) | |
| parent | 927ad1659ab4c918a4f41aef71cc8847a5198326 (diff) | |
| download | rust-3c5ee8d5f9e8bf742e2160405c7d1241c5a39a87.tar.gz rust-3c5ee8d5f9e8bf742e2160405c7d1241c5a39a87.zip | |
Rollup merge of #139237 - Zoxc:anon-0-deps-kind, r=compiler-errors
Add a dep kind for use of the anon node with zero dependencies This adds a dep kind for use of the anon node with zero dependencies instead of making use of the null node. I don't think this matters, but it is nicer than random null nodes in the dep graph.
| -rw-r--r-- | compiler/rustc_middle/src/dep_graph/dep_node.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/dep_graph/mod.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_query_impl/src/plumbing.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/mod.rs | 3 |
5 files changed, 21 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index be34c7ef4bd..644cdac5d55 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -89,6 +89,7 @@ rustc_query_append!(define_dep_nodes![ /// We use this to create a forever-red node. [] fn Red() -> (), [] fn SideEffect() -> (), + [] fn AnonZeroDeps() -> (), [] fn TraitSelect() -> (), [] fn CompileCodegenUnit() -> (), [] fn CompileMonoItem() -> (), diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index 739c0be1a91..931d67087ac 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -53,6 +53,7 @@ impl Deps for DepsType { const DEP_KIND_NULL: DepKind = dep_kinds::Null; const DEP_KIND_RED: DepKind = dep_kinds::Red; const DEP_KIND_SIDE_EFFECT: DepKind = dep_kinds::SideEffect; + const DEP_KIND_ANON_ZERO_DEPS: DepKind = dep_kinds::AnonZeroDeps; const DEP_KIND_MAX: u16 = dep_node::DEP_KIND_VARIANTS - 1; } diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 3238c7a0912..19ccc5587d6 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -870,6 +870,17 @@ macro_rules! define_queries { } } + pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindStruct<'tcx> { + DepKindStruct { + is_anon: true, + is_eval_always: false, + fingerprint_style: FingerprintStyle::Opaque, + force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")), + try_load_from_on_disk_cache: None, + name: &"AnonZeroDeps", + } + } + pub(crate) fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> { DepKindStruct { is_anon: true, diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 127dcd825da..9f34417973e 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -50,7 +50,7 @@ rustc_index::newtype_index! { rustc_data_structures::static_assert_size!(Option<DepNodeIndex>, 4); impl DepNodeIndex { - const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::ZERO; + const SINGLETON_ZERO_DEPS_ANON_NODE: DepNodeIndex = DepNodeIndex::ZERO; pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1); } @@ -140,13 +140,13 @@ impl<D: Deps> DepGraph<D> { let colors = DepNodeColorMap::new(prev_graph_node_count); - // Instantiate a dependy-less node only once for anonymous queries. + // Instantiate a node with zero dependencies only once for anonymous queries. let _green_node_index = current.alloc_node( - DepNode { kind: D::DEP_KIND_NULL, hash: current.anon_id_seed.into() }, + DepNode { kind: D::DEP_KIND_ANON_ZERO_DEPS, hash: current.anon_id_seed.into() }, EdgesVec::new(), Fingerprint::ZERO, ); - assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE); + assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_ZERO_DEPS_ANON_NODE); // Instantiate a dependy-less red node only once for anonymous queries. let red_node_index = current.alloc_node( @@ -407,7 +407,7 @@ impl<D: Deps> DepGraphData<D> { // going to be (i.e. equal to the precomputed // `SINGLETON_DEPENDENCYLESS_ANON_NODE`). As a consequence we can skip creating // a `StableHasher` and sending the node through interning. - DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE + DepNodeIndex::SINGLETON_ZERO_DEPS_ANON_NODE } 1 => { // When there is only one dependency, don't bother creating a node. diff --git a/compiler/rustc_query_system/src/dep_graph/mod.rs b/compiler/rustc_query_system/src/dep_graph/mod.rs index 4eeb6078d14..3a80835afad 100644 --- a/compiler/rustc_query_system/src/dep_graph/mod.rs +++ b/compiler/rustc_query_system/src/dep_graph/mod.rs @@ -111,6 +111,9 @@ pub trait Deps { /// We use this to create a side effect node. const DEP_KIND_SIDE_EFFECT: DepKind; + /// We use this to create the anon node with zero dependencies. + const DEP_KIND_ANON_ZERO_DEPS: DepKind; + /// This is the highest value a `DepKind` can have. It's used during encoding to /// pack information into the unused bits. const DEP_KIND_MAX: u16; |
