3232//! `DepNode` definition happens in the `define_dep_nodes!()` macro. This macro
3333//! defines the `DepKind` enum. Each `DepKind` has its own parameters that are
3434//! needed at runtime in order to construct a valid `DepNode` fingerprint.
35- //! However, only `CompileCodegenUnit` is constructed explicitly (with
36- //! `make_compile_codegen_unit`).
35+ //! However, only `CompileCodegenUnit` and `CompileMonoItem` are constructed
36+ //! explicitly (with `make_compile_codegen_unit` cq `make_compile_mono_item `).
3737//!
3838//! Because the macro sees what parameters a given `DepKind` requires, it can
3939//! "infer" some properties for each kind of `DepNode`:
4646//! `DefId` it was computed from. In other cases, too much information gets
4747//! lost during fingerprint computation.
4848//!
49- //! `make_compile_codegen_unit`, together with `DepNode::new()`, ensures that only
50- //! valid `DepNode` instances can be constructed. For example, the API does not
51- //! allow for constructing parameterless `DepNode`s with anything other
52- //! than a zeroed out fingerprint. More generally speaking, it relieves the
53- //! user of the `DepNode` API of having to know how to compute the expected
54- //! fingerprint for a given set of node parameters.
49+ //! `make_compile_codegen_unit` and `make_compile_mono_items`, together with
50+ //! `DepNode::new()`, ensures that only valid `DepNode` instances can be
51+ //! constructed. For example, the API does not allow for constructing
52+ //! parameterless `DepNode`s with anything other than a zeroed out fingerprint.
53+ //! More generally speaking, it relieves the user of the `DepNode` API of
54+ //! having to know how to compute the expected fingerprint for a given set of
55+ //! node parameters.
5556//!
5657//! [dependency graph]: https://rustc-dev-guide.rust-lang.org/query.html
5758
59+ use crate :: mir:: mono:: MonoItem ;
5860use crate :: ty:: TyCtxt ;
5961
6062use rustc_data_structures:: fingerprint:: Fingerprint ;
@@ -175,6 +177,14 @@ pub mod dep_kind {
175177 can_reconstruct_query_key : || false ,
176178 } ;
177179
180+ pub const CompileMonoItem : DepKindStruct = DepKindStruct {
181+ has_params : true ,
182+ is_anon : false ,
183+ is_eval_always : false ,
184+
185+ can_reconstruct_query_key : || false ,
186+ } ;
187+
178188 macro_rules! define_query_dep_kinds {
179189 ( $(
180190 [ $( $attrs: tt) * ]
@@ -251,6 +261,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
251261
252262 // WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
253263 [ ] CompileCodegenUnit ( Symbol ) ,
264+
265+ // WARNING: if `MonoItem` is changed, make sure you update `make_compile_mono_item` below.
266+ // Only used by rustc_codegen_cranelift
267+ [ ] CompileMonoItem ( MonoItem ) ,
254268] ) ;
255269
256270// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
@@ -259,6 +273,12 @@ crate fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode {
259273 DepNode :: construct ( tcx, DepKind :: CompileCodegenUnit , & name)
260274}
261275
276+ // WARNING: `construct` is generic and does not know that `CompileMonoItem` takes `MonoItem`s as keys.
277+ // Be very careful changing this type signature!
278+ crate fn make_compile_mono_item ( tcx : TyCtxt < ' tcx > , mono_item : & MonoItem < ' tcx > ) -> DepNode {
279+ DepNode :: construct ( tcx, DepKind :: CompileMonoItem , mono_item)
280+ }
281+
262282pub type DepNode = rustc_query_system:: dep_graph:: DepNode < DepKind > ;
263283
264284// We keep a lot of `DepNode`s in memory during compilation. It's not
0 commit comments