Skip to content

Commit 68f5762

Browse files
authored
Rollup merge of rust-lang#117963 - nnethercote:rustc_query_system, r=compiler-errors
`rustc_query_system` cleanups Minor cleanups. r? `@compiler-errors`
2 parents c77cb7a + 8f669f5 commit 68f5762

File tree

7 files changed

+29
-34
lines changed

7 files changed

+29
-34
lines changed

compiler/rustc_middle/src/dep_graph/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ mod dep_node;
88

99
pub use rustc_query_system::dep_graph::debug::EdgeFilter;
1010
pub use rustc_query_system::dep_graph::{
11-
debug::DepNodeFilter, hash_result, DepContext, DepGraphQuery, DepNodeColor, DepNodeIndex, Deps,
12-
SerializedDepGraph, SerializedDepNodeIndex, TaskDeps, TaskDepsRef, WorkProduct, WorkProductId,
11+
debug::DepNodeFilter, hash_result, DepContext, DepGraphQuery, DepNodeIndex, Deps,
12+
SerializedDepGraph, SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId,
1313
WorkProductMap,
1414
};
1515

compiler/rustc_query_system/src/dep_graph/edges.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::iter::Extend;
55
use std::ops::Deref;
66

77
#[derive(Default, Debug)]
8-
pub struct EdgesVec {
8+
pub(crate) struct EdgesVec {
99
max: u32,
1010
edges: SmallVec<[DepNodeIndex; EdgesVec::INLINE_CAPACITY]>,
1111
}
@@ -18,21 +18,21 @@ impl Hash for EdgesVec {
1818
}
1919

2020
impl EdgesVec {
21-
pub const INLINE_CAPACITY: usize = 8;
21+
pub(crate) const INLINE_CAPACITY: usize = 8;
2222

2323
#[inline]
24-
pub fn new() -> Self {
24+
pub(crate) fn new() -> Self {
2525
Self::default()
2626
}
2727

2828
#[inline]
29-
pub fn push(&mut self, edge: DepNodeIndex) {
29+
pub(crate) fn push(&mut self, edge: DepNodeIndex) {
3030
self.max = self.max.max(edge.as_u32());
3131
self.edges.push(edge);
3232
}
3333

3434
#[inline]
35-
pub fn max_index(&self) -> u32 {
35+
pub(crate) fn max_index(&self) -> u32 {
3636
self.max
3737
}
3838
}

compiler/rustc_query_system/src/dep_graph/graph.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::sync::atomic::Ordering::Relaxed;
1818
use super::query::DepGraphQuery;
1919
use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex};
2020
use super::{DepContext, DepKind, DepNode, Deps, HasDepContext, WorkProductId};
21-
use crate::dep_graph::EdgesVec;
21+
use crate::dep_graph::edges::EdgesVec;
2222
use crate::ich::StableHashingContext;
2323
use crate::query::{QueryContext, QuerySideEffects};
2424

@@ -41,8 +41,7 @@ rustc_index::newtype_index! {
4141
}
4242

4343
impl DepNodeIndex {
44-
pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
45-
pub const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0);
44+
const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0);
4645
pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1);
4746
}
4847

@@ -53,28 +52,28 @@ impl From<DepNodeIndex> for QueryInvocationId {
5352
}
5453
}
5554

56-
pub struct MarkFrame<'a> {
55+
pub(crate) struct MarkFrame<'a> {
5756
index: SerializedDepNodeIndex,
5857
parent: Option<&'a MarkFrame<'a>>,
5958
}
6059

