Skip to content

Commit 9e9aba8

Browse files
authored
Rollup merge of #80829 - jyn514:dep-constructor, r=michaelwoerister
Get rid of `DepConstructor` This removes fully 235 unused functions. Follow-up to #80325 (comment). r? ``@michaelwoerister`` cc ``@cjgillot``
2 parents 446ed77 + f7d261c commit 9e9aba8

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed

compiler/rustc_middle/src/dep_graph/dep_node.rs

+13-32
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
//! contained no `DefId` for thing that had been removed.
3030
//!
3131
//! `DepNode` definition happens in the `define_dep_nodes!()` macro. This macro
32-
//! defines the `DepKind` enum and a corresponding `dep_constructor` module. The
33-
//! `dep_constructor` module links a `DepKind` to the parameters that are needed at
34-
//! runtime in order to construct a valid `DepNode` fingerprint.
32+
//! defines the `DepKind` enum. Each `DepKind` has its own parameters that are
33+
//! needed at runtime in order to construct a valid `DepNode` fingerprint.
34+
//! However, only `CompileCodegenUnit` is constructed explicitly (with
35+
//! `make_compile_codegen_unit`).
3536
//!
3637
//! Because the macro sees what parameters a given `DepKind` requires, it can
3738
//! "infer" some properties for each kind of `DepNode`:
@@ -44,22 +45,14 @@
4445
//! `DefId` it was computed from. In other cases, too much information gets
4546
//! lost during fingerprint computation.
4647
//!
47-
//! The `dep_constructor` module, together with `DepNode::new()`, ensures that only
48+
//! `make_compile_codegen_unit`, together with `DepNode::new()`, ensures that only
4849
//! valid `DepNode` instances can be constructed. For example, the API does not
4950
//! allow for constructing parameterless `DepNode`s with anything other
5051
//! than a zeroed out fingerprint. More generally speaking, it relieves the
5152
//! user of the `DepNode` API of having to know how to compute the expected
5253
//! fingerprint for a given set of node parameters.
5354
54-
use crate::mir::interpret::{GlobalId, LitToConstInput};
55-
use crate::traits;
56-
use crate::traits::query::{
57-
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
58-
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
59-
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
60-
};
61-
use crate::ty::subst::{GenericArg, SubstsRef};
62-
use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
55+
use crate::ty::TyCtxt;
6356

6457
use rustc_data_structures::fingerprint::Fingerprint;
6558
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
@@ -338,25 +331,6 @@ macro_rules! define_dep_nodes {
338331
$($variant),*
339332
}
340333

341-
#[allow(non_camel_case_types)]
342-
pub mod dep_constructor {
343-
use super::*;
344-
345-
$(
346-
#[inline(always)]
347-
#[allow(unreachable_code, non_snake_case)]
348-
pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
349-
// tuple args
350-
$({
351-
erase!($tuple_arg_ty);
352-
return DepNode::construct(_tcx, DepKind::$variant, &arg)
353-
})*
354-
355-
return DepNode::construct(_tcx, DepKind::$variant, &())
356-
}
357-
)*
358-
}
359-
360334
fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
361335
match label {
362336
$(stringify!($variant) => Ok(DepKind::$variant),)*
@@ -384,9 +358,16 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
384358

385359
[anon] TraitSelect,
386360

361+
// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
387362
[] CompileCodegenUnit(Symbol),
388363
]);
389364

365+
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
366+
// Be very careful changing this type signature!
367+
crate fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode {
368+
DepNode::construct(tcx, DepKind::CompileCodegenUnit, &name)
369+
}
370+
390371
pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
391372

392373
// We keep a lot of `DepNode`s in memory during compilation. It's not

compiler/rustc_middle/src/dep_graph/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ pub use rustc_query_system::dep_graph::{
1313
WorkProduct, WorkProductId,
1414
};
1515

16-
pub use dep_node::{dep_constructor, label_strs, DepKind, DepNode, DepNodeExt};
16+
crate use dep_node::make_compile_codegen_unit;
17+
pub use dep_node::{label_strs, DepKind, DepNode, DepNodeExt};
1718

1819
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
1920
pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;

compiler/rustc_middle/src/mir/mono.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::dep_graph::{dep_constructor, DepNode, WorkProduct, WorkProductId};
1+
use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
22
use crate::ich::{NodeIdHashingMode, StableHashingContext};
33
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
44
use rustc_attr::InlineAttr;
@@ -362,7 +362,7 @@ impl<'tcx> CodegenUnit<'tcx> {
362362
}
363363

364364
pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode {
365-
dep_constructor::CompileCodegenUnit(tcx, self.name())
365+
crate::dep_graph::make_compile_codegen_unit(tcx, self.name())
366366
}
367367
}
368368

0 commit comments

Comments
 (0)