mirror of
https://github.com/rust-lang/rust.git
synced 2026-01-24 23:17:31 +00:00
Make Deps::name lookup a non-self associated function
The dep names needed here are statically available from `rustc_middle`.
This commit is contained in:
@@ -91,10 +91,7 @@ fn delete_dirty_work_product(sess: &Session, swp: SerializedWorkProduct) {
|
||||
work_product::delete_workproduct_files(sess, &swp.work_product);
|
||||
}
|
||||
|
||||
fn load_dep_graph(
|
||||
sess: &Session,
|
||||
deps: &DepsType,
|
||||
) -> LoadResult<(Arc<SerializedDepGraph>, WorkProductMap)> {
|
||||
fn load_dep_graph(sess: &Session) -> LoadResult<(Arc<SerializedDepGraph>, WorkProductMap)> {
|
||||
let prof = sess.prof.clone();
|
||||
|
||||
if sess.opts.incremental.is_none() {
|
||||
@@ -174,7 +171,7 @@ fn load_dep_graph(
|
||||
return LoadResult::DataOutOfDate;
|
||||
}
|
||||
|
||||
let dep_graph = SerializedDepGraph::decode::<DepsType>(&mut decoder, deps);
|
||||
let dep_graph = SerializedDepGraph::decode::<DepsType>(&mut decoder);
|
||||
|
||||
LoadResult::Ok { data: (dep_graph, prev_work_products) }
|
||||
}
|
||||
@@ -212,12 +209,11 @@ pub fn setup_dep_graph(
|
||||
sess: &Session,
|
||||
crate_name: Symbol,
|
||||
stable_crate_id: StableCrateId,
|
||||
deps: &DepsType,
|
||||
) -> DepGraph {
|
||||
// `load_dep_graph` can only be called after `prepare_session_directory`.
|
||||
prepare_session_directory(sess, crate_name, stable_crate_id);
|
||||
|
||||
let res = sess.opts.build_dep_graph().then(|| load_dep_graph(sess, deps));
|
||||
let res = sess.opts.build_dep_graph().then(|| load_dep_graph(sess));
|
||||
|
||||
if sess.opts.incremental.is_some() {
|
||||
sess.time("incr_comp_garbage_collect_session_directories", || {
|
||||
|
||||
@@ -26,7 +26,6 @@ use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore, unerased_lint_sto
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_metadata::creader::CStore;
|
||||
use rustc_middle::arena::Arena;
|
||||
use rustc_middle::dep_graph::DepsType;
|
||||
use rustc_middle::ty::{self, CurrentGcx, GlobalCtxt, RegisteredTools, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_parse::lexer::StripTokens;
|
||||
@@ -940,8 +939,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_middle::dep_graph::DEP_KIND_NAMES };
|
||||
let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id, &dep_type);
|
||||
let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id);
|
||||
|
||||
let cstore =
|
||||
FreezeLock::new(Box::new(CStore::new(compiler.codegen_backend.metadata_loader())) as _);
|
||||
|
||||
@@ -61,7 +61,7 @@ macro_rules! define_dep_nodes {
|
||||
|
||||
/// List containing the name of each dep kind as a static string,
|
||||
/// indexable by `DepKind`.
|
||||
pub const DEP_KIND_NAMES: &[&str] = &[
|
||||
pub(crate) const DEP_KIND_NAMES: &[&str] = &[
|
||||
$( self::label_strs::$variant, )*
|
||||
];
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ use crate::ty::{self, TyCtxt};
|
||||
#[macro_use]
|
||||
mod dep_node;
|
||||
|
||||
pub use dep_node::{
|
||||
DEP_KIND_NAMES, DepKind, DepNode, DepNodeExt, dep_kind_from_label, dep_kinds, label_strs,
|
||||
};
|
||||
pub use dep_node::{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::{
|
||||
@@ -23,9 +21,7 @@ pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepsType>;
|
||||
pub type DepKindStruct<'tcx> = rustc_query_system::dep_graph::DepKindStruct<TyCtxt<'tcx>>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DepsType {
|
||||
pub dep_names: &'static [&'static str],
|
||||
}
|
||||
pub struct DepsType;
|
||||
|
||||
impl Deps for DepsType {
|
||||
fn with_deps<OP, R>(task_deps: TaskDepsRef<'_>, op: OP) -> R
|
||||
@@ -49,8 +45,8 @@ impl Deps for DepsType {
|
||||
})
|
||||
}
|
||||
|
||||
fn name(&self, dep_kind: DepKind) -> &'static str {
|
||||
self.dep_names[dep_kind.as_usize()]
|
||||
fn name(dep_kind: DepKind) -> &'static str {
|
||||
dep_node::DEP_KIND_NAMES[dep_kind.as_usize()]
|
||||
}
|
||||
|
||||
const DEP_KIND_NULL: DepKind = dep_kinds::Null;
|
||||
|
||||
@@ -103,7 +103,7 @@ pub trait Deps: DynSync {
|
||||
where
|
||||
OP: for<'a> FnOnce(TaskDepsRef<'a>);
|
||||
|
||||
fn name(&self, dep_kind: DepKind) -> &'static str;
|
||||
fn name(dep_kind: DepKind) -> &'static str;
|
||||
|
||||
/// We use this for most things when incr. comp. is turned off.
|
||||
const DEP_KIND_NULL: DepKind;
|
||||
|
||||
@@ -191,8 +191,8 @@ fn mask(bits: usize) -> usize {
|
||||
}
|
||||
|
||||
impl SerializedDepGraph {
|
||||
#[instrument(level = "debug", skip(d, deps))]
|
||||
pub fn decode<D: Deps>(d: &mut MemDecoder<'_>, deps: &D) -> Arc<SerializedDepGraph> {
|
||||
#[instrument(level = "debug", skip(d))]
|
||||
pub fn decode<D: Deps>(d: &mut MemDecoder<'_>) -> Arc<SerializedDepGraph> {
|
||||
// The last 16 bytes are the node count and edge count.
|
||||
debug!("position: {:?}", d.position());
|
||||
|
||||
@@ -280,7 +280,7 @@ impl SerializedDepGraph {
|
||||
if index[node.kind.as_usize()].insert(node.hash, idx).is_some() {
|
||||
// Empty nodes and side effect nodes can have duplicates
|
||||
if node.kind != D::DEP_KIND_NULL && node.kind != D::DEP_KIND_SIDE_EFFECT {
|
||||
let name = deps.name(node.kind);
|
||||
let name = D::name(node.kind);
|
||||
panic!(
|
||||
"Error: A dep graph node ({name}) does not have an unique index. \
|
||||
Running a clean build on a nightly compiler with `-Z incremental-verify-ich` \
|
||||
|
||||
Reference in New Issue
Block a user