6160
#[derive(PartialEq)]
62-
pub enum DepNodeColor {
61+
enum DepNodeColor {
6362
Red,
6463
Green(DepNodeIndex),
6564
}
6665

6766
impl DepNodeColor {
6867
#[inline]
69-
pub fn is_green(self) -> bool {
68+
fn is_green(self) -> bool {
7069
match self {
7170
DepNodeColor::Red => false,
7271
DepNodeColor::Green(_) => true,
7372
}
7473
}
7574
}
7675

77-
pub struct DepGraphData<D: Deps> {
76+
pub(crate) struct DepGraphData<D: Deps> {
7877
/// The new encoding of the dependency graph, optimized for red/green
7978
/// tracking. The `current` field is the dependency graph of only the
8079
/// current compilation session: We don't merge the previous dep-graph into
@@ -185,7 +184,7 @@ impl<D: Deps> DepGraph<D> {
185184
}
186185

187186
#[inline]
188-
pub fn data(&self) -> Option<&DepGraphData<D>> {
187+
pub(crate) fn data(&self) -> Option<&DepGraphData<D>> {
189188
self.data.as_deref()
190189
}
191190

@@ -333,7 +332,7 @@ impl<D: Deps> DepGraphData<D> {
333332
///
334333
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/queries/incremental-compilation.html
335334
#[inline(always)]
336-
pub fn with_task<Ctxt: HasDepContext<Deps = D>, A: Debug, R>(
335+
pub(crate) fn with_task<Ctxt: HasDepContext<Deps = D>, A: Debug, R>(
337336
&self,
338337
key: DepNode,
339338
cx: Ctxt,
@@ -398,7 +397,7 @@ impl<D: Deps> DepGraphData<D> {
398397

399398
/// Executes something within an "anonymous" task, that is, a task the
400399
/// `DepNode` of which is determined by the list of inputs it read from.
401-
pub fn with_anon_task<Tcx: DepContext<Deps = D>, OP, R>(
400+
pub(crate) fn with_anon_task<Tcx: DepContext<Deps = D>, OP, R>(
402401
&self,
403402
cx: Tcx,
404403
dep_kind: DepKind,
@@ -618,7 +617,7 @@ impl<D: Deps> DepGraph<D> {
618617

619618
impl<D: Deps> DepGraphData<D> {
620619
#[inline]
621-
pub fn dep_node_index_of_opt(&self, dep_node: &DepNode) -> Option<DepNodeIndex> {
620+
fn dep_node_index_of_opt(&self, dep_node: &DepNode) -> Option<DepNodeIndex> {
622621
if let Some(prev_index) = self.previous.node_to_index_opt(dep_node) {
623622
self.current.prev_index_to_index.lock()[prev_index]
624623
} else {
@@ -627,7 +626,7 @@ impl<D: Deps> DepGraphData<D> {
627626
}
628627

629628
#[inline]
630-
pub fn dep_node_exists(&self, dep_node: &DepNode) -> bool {
629+
fn dep_node_exists(&self, dep_node: &DepNode) -> bool {
631630
self.dep_node_index_of_opt(dep_node).is_some()
632631
}
633632

@@ -643,21 +642,21 @@ impl<D: Deps> DepGraphData<D> {
643642
/// Returns true if the given node has been marked as green during the
644643
/// current compilation session. Used in various assertions
645644
#[inline]
646-
pub fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool {
645+
pub(crate) fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool {
647646
self.colors.get(prev_index).is_some_and(|c| c.is_green())
648647
}
649648

650649
#[inline]
651-
pub fn prev_fingerprint_of(&self, prev_index: SerializedDepNodeIndex) -> Fingerprint {
650+
pub(crate) fn prev_fingerprint_of(&self, prev_index: SerializedDepNodeIndex) -> Fingerprint {
652651
self.previous.fingerprint_by_index(prev_index)
653652
}
654653

655654
#[inline]
656-
pub fn prev_node_of(&self, prev_index: SerializedDepNodeIndex) -> DepNode {
655+
pub(crate) fn prev_node_of(&self, prev_index: SerializedDepNodeIndex) -> DepNode {
657656
self.previous.index_to_node(prev_index)
658657
}
659658

660-
pub fn mark_debug_loaded_from_disk(&self, dep_node: DepNode) {
659+
pub(crate) fn mark_debug_loaded_from_disk(&self, dep_node: DepNode) {
661660
self.debug_loaded_from_disk.lock().insert(dep_node);
662661
}
663662
}
@@ -684,8 +683,9 @@ impl<D: Deps> DepGraph<D> {
684683
self.data.as_ref().unwrap().debug_loaded_from_disk.lock().contains(&dep_node)
685684
}
686685

686+
#[cfg(debug_assertions)]
687687
#[inline(always)]
688-
pub fn register_dep_node_debug_str<F>(&self, dep_node: DepNode, debug_str_gen: F)
688+
pub(crate) fn register_dep_node_debug_str<F>(&self, dep_node: DepNode, debug_str_gen: F)
689689
where
690690
F: FnOnce() -> String,
691691
{
@@ -725,7 +725,7 @@ impl<D: Deps> DepGraphData<D> {
725725
/// A node will have an index, when it's already been marked green, or when we can mark it
726726
/// green. This function will mark the current task as a reader of the specified node, when
727727
/// a node index can be found for that node.
728-
pub fn try_mark_green<Qcx: QueryContext<Deps = D>>(
728+
pub(crate) fn try_mark_green<Qcx: QueryContext<Deps = D>>(
729729
&self,
730730
qcx: Qcx,
731731
dep_node: &DepNode,

compiler/rustc_query_system/src/dep_graph/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ mod query;
66
mod serialized;
77

88
pub use dep_node::{DepKind, DepKindStruct, DepNode, DepNodeParams, WorkProductId};
9-
pub use edges::EdgesVec;
10-
pub use graph::{
11-
hash_result, DepGraph, DepGraphData, DepNodeColor, DepNodeIndex, TaskDeps, TaskDepsRef,
12-
WorkProduct, WorkProductMap,
13-
};
9+
pub(crate) use graph::DepGraphData;
10+
pub use graph::{hash_result, DepGraph, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap};
1411
pub use query::DepGraphQuery;
1512
pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
1613

compiler/rustc_query_system/src/dep_graph/serialized.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
3838
use super::query::DepGraphQuery;
3939
use super::{DepKind, DepNode, DepNodeIndex, Deps};
40-
use crate::dep_graph::EdgesVec;
40+
use crate::dep_graph::edges::EdgesVec;
4141
use rustc_data_structures::fingerprint::Fingerprint;
4242
use rustc_data_structures::fingerprint::PackedFingerprint;
4343
use rustc_data_structures::fx::FxHashMap;

compiler/rustc_query_system/src/ich/hcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct StableHashingContext<'a> {
2828
// `CachingSourceMapView`, so we initialize it lazily.
2929
raw_source_map: &'a SourceMap,
3030
caching_source_map: Option<CachingSourceMapView<'a>>,
31-
pub(super) hashing_controls: HashingControls,
31+
hashing_controls: HashingControls,
3232
}
3333

3434
/// The `BodyResolver` allows mapping a `BodyId` to the corresponding `hir::Body`.

compiler/rustc_query_system/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
#![feature(core_intrinsics)]
33
#![feature(hash_raw_entry)]
44
#![feature(min_specialization)]
5-
#![feature(extern_types)]
65
#![feature(let_chains)]
7-
#![feature(inline_const)]
86
#![allow(rustc::potential_query_instability)]
97
#![deny(rustc::untranslatable_diagnostic)]
108
#![deny(rustc::diagnostic_outside_of_impl)]

0 commit comments

Comments
 (0)