@@ -26,7 +26,7 @@ use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex
2626use super :: { DepContext , DepKind , DepNode , Deps , HasDepContext , WorkProductId } ;
2727use crate :: dep_graph:: edges:: EdgesVec ;
2828use crate :: ich:: StableHashingContext ;
29- use crate :: query:: { QueryContext , QuerySideEffect } ;
29+ use crate :: query:: { DefIdInfo , QueryContext , QuerySideEffect } ;
3030
3131#[ derive( Clone ) ]
3232pub struct DepGraph < D : Deps > {
@@ -260,6 +260,7 @@ impl<D: Deps> DepGraph<D> {
260260 }
261261
262262 #[ inline( always) ]
263+ /// A helper for `codegen_cranelift`.
263264 pub fn with_task < Ctxt : HasDepContext < Deps = D > , A : Debug , R > (
264265 & self ,
265266 key : DepNode ,
@@ -530,6 +531,18 @@ impl<D: Deps> DepGraph<D> {
530531 } )
531532 }
532533 }
534+
535+ pub fn record_def < Qcx : QueryContext > ( & self , qcx : Qcx , def : DefIdInfo ) {
536+ if let Some ( ref data) = self . data {
537+ D :: read_deps ( |task_deps| match task_deps {
538+ TaskDepsRef :: EvalAlways | TaskDepsRef :: Ignore => return ,
539+ TaskDepsRef :: Forbid | TaskDepsRef :: Allow ( ..) => {
540+ self . read_index ( data. encode_side_effect ( qcx, QuerySideEffect :: Definition ( def) ) ) ;
541+ }
542+ } )
543+ }
544+ }
545+
533546 /// This forces a diagnostic node green by running its side effect. `prev_index` would
534547 /// refer to a node created used [Self::record_diagnostic] in the previous session.
535548 #[ inline]
@@ -667,7 +680,7 @@ impl<D: Deps> DepGraphData<D> {
667680 self . debug_loaded_from_disk . lock ( ) . insert ( dep_node) ;
668681 }
669682
670- /// This encodes a diagnostic by creating a node with an unique index and assoicating
683+ /// This encodes a diagnostic by creating a node with an unique index and associating
671684 /// `diagnostic` with it, for use in the next session.
672685 #[ inline]
673686 fn encode_side_effect < Qcx : QueryContext > (
@@ -705,6 +718,9 @@ impl<D: Deps> DepGraphData<D> {
705718 QuerySideEffect :: Diagnostic ( diagnostic) => {
706719 qcx. dep_context ( ) . sess ( ) . dcx ( ) . emit_diagnostic ( diagnostic. clone ( ) ) ;
707720 }
721+ QuerySideEffect :: Definition ( def_id_info) => {
722+ qcx. dep_context ( ) . create_def ( def_id_info)
723+ }
708724 }
709725
710726 // Use `send_and_color` as `promote_node_and_deps_to_current` expects all
0 commit comments