Skip to main content

rustc_middle/dep_graph/
dep_node.rs

1//! This module defines the [`DepNode`] type which the compiler uses to represent
2//! nodes in the [dependency graph]. A `DepNode` consists of a [`DepKind`] (which
3//! specifies the kind of thing it represents, like a piece of HIR, MIR, etc.)
4//! and a "key fingerprint", a 128-bit hash value, the exact meaning of which
5//! depends on the node's `DepKind`. Together, the kind and the key fingerprint
6//! fully identify a dependency node, even across multiple compilation sessions.
7//! In other words, the value of the key fingerprint does not depend on anything
8//! that is specific to a given compilation session, like an unpredictable
9//! interning key (e.g., `NodeId`, `DefId`, `Symbol`) or the numeric value of a
10//! pointer. The concept behind this could be compared to how git commit hashes
11//! uniquely identify a given commit. The fingerprinting approach has
12//! a few advantages:
13//!
14//! * A `DepNode` can simply be serialized to disk and loaded in another session
15//!   without the need to do any "rebasing" (like we have to do for Spans and
16//!   NodeIds) or "retracing" (like we had to do for `DefId` in earlier
17//!   implementations of the dependency graph).
18//! * A `Fingerprint` is just a bunch of bits, which allows `DepNode` to
19//!   implement `Copy`, `Sync`, `Send`, `Freeze`, etc.
20//! * Since we just have a bit pattern, `DepNode` can be mapped from disk into
21//!   memory without any post-processing (e.g., "abomination-style" pointer
22//!   reconstruction).
23//! * Because a `DepNode` is self-contained, we can instantiate `DepNodes` that
24//!   refer to things that do not exist anymore. In previous implementations
25//!   `DepNode` contained a `DefId`. A `DepNode` referring to something that
26//!   had been removed between the previous and the current compilation session
27//!   could not be instantiated because the current compilation session
28//!   contained no `DefId` for thing that had been removed.
29//!
30//! `DepNode` definition happens in `rustc_middle` with the
31//! `define_dep_nodes!()` macro. This macro defines the `DepKind` enum. Each
32//! `DepKind` has its own parameters that are needed at runtime in order to
33//! construct a valid `DepNode` fingerprint. However, only `CompileCodegenUnit`
34//! and `CompileMonoItem` are constructed explicitly (with
35//! `make_compile_codegen_unit` and `make_compile_mono_item`).
36//!
37//! Because the macro sees what parameters a given `DepKind` requires, it can
38//! "infer" some properties for each kind of `DepNode`:
39//!
40//! * Whether a `DepNode` of a given kind has any parameters at all. Some
41//!   `DepNode`s could represent global concepts with only one value.
42//! * Whether it is possible, in principle, to reconstruct a query key from a
43//!   given `DepNode`. Many `DepKind`s only require a single `DefId` parameter,
44//!   in which case it is possible to map the node's key fingerprint back to the
45//!   `DefId` it was computed from. In other cases, too much information gets
46//!   lost when computing a key fingerprint.
47//!
48//! [dependency graph]: https://rustc-dev-guide.rust-lang.org/query.html
49
50use std::fmt;
51use std::hash::Hash;
52
53use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
54use rustc_data_structures::stable_hash::{StableHasher, StableOrd};
55use rustc_hir::def_id::DefId;
56use rustc_hir::definitions::DefPathHash;
57use rustc_macros::{Decodable, Encodable, StableHash};
58use rustc_span::Symbol;
59
60use super::{DepNodeIndex, KeyFingerprintStyle, SerializedDepNodeIndex};
61use crate::dep_graph::DepNodeKey;
62use crate::mono::MonoItem;
63use crate::ty::{TyCtxt, tls};
64
65// `enum DepKind` is generated by `define_dep_nodes!` below.
66impl DepKind {
67    #[inline]
68    pub(crate) fn from_u16(u: u16) -> Self {
69        if u > Self::MAX {
70            { ::core::panicking::panic_fmt(format_args!("Invalid DepKind {0}", u)); };panic!("Invalid DepKind {u}");
71        }
72        // SAFETY: `DepKind` is `repr(u16)`, its variants are `0..=MAX`, and `u` was checked
73        // against `MAX` above.
74        unsafe { std::mem::transmute(u) }
75    }
76
77    #[inline]
78    pub(crate) const fn as_u16(&self) -> u16 {
79        *self as u16
80    }
81
82    #[inline]
83    pub const fn as_usize(&self) -> usize {
84        *self as usize
85    }
86
87    /// The number of dep kind variants.
88    pub(crate) const NUM_VARIANTS: usize = std::mem::variant_count::<DepKind>();
89
90    /// This is the highest value a `DepKind` can have. It's used during encoding to
91    /// pack information into the unused bits. u16 matches the `repr(u16)` on `DepKind`.
92    pub(crate) const MAX: u16 = {
93        let max = Self::NUM_VARIANTS - 1;
94        if !(max < u16::MAX as usize) {
    ::core::panicking::panic("assertion failed: max < u16::MAX as usize")
};assert!(max < u16::MAX as usize);
95        max as u16
96    };
97}
98
99/// Combination of a [`DepKind`] and a key fingerprint that uniquely identifies
100/// a node in the dep graph.
101#[derive(#[automatically_derived]
impl ::core::clone::Clone for DepNode {
    #[inline]
    fn clone(&self) -> DepNode {
        let _: ::core::clone::AssertParamIsClone<DepKind>;
        let _: ::core::clone::AssertParamIsClone<PackedFingerprint>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DepNode { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DepNode {
    #[inline]
    fn eq(&self, other: &DepNode) -> bool {
        self.kind == other.kind &&
            self.key_fingerprint == other.key_fingerprint
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DepNode {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<DepKind>;
        let _: ::core::cmp::AssertParamIsEq<PackedFingerprint>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DepNode {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.kind, state);
        ::core::hash::Hash::hash(&self.key_fingerprint, state)
    }
}Hash)]
102pub struct DepNode {
103    pub kind: DepKind,
104
105    /// If `kind` is a query method, then its "key fingerprint" is always a
106    /// stable hash of the query key.
107    ///
108    /// For non-query nodes, the content of this field varies:
109    /// - Some dep kinds always use a dummy `ZERO` fingerprint.
110    /// - Some dep kinds use the stable hash of some relevant key-like value.
111    /// - Some dep kinds use the `with_anon_task` mechanism, and set their key
112    ///   fingerprint to a hash derived from the task's dependencies.
113    ///
114    /// In some cases the key value can be reconstructed from this fingerprint;
115    /// see [`KeyFingerprintStyle`].
116    pub key_fingerprint: PackedFingerprint,
117}
118
119impl DepNode {
120    /// Creates a new, parameterless DepNode. This method will assert
121    /// that the DepNode corresponding to the given DepKind actually
122    /// does not require any parameters.
123    pub fn new_no_params<'tcx>(tcx: TyCtxt<'tcx>, kind: DepKind) -> DepNode {
124        if true {
    {
        match (&tcx.key_fingerprint_style(kind), &KeyFingerprintStyle::Unit) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    let kind = ::core::panicking::AssertKind::Eq;
                    ::core::panicking::assert_failed(kind, &*left_val,
                        &*right_val, ::core::option::Option::None);
                }
            }
        }
    };
};debug_assert_eq!(tcx.key_fingerprint_style(kind), KeyFingerprintStyle::Unit);
125        DepNode { kind, key_fingerprint: Fingerprint::ZERO.into() }
126    }
127
128    pub fn construct<'tcx, Key>(tcx: TyCtxt<'tcx>, kind: DepKind, key: &Key) -> DepNode
129    where
130        Key: DepNodeKey<'tcx>,
131    {
132        DepNode { kind, key_fingerprint: key.to_fingerprint(tcx).into() }
133    }
134
135    /// Construct a DepNode from the given DepKind and DefPathHash. This
136    /// method will assert that the given DepKind actually requires a
137    /// single DefId/DefPathHash parameter.
138    pub fn from_def_path_hash<'tcx>(
139        tcx: TyCtxt<'tcx>,
140        def_path_hash: DefPathHash,
141        kind: DepKind,
142    ) -> Self {
143        if true {
    if !(tcx.key_fingerprint_style(kind) == KeyFingerprintStyle::DefPathHash)
        {
        ::core::panicking::panic("assertion failed: tcx.key_fingerprint_style(kind) == KeyFingerprintStyle::DefPathHash")
    };
};debug_assert!(tcx.key_fingerprint_style(kind) == KeyFingerprintStyle::DefPathHash);
144        DepNode { kind, key_fingerprint: def_path_hash.0.into() }
145    }
146}
147
148impl fmt::Debug for DepNode {
149    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
150        tls::with_opt(|opt_tcx| {
151            if let Some(tcx) = opt_tcx
152                && let Some(def_id) = self.extract_def_id(tcx)
153            {
154                f.write_fmt(format_args!("{0:?}({1})", self.kind,
        tcx.def_path_debug_str(def_id)))write!(f, "{:?}({})", self.kind, tcx.def_path_debug_str(def_id))?;
155            } else {
156                f.write_fmt(format_args!("{0:?}({1})", self.kind, self.key_fingerprint))write!(f, "{:?}({})", self.kind, self.key_fingerprint)?;
157            }
158            Ok(())
159        })
160    }
161}
162
163/// This struct stores function pointers and other metadata for a particular DepKind.
164///
165/// Information is retrieved by indexing the `DEP_KINDS` array using the integer value
166/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
167/// jump table instead of large matches.
168pub struct DepKindVTable<'tcx> {
169    /// Eval-always queries do not track their dependencies, and are always recomputed, even if
170    /// their inputs have not changed since the last compiler invocation. The result is still
171    /// cached within one compiler invocation.
172    pub is_eval_always: bool,
173
174    /// Indicates whether and how a query key can be reconstructed from the
175    /// key fingerprint of a dep node with this [`DepKind`].
176    ///
177    /// The [`DepNodeKey`] trait determines the fingerprint style for each key type.
178    pub key_fingerprint_style: KeyFingerprintStyle,
179
180    /// The red/green evaluation system will try to mark a specific DepNode in the
181    /// dependency graph as green by recursively trying to mark the dependencies of
182    /// that `DepNode` as green. While doing so, it will sometimes encounter a `DepNode`
183    /// where we don't know if it is red or green and we therefore actually have
184    /// to recompute its value in order to find out. Since the only piece of
185    /// information that we have at that point is the `DepNode` we are trying to
186    /// re-evaluate, we need some way to re-run a query from just that. This is what
187    /// `force_from_dep_node()` implements.
188    ///
189    /// In the general case, a `DepNode` consists of a `DepKind` and an opaque
190    /// "key fingerprint" that will uniquely identify the node. This key fingerprint
191    /// is usually constructed by computing a stable hash of the query-key that the
192    /// `DepNode` corresponds to. Consequently, it is not in general possible to go
193    /// back from hash to query-key (since hash functions are not reversible). For
194    /// this reason `force_from_dep_node()` is expected to fail from time to time
195    /// because we just cannot find out, from the `DepNode` alone, what the
196    /// corresponding query-key is and therefore cannot re-run the query.
197    ///
198    /// The system deals with this case letting `try_mark_green` fail which forces
199    /// the root query to be re-evaluated.
200    ///
201    /// Now, if `force_from_dep_node()` would always fail, it would be pretty useless.
202    /// Fortunately, we can use some contextual information that will allow us to
203    /// reconstruct query-keys for certain kinds of `DepNode`s. In particular, we
204    /// enforce by construction that the key fingerprint of certain `DepNode`s is a
205    /// valid `DefPathHash`. Since we also always build a huge table that maps every
206    /// `DefPathHash` in the current codebase to the corresponding `DefId`, we have
207    /// everything we need to re-run the query.
208    ///
209    /// Take the `mir_promoted` query as an example. Like many other queries, it
210    /// just has a single parameter: the `DefId` of the item it will compute the
211    /// validated MIR for. Now, when we call `force_from_dep_node()` on a `DepNode`
212    /// with kind `mir_promoted`, we know that the key fingerprint of the `DepNode`
213    /// is actually a `DefPathHash`, and can therefore just look up the corresponding
214    /// `DefId` in `tcx.def_path_hash_to_def_id`.
215    pub force_from_dep_node_fn: Option<
216        fn(tcx: TyCtxt<'tcx>, dep_node: DepNode, prev_index: SerializedDepNodeIndex) -> bool,
217    >,
218
219    /// Load the on-disk cached value of a query into memory. The node is known
220    /// to be green, with `prev_index` its index in the previous session's dep
221    /// graph and `dep_node_index` its index in the current session's dep graph.
222    pub promote_from_disk_fn: Option<
223        fn(
224            tcx: TyCtxt<'tcx>,
225            dep_node: DepNode,
226            prev_index: SerializedDepNodeIndex,
227            dep_node_index: DepNodeIndex,
228        ),
229    >,
230}
231
232/// A "work product" corresponds to a `.o` (or other) file that we
233/// save in between runs. These IDs do not have a `DefId` but rather
234/// some independent path or string that persists between runs without
235/// the need to be mapped or unmapped. (This ensures we can serialize
236/// them even in the absence of a tcx.)
237#[derive(#[automatically_derived]
impl ::core::clone::Clone for WorkProductId {
    #[inline]
    fn clone(&self) -> WorkProductId {
        let _: ::core::clone::AssertParamIsClone<Fingerprint>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for WorkProductId { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for WorkProductId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "WorkProductId",
            "hash", &&self.hash)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for WorkProductId {
    #[inline]
    fn eq(&self, other: &WorkProductId) -> bool { self.hash == other.hash }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for WorkProductId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Fingerprint>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for WorkProductId {
    #[inline]
    fn partial_cmp(&self, other: &WorkProductId)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for WorkProductId {
    #[inline]
    fn cmp(&self, other: &WorkProductId) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.hash, &other.hash)
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for WorkProductId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.hash, state)
    }
}Hash)]
238#[derive(const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for WorkProductId {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    WorkProductId { hash: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for WorkProductId {
            fn decode(__decoder: &mut __D) -> Self {
                WorkProductId {
                    hash: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            WorkProductId {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    WorkProductId { hash: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
239pub struct WorkProductId {
240    hash: Fingerprint,
241}
242
243impl WorkProductId {
244    pub fn from_cgu_name(cgu_name: &str) -> WorkProductId {
245        let mut hasher = StableHasher::new();
246        cgu_name.hash(&mut hasher);
247        WorkProductId { hash: hasher.finish() }
248    }
249}
250
251impl StableOrd for WorkProductId {
252    // Fingerprint can use unstable (just a tuple of `u64`s), so WorkProductId can as well
253    const CAN_USE_UNSTABLE_SORT: bool = true;
254
255    // `WorkProductId` sort order is not affected by (de)serialization.
256    const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
257}
258
259// Note: `$K` and `$V` are unused but present so this can be called by `rustc_with_all_queries`.
260macro_rules! define_dep_nodes {
261    (
262        queries {
263            $(
264                $(#[$q_attr:meta])*
265                fn $q_name:ident($K:ty) -> $V:ty
266                // Search for (QMODLIST) to find all occurrences of this query modifier list.
267                // Query modifiers are currently not used here, so skip the whole list.
268                { $($modifiers:tt)* }
269            )*
270        }
271        non_queries {
272            $(
273                $(#[$nq_attr:meta])*
274                $nq_name:ident,
275            )*
276        }
277    ) => {
278        // This enum has more than u8::MAX variants so we need some kind of multi-byte
279        // encoding. The derived Encodable/Decodable uses leb128 encoding which is
280        // dense when only considering this enum. But DepKind is encoded in a larger
281        // struct, and there we can take advantage of the unused bits in the u16.
282        #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
283        #[allow(non_camel_case_types)]
284        #[repr(u16)] // Must be kept in sync with the rest of `DepKind`.
285        pub enum DepKind {
286            $( $(#[$nq_attr])* $nq_name, )*
287            $( $(#[$q_attr])* $q_name, )*
288        }
289
290        /// Converts a string to a `DepKind`. Used for handling attributes like `rustc_clean` that
291        /// name dep kinds.
292        fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
293            match label {
294                $( stringify!($nq_name) => Ok(self::DepKind::$nq_name), )*
295                $( stringify!($q_name) => Ok(self::DepKind::$q_name), )*
296                _ => Err(()),
297            }
298        }
299    };
300}
301
302// Create various data structures for each query, and also for a few things that aren't queries.
303#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::clone::Clone for DepKind {
    #[inline]
    fn clone(&self) -> DepKind { *self }
}
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::Copy for DepKind { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::fmt::Debug for DepKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        static __NAMES: &str =
            "NullRedSideEffectAnonZeroDepsTraitSelectCompileCodegenUnitCompileMonoItemMetadataderive_macro_expansiontrigger_delayed_bugregistered_attr_toolsregistered_lint_toolsearly_lint_checksenv_var_osresolutionsresolver_for_lowering_rawindex_astsource_spanlower_to_hirhir_ownerhir_crate_itemshir_module_itemshir_owner_parent_qhir_attr_mapconst_param_defaultconst_of_itemtype_oftype_of_opaquetype_of_opaque_hir_typecktype_alias_is_checkedcollect_return_position_impl_trait_in_trait_tysopaque_ty_originunsizing_params_for_adtanalysischeck_expectationsgenerics_ofclauses_ofopaque_types_defined_bynested_bodies_withinexplicit_item_boundsexplicit_item_self_boundsitem_boundsitem_self_boundsitem_non_self_boundsimpl_super_outlivesnative_librariesshallow_lint_levels_onlint_expectationsskippable_lintsexpn_that_definedis_panic_runtimecheck_representabilitycheck_representability_adt_typarams_in_reprthir_bodymir_keysmir_const_qualifmir_builtthir_abstract_constmir_drops_elaborated_and_const_checkedmir_for_ctfemir_promotedclosure_typeinfoclosure_saved_names_of_captured_variablesmir_coroutine_witnessescheck_coroutine_obligationscheck_potentially_region_dependent_goalsoptimized_mircoverage_attr_oncoverage_ids_infopromoted_mirerase_and_anonymize_regions_tywasm_import_module_maptrait_explicit_clauses_and_boundsexplicit_clauses_ofinferred_outlives_ofexplicit_super_clauses_ofexplicit_implied_clauses_ofexplicit_supertraits_containing_assoc_itemconst_conditionsexplicit_implied_const_boundstype_param_clausestrait_defadt_defadt_destructoradt_async_destructoradt_sizedness_constraintadt_dtorck_constraintconstnessasyncnessis_promotable_const_fncoroutine_by_move_body_def_idcoroutine_kindcoroutine_for_closurecoroutine_hidden_typescrate_variancesvariances_ofinferred_outlives_crateassociated_item_def_idsassociated_itemassociated_itemsimpl_item_implementor_idsassociated_types_for_impl_traits_in_trait_or_implimpl_trait_headerimpl_is_fully_generic_for_reflectionimpl_self_is_guaranteed_unsizedinherent_implsincoherent_implscheck_transmutescheck_offloadscheck_unsafetycheck_tail_callsassumed_wf_typesassumed_wf_types_for_rpititfn_siglint_modcheck_unused_traitscheck_mod_attrscheck_mod_unstable_api_usagecheck_mod_privacycheck_livenesslive_symbols_and_ignored_derived_traitscheck_mod_deathnesscheck_type_wfcoerce_unsized_infotypeck_rootused_trait_importscoherent_traitmir_borrowckcrate_inherent_implscrate_inherent_impls_validity_checkcrate_inherent_impls_overlap_checkorphan_check_implmir_callgraph_cyclicmir_inliner_calleestag_for_varianteval_to_allocation_raweval_static_initializereval_to_const_value_raweval_to_valtreevaltree_to_const_vallit_to_constcheck_matcheffective_visibilitiescheck_private_in_publicreachable_setregion_scope_treemir_shimssymbol_namedef_kinddef_spandef_ident_spanty_spanlookup_stabilitylookup_const_stabilitylookup_default_body_stabilityshould_inherit_track_callerinherited_alignlookup_deprecation_entryis_doc_hiddenis_doc_notable_traitattrs_for_defcodegen_fn_attrsasm_target_featuresfn_arg_identsrendered_constrendered_precise_capturing_argsimpl_parentis_mir_availableown_existential_vtable_entriesvtable_entriesfirst_method_vtable_slotsupertrait_vtable_slotvtable_allocationcodegen_select_candidateall_local_trait_implslocal_trait_implstrait_impls_ofspecialization_graph_ofdyn_compatibility_violationsis_dyn_compatibleparam_envparam_env_normalized_for_post_analysisis_copy_rawis_use_cloned_rawis_sized_rawis_freeze_rawis_unsafe_unpin_rawis_unpin_rawis_async_drop_rawneeds_drop_rawneeds_async_drop_rawhas_significant_drop_rawhas_structural_eq_impladt_drop_tysadt_async_drop_tysadt_significant_drop_tyslist_significant_drop_tyslayout_offn_abi_of_fn_ptrfn_abi_of_instance_no_deduced_attrsfn_abi_of_instance_rawdylib_dependency_formatsdependency_formatsis_compiler_builtinshas_global_allocatorhas_alloc_error_handlerhas_panic_handleris_profiler_runtimehas_ffi_unwind_callsrequired_panic_strategypanic_in_drop_strategyis_no_builtinssymbol_mangling_versionextern_cratespecialization_enabled_inspecializesdefaultnessdefault_fieldcheck_well_formedenforce_impl_non_lifetime_params_are_constrainedreachable_non_genericsis_reachable_non_genericis_unreachable_local_definitionupstream_monomorphizationsupstream_monomorphizations_forupstream_drop_glue_forupstream_async_drop_glue_forforeign_modulesclashing_extern_declarationsentry_fnproc_macro_decls_staticcrate_hashcrate_host_hashextra_filenamecrate_extern_pathsimplementations_of_traitcrate_incoherent_implsnative_libraryinherit_sig_for_delegation_itemdelegation_user_specified_argsresolve_bound_varsnamed_variable_mapis_late_bound_mapobject_lifetime_defaultlate_bound_vars_mapopaque_captured_lifetimeslive_args_for_alias_from_outlives_boundsargs_known_to_outlive_alias_paramsvisibilityinhabited_predicate_adtinhabited_predicate_typeis_opsem_inhabited_rawcrate_dep_kindcrate_namemodule_childrennum_extern_def_idslib_featuresstability_implicationsintrinsic_rawget_lang_itemsall_diagnostic_itemsall_canonical_symbolsdefined_lang_itemsdiagnostic_itemscanonical_symbolsmissing_lang_itemsvisible_parent_maptrimmed_def_pathsmissing_extern_crate_itemused_crate_sourcedebugger_visualizerspostorder_cnumsis_private_depallocator_kindalloc_error_handler_kindupvars_mentionedcratesused_cratesduplicate_crate_namestraitstrait_impls_in_cratestable_order_of_exportable_implsexportable_itemsexported_non_generic_symbolsexported_generic_symbolscollect_and_partition_mono_itemsis_codegened_itemcodegen_unitbackend_optimization_leveloutput_filenamesnormalize_canonicalized_projectionnormalize_canonicalized_free_aliasnormalize_canonicalized_inherent_projectiontry_normalize_generic_arg_after_erasing_regionsimplied_outlives_boundsmir_borrowck_implied_outlives_boundsdropck_outlivesevaluate_obligationtype_op_ascribe_user_typetype_op_prove_predicatetype_op_normalize_tytype_op_normalize_clausetype_op_normalize_poly_fn_sigtype_op_normalize_fn_siginstantiate_and_check_impossible_clausesis_impossible_associated_itemmethod_autoderef_stepsevaluate_root_goal_for_proof_tree_rawrust_target_featuresimplied_target_featuresfeatures_querycrate_for_resolverresolve_instance_rawreveal_opaque_types_in_boundslimitsdiagnostic_hir_wf_checkglobal_backend_featurescheck_validity_requirementcompare_impl_itemdeduced_param_attrsdoc_link_resolutionsdoc_link_traits_in_scopestripped_cfg_itemsgenerics_require_sized_selfcross_crate_inlinablecheck_mono_itemitems_of_instancesize_estimateanon_const_kindtrivial_constsanitizer_settings_forcheck_externally_implementable_itemsexternally_implementable_items";
        static __OFFSET: [usize; 335] =
            [0usize, 4usize, 7usize, 17usize, 29usize, 40usize, 58usize,
                    73usize, 81usize, 103usize, 122usize, 143usize, 164usize,
                    181usize, 191usize, 202usize, 227usize, 236usize, 247usize,
                    259usize, 268usize, 283usize, 299usize, 317usize, 329usize,
                    348usize, 361usize, 368usize, 382usize, 407usize, 428usize,
                    475usize, 491usize, 514usize, 522usize, 540usize, 551usize,
                    561usize, 584usize, 604usize, 624usize, 649usize, 660usize,
                    676usize, 696usize, 715usize, 731usize, 753usize, 770usize,
                    785usize, 802usize, 818usize, 840usize, 869usize, 883usize,
                    892usize, 900usize, 916usize, 925usize, 944usize, 982usize,
                    994usize, 1006usize, 1022usize, 1063usize, 1086usize,
                    1113usize, 1153usize, 1166usize, 1182usize, 1199usize,
                    1211usize, 1241usize, 1263usize, 1296usize, 1315usize,
                    1335usize, 1360usize, 1387usize, 1429usize, 1445usize,
                    1474usize, 1492usize, 1501usize, 1508usize, 1522usize,
                    1542usize, 1566usize, 1587usize, 1596usize, 1605usize,
                    1627usize, 1656usize, 1670usize, 1691usize, 1713usize,
                    1728usize, 1740usize, 1763usize, 1786usize, 1801usize,
                    1817usize, 1842usize, 1891usize, 1908usize, 1944usize,
                    1975usize, 1989usize, 2005usize, 2021usize, 2035usize,
                    2049usize, 2065usize, 2081usize, 2108usize, 2114usize,
                    2122usize, 2141usize, 2156usize, 2184usize, 2201usize,
                    2215usize, 2254usize, 2273usize, 2286usize, 2305usize,
                    2316usize, 2334usize, 2348usize, 2360usize, 2380usize,
                    2415usize, 2449usize, 2466usize, 2486usize, 2505usize,
                    2520usize, 2542usize, 2565usize, 2588usize, 2603usize,
                    2623usize, 2635usize, 2646usize, 2668usize, 2691usize,
                    2704usize, 2721usize, 2730usize, 2741usize, 2749usize,
                    2757usize, 2771usize, 2778usize, 2794usize, 2816usize,
                    2845usize, 2872usize, 2887usize, 2911usize, 2924usize,
                    2944usize, 2957usize, 2973usize, 2992usize, 3005usize,
                    3019usize, 3050usize, 3061usize, 3077usize, 3107usize,
                    3121usize, 3145usize, 3167usize, 3184usize, 3208usize,
                    3229usize, 3246usize, 3260usize, 3283usize, 3311usize,
                    3328usize, 3337usize, 3375usize, 3386usize, 3403usize,
                    3415usize, 3428usize, 3447usize, 3459usize, 3476usize,
                    3490usize, 3510usize, 3534usize, 3556usize, 3568usize,
                    3586usize, 3610usize, 3635usize, 3644usize, 3660usize,
                    3695usize, 3717usize, 3741usize, 3759usize, 3779usize,
                    3799usize, 3822usize, 3839usize, 3858usize, 3878usize,
                    3901usize, 3923usize, 3937usize, 3960usize, 3972usize,
                    3997usize, 4008usize, 4019usize, 4032usize, 4049usize,
                    4097usize, 4119usize, 4143usize, 4174usize, 4200usize,
                    4230usize, 4252usize, 4280usize, 4295usize, 4323usize,
                    4331usize, 4354usize, 4364usize, 4379usize, 4393usize,
                    4411usize, 4435usize, 4457usize, 4471usize, 4502usize,
                    4532usize, 4550usize, 4568usize, 4585usize, 4608usize,
                    4627usize, 4652usize, 4692usize, 4726usize, 4736usize,
                    4759usize, 4783usize, 4805usize, 4819usize, 4829usize,
                    4844usize, 4862usize, 4874usize, 4896usize, 4909usize,
                    4923usize, 4943usize, 4964usize, 4982usize, 4998usize,
                    5015usize, 5033usize, 5051usize, 5068usize, 5093usize,
                    5110usize, 5130usize, 5145usize, 5159usize, 5173usize,
                    5197usize, 5213usize, 5219usize, 5230usize, 5251usize,
                    5257usize, 5277usize, 5309usize, 5325usize, 5353usize,
                    5377usize, 5409usize, 5426usize, 5438usize, 5464usize,
                    5480usize, 5514usize, 5548usize, 5591usize, 5638usize,
                    5661usize, 5697usize, 5712usize, 5731usize, 5756usize,
                    5779usize, 5799usize, 5823usize, 5852usize, 5876usize,
                    5916usize, 5945usize, 5967usize, 6004usize, 6024usize,
                    6047usize, 6061usize, 6079usize, 6099usize, 6128usize,
                    6134usize, 6157usize, 6180usize, 6206usize, 6223usize,
                    6242usize, 6262usize, 6286usize, 6304usize, 6331usize,
                    6352usize, 6367usize, 6384usize, 6397usize, 6412usize,
                    6425usize, 6447usize, 6483usize, 6513usize];
        let __d = ::core::intrinsics::discriminant_value(self) as usize;
        ::core::fmt::Formatter::debug_c_like_enum_write_str(f, __NAMES,
            &__OFFSET, __d)
    }
}
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::StructuralPartialEq for DepKind { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::PartialEq for DepKind {
    #[inline]
    fn eq(&self, other: &DepKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::Eq for DepKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::hash::Hash for DepKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}
/// Converts a string to a `DepKind`. Used for handling attributes like `rustc_clean` that
/// name dep kinds.
fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
    match label {
        "Null" => Ok(self::DepKind::Null),
        "Red" => Ok(self::DepKind::Red),
        "SideEffect" => Ok(self::DepKind::SideEffect),
        "AnonZeroDeps" => Ok(self::DepKind::AnonZeroDeps),
        "TraitSelect" => Ok(self::DepKind::TraitSelect),
        "CompileCodegenUnit" => Ok(self::DepKind::CompileCodegenUnit),
        "CompileMonoItem" => Ok(self::DepKind::CompileMonoItem),
        "Metadata" => Ok(self::DepKind::Metadata),
        "derive_macro_expansion" => Ok(self::DepKind::derive_macro_expansion),
        "trigger_delayed_bug" => Ok(self::DepKind::trigger_delayed_bug),
        "registered_attr_tools" => Ok(self::DepKind::registered_attr_tools),
        "registered_lint_tools" => Ok(self::DepKind::registered_lint_tools),
        "early_lint_checks" => Ok(self::DepKind::early_lint_checks),
        "env_var_os" => Ok(self::DepKind::env_var_os),
        "resolutions" => Ok(self::DepKind::resolutions),
        "resolver_for_lowering_raw" =>
            Ok(self::DepKind::resolver_for_lowering_raw),
        "index_ast" => Ok(self::DepKind::index_ast),
        "source_span" => Ok(self::DepKind::source_span),
        "lower_to_hir" => Ok(self::DepKind::lower_to_hir),
        "hir_owner" => Ok(self::DepKind::hir_owner),
        "hir_crate_items" => Ok(self::DepKind::hir_crate_items),
        "hir_module_items" => Ok(self::DepKind::hir_module_items),
        "hir_owner_parent_q" => Ok(self::DepKind::hir_owner_parent_q),
        "hir_attr_map" => Ok(self::DepKind::hir_attr_map),
        "const_param_default" => Ok(self::DepKind::const_param_default),
        "const_of_item" => Ok(self::DepKind::const_of_item),
        "type_of" => Ok(self::DepKind::type_of),
        "type_of_opaque" => Ok(self::DepKind::type_of_opaque),
        "type_of_opaque_hir_typeck" =>
            Ok(self::DepKind::type_of_opaque_hir_typeck),
        "type_alias_is_checked" => Ok(self::DepKind::type_alias_is_checked),
        "collect_return_position_impl_trait_in_trait_tys" =>
            Ok(self::DepKind::collect_return_position_impl_trait_in_trait_tys),
        "opaque_ty_origin" => Ok(self::DepKind::opaque_ty_origin),
        "unsizing_params_for_adt" =>
            Ok(self::DepKind::unsizing_params_for_adt),
        "analysis" => Ok(self::DepKind::analysis),
        "check_expectations" => Ok(self::DepKind::check_expectations),
        "generics_of" => Ok(self::DepKind::generics_of),
        "clauses_of" => Ok(self::DepKind::clauses_of),
        "opaque_types_defined_by" =>
            Ok(self::DepKind::opaque_types_defined_by),
        "nested_bodies_within" => Ok(self::DepKind::nested_bodies_within),
        "explicit_item_bounds" => Ok(self::DepKind::explicit_item_bounds),
        "explicit_item_self_bounds" =>
            Ok(self::DepKind::explicit_item_self_bounds),
        "item_bounds" => Ok(self::DepKind::item_bounds),
        "item_self_bounds" => Ok(self::DepKind::item_self_bounds),
        "item_non_self_bounds" => Ok(self::DepKind::item_non_self_bounds),
        "impl_super_outlives" => Ok(self::DepKind::impl_super_outlives),
        "native_libraries" => Ok(self::DepKind::native_libraries),
        "shallow_lint_levels_on" => Ok(self::DepKind::shallow_lint_levels_on),
        "lint_expectations" => Ok(self::DepKind::lint_expectations),
        "skippable_lints" => Ok(self::DepKind::skippable_lints),
        "expn_that_defined" => Ok(self::DepKind::expn_that_defined),
        "is_panic_runtime" => Ok(self::DepKind::is_panic_runtime),
        "check_representability" => Ok(self::DepKind::check_representability),
        "check_representability_adt_ty" =>
            Ok(self::DepKind::check_representability_adt_ty),
        "params_in_repr" => Ok(self::DepKind::params_in_repr),
        "thir_body" => Ok(self::DepKind::thir_body),
        "mir_keys" => Ok(self::DepKind::mir_keys),
        "mir_const_qualif" => Ok(self::DepKind::mir_const_qualif),
        "mir_built" => Ok(self::DepKind::mir_built),
        "thir_abstract_const" => Ok(self::DepKind::thir_abstract_const),
        "mir_drops_elaborated_and_const_checked" =>
            Ok(self::DepKind::mir_drops_elaborated_and_const_checked),
        "mir_for_ctfe" => Ok(self::DepKind::mir_for_ctfe),
        "mir_promoted" => Ok(self::DepKind::mir_promoted),
        "closure_typeinfo" => Ok(self::DepKind::closure_typeinfo),
        "closure_saved_names_of_captured_variables" =>
            Ok(self::DepKind::closure_saved_names_of_captured_variables),
        "mir_coroutine_witnesses" =>
            Ok(self::DepKind::mir_coroutine_witnesses),
        "check_coroutine_obligations" =>
            Ok(self::DepKind::check_coroutine_obligations),
        "check_potentially_region_dependent_goals" =>
            Ok(self::DepKind::check_potentially_region_dependent_goals),
        "optimized_mir" => Ok(self::DepKind::optimized_mir),
        "coverage_attr_on" => Ok(self::DepKind::coverage_attr_on),
        "coverage_ids_info" => Ok(self::DepKind::coverage_ids_info),
        "promoted_mir" => Ok(self::DepKind::promoted_mir),
        "erase_and_anonymize_regions_ty" =>
            Ok(self::DepKind::erase_and_anonymize_regions_ty),
        "wasm_import_module_map" => Ok(self::DepKind::wasm_import_module_map),
        "trait_explicit_clauses_and_bounds" =>
            Ok(self::DepKind::trait_explicit_clauses_and_bounds),
        "explicit_clauses_of" => Ok(self::DepKind::explicit_clauses_of),
        "inferred_outlives_of" => Ok(self::DepKind::inferred_outlives_of),
        "explicit_super_clauses_of" =>
            Ok(self::DepKind::explicit_super_clauses_of),
        "explicit_implied_clauses_of" =>
            Ok(self::DepKind::explicit_implied_clauses_of),
        "explicit_supertraits_containing_assoc_item" =>
            Ok(self::DepKind::explicit_supertraits_containing_assoc_item),
        "const_conditions" => Ok(self::DepKind::const_conditions),
        "explicit_implied_const_bounds" =>
            Ok(self::DepKind::explicit_implied_const_bounds),
        "type_param_clauses" => Ok(self::DepKind::type_param_clauses),
        "trait_def" => Ok(self::DepKind::trait_def),
        "adt_def" => Ok(self::DepKind::adt_def),
        "adt_destructor" => Ok(self::DepKind::adt_destructor),
        "adt_async_destructor" => Ok(self::DepKind::adt_async_destructor),
        "adt_sizedness_constraint" =>
            Ok(self::DepKind::adt_sizedness_constraint),
        "adt_dtorck_constraint" => Ok(self::DepKind::adt_dtorck_constraint),
        "constness" => Ok(self::DepKind::constness),
        "asyncness" => Ok(self::DepKind::asyncness),
        "is_promotable_const_fn" => Ok(self::DepKind::is_promotable_const_fn),
        "coroutine_by_move_body_def_id" =>
            Ok(self::DepKind::coroutine_by_move_body_def_id),
        "coroutine_kind" => Ok(self::DepKind::coroutine_kind),
        "coroutine_for_closure" => Ok(self::DepKind::coroutine_for_closure),
        "coroutine_hidden_types" => Ok(self::DepKind::coroutine_hidden_types),
        "crate_variances" => Ok(self::DepKind::crate_variances),
        "variances_of" => Ok(self::DepKind::variances_of),
        "inferred_outlives_crate" =>
            Ok(self::DepKind::inferred_outlives_crate),
        "associated_item_def_ids" =>
            Ok(self::DepKind::associated_item_def_ids),
        "associated_item" => Ok(self::DepKind::associated_item),
        "associated_items" => Ok(self::DepKind::associated_items),
        "impl_item_implementor_ids" =>
            Ok(self::DepKind::impl_item_implementor_ids),
        "associated_types_for_impl_traits_in_trait_or_impl" =>
            Ok(self::DepKind::associated_types_for_impl_traits_in_trait_or_impl),
        "impl_trait_header" => Ok(self::DepKind::impl_trait_header),
        "impl_is_fully_generic_for_reflection" =>
            Ok(self::DepKind::impl_is_fully_generic_for_reflection),
        "impl_self_is_guaranteed_unsized" =>
            Ok(self::DepKind::impl_self_is_guaranteed_unsized),
        "inherent_impls" => Ok(self::DepKind::inherent_impls),
        "incoherent_impls" => Ok(self::DepKind::incoherent_impls),
        "check_transmutes" => Ok(self::DepKind::check_transmutes),
        "check_offloads" => Ok(self::DepKind::check_offloads),
        "check_unsafety" => Ok(self::DepKind::check_unsafety),
        "check_tail_calls" => Ok(self::DepKind::check_tail_calls),
        "assumed_wf_types" => Ok(self::DepKind::assumed_wf_types),
        "assumed_wf_types_for_rpitit" =>
            Ok(self::DepKind::assumed_wf_types_for_rpitit),
        "fn_sig" => Ok(self::DepKind::fn_sig),
        "lint_mod" => Ok(self::DepKind::lint_mod),
        "check_unused_traits" => Ok(self::DepKind::check_unused_traits),
        "check_mod_attrs" => Ok(self::DepKind::check_mod_attrs),
        "check_mod_unstable_api_usage" =>
            Ok(self::DepKind::check_mod_unstable_api_usage),
        "check_mod_privacy" => Ok(self::DepKind::check_mod_privacy),
        "check_liveness" => Ok(self::DepKind::check_liveness),
        "live_symbols_and_ignored_derived_traits" =>
            Ok(self::DepKind::live_symbols_and_ignored_derived_traits),
        "check_mod_deathness" => Ok(self::DepKind::check_mod_deathness),
        "check_type_wf" => Ok(self::DepKind::check_type_wf),
        "coerce_unsized_info" => Ok(self::DepKind::coerce_unsized_info),
        "typeck_root" => Ok(self::DepKind::typeck_root),
        "used_trait_imports" => Ok(self::DepKind::used_trait_imports),
        "coherent_trait" => Ok(self::DepKind::coherent_trait),
        "mir_borrowck" => Ok(self::DepKind::mir_borrowck),
        "crate_inherent_impls" => Ok(self::DepKind::crate_inherent_impls),
        "crate_inherent_impls_validity_check" =>
            Ok(self::DepKind::crate_inherent_impls_validity_check),
        "crate_inherent_impls_overlap_check" =>
            Ok(self::DepKind::crate_inherent_impls_overlap_check),
        "orphan_check_impl" => Ok(self::DepKind::orphan_check_impl),
        "mir_callgraph_cyclic" => Ok(self::DepKind::mir_callgraph_cyclic),
        "mir_inliner_callees" => Ok(self::DepKind::mir_inliner_callees),
        "tag_for_variant" => Ok(self::DepKind::tag_for_variant),
        "eval_to_allocation_raw" => Ok(self::DepKind::eval_to_allocation_raw),
        "eval_static_initializer" =>
            Ok(self::DepKind::eval_static_initializer),
        "eval_to_const_value_raw" =>
            Ok(self::DepKind::eval_to_const_value_raw),
        "eval_to_valtree" => Ok(self::DepKind::eval_to_valtree),
        "valtree_to_const_val" => Ok(self::DepKind::valtree_to_const_val),
        "lit_to_const" => Ok(self::DepKind::lit_to_const),
        "check_match" => Ok(self::DepKind::check_match),
        "effective_visibilities" => Ok(self::DepKind::effective_visibilities),
        "check_private_in_public" =>
            Ok(self::DepKind::check_private_in_public),
        "reachable_set" => Ok(self::DepKind::reachable_set),
        "region_scope_tree" => Ok(self::DepKind::region_scope_tree),
        "mir_shims" => Ok(self::DepKind::mir_shims),
        "symbol_name" => Ok(self::DepKind::symbol_name),
        "def_kind" => Ok(self::DepKind::def_kind),
        "def_span" => Ok(self::DepKind::def_span),
        "def_ident_span" => Ok(self::DepKind::def_ident_span),
        "ty_span" => Ok(self::DepKind::ty_span),
        "lookup_stability" => Ok(self::DepKind::lookup_stability),
        "lookup_const_stability" => Ok(self::DepKind::lookup_const_stability),
        "lookup_default_body_stability" =>
            Ok(self::DepKind::lookup_default_body_stability),
        "should_inherit_track_caller" =>
            Ok(self::DepKind::should_inherit_track_caller),
        "inherited_align" => Ok(self::DepKind::inherited_align),
        "lookup_deprecation_entry" =>
            Ok(self::DepKind::lookup_deprecation_entry),
        "is_doc_hidden" => Ok(self::DepKind::is_doc_hidden),
        "is_doc_notable_trait" => Ok(self::DepKind::is_doc_notable_trait),
        "attrs_for_def" => Ok(self::DepKind::attrs_for_def),
        "codegen_fn_attrs" => Ok(self::DepKind::codegen_fn_attrs),
        "asm_target_features" => Ok(self::DepKind::asm_target_features),
        "fn_arg_idents" => Ok(self::DepKind::fn_arg_idents),
        "rendered_const" => Ok(self::DepKind::rendered_const),
        "rendered_precise_capturing_args" =>
            Ok(self::DepKind::rendered_precise_capturing_args),
        "impl_parent" => Ok(self::DepKind::impl_parent),
        "is_mir_available" => Ok(self::DepKind::is_mir_available),
        "own_existential_vtable_entries" =>
            Ok(self::DepKind::own_existential_vtable_entries),
        "vtable_entries" => Ok(self::DepKind::vtable_entries),
        "first_method_vtable_slot" =>
            Ok(self::DepKind::first_method_vtable_slot),
        "supertrait_vtable_slot" => Ok(self::DepKind::supertrait_vtable_slot),
        "vtable_allocation" => Ok(self::DepKind::vtable_allocation),
        "codegen_select_candidate" =>
            Ok(self::DepKind::codegen_select_candidate),
        "all_local_trait_impls" => Ok(self::DepKind::all_local_trait_impls),
        "local_trait_impls" => Ok(self::DepKind::local_trait_impls),
        "trait_impls_of" => Ok(self::DepKind::trait_impls_of),
        "specialization_graph_of" =>
            Ok(self::DepKind::specialization_graph_of),
        "dyn_compatibility_violations" =>
            Ok(self::DepKind::dyn_compatibility_violations),
        "is_dyn_compatible" => Ok(self::DepKind::is_dyn_compatible),
        "param_env" => Ok(self::DepKind::param_env),
        "param_env_normalized_for_post_analysis" =>
            Ok(self::DepKind::param_env_normalized_for_post_analysis),
        "is_copy_raw" => Ok(self::DepKind::is_copy_raw),
        "is_use_cloned_raw" => Ok(self::DepKind::is_use_cloned_raw),
        "is_sized_raw" => Ok(self::DepKind::is_sized_raw),
        "is_freeze_raw" => Ok(self::DepKind::is_freeze_raw),
        "is_unsafe_unpin_raw" => Ok(self::DepKind::is_unsafe_unpin_raw),
        "is_unpin_raw" => Ok(self::DepKind::is_unpin_raw),
        "is_async_drop_raw" => Ok(self::DepKind::is_async_drop_raw),
        "needs_drop_raw" => Ok(self::DepKind::needs_drop_raw),
        "needs_async_drop_raw" => Ok(self::DepKind::needs_async_drop_raw),
        "has_significant_drop_raw" =>
            Ok(self::DepKind::has_significant_drop_raw),
        "has_structural_eq_impl" => Ok(self::DepKind::has_structural_eq_impl),
        "adt_drop_tys" => Ok(self::DepKind::adt_drop_tys),
        "adt_async_drop_tys" => Ok(self::DepKind::adt_async_drop_tys),
        "adt_significant_drop_tys" =>
            Ok(self::DepKind::adt_significant_drop_tys),
        "list_significant_drop_tys" =>
            Ok(self::DepKind::list_significant_drop_tys),
        "layout_of" => Ok(self::DepKind::layout_of),
        "fn_abi_of_fn_ptr" => Ok(self::DepKind::fn_abi_of_fn_ptr),
        "fn_abi_of_instance_no_deduced_attrs" =>
            Ok(self::DepKind::fn_abi_of_instance_no_deduced_attrs),
        "fn_abi_of_instance_raw" => Ok(self::DepKind::fn_abi_of_instance_raw),
        "dylib_dependency_formats" =>
            Ok(self::DepKind::dylib_dependency_formats),
        "dependency_formats" => Ok(self::DepKind::dependency_formats),
        "is_compiler_builtins" => Ok(self::DepKind::is_compiler_builtins),
        "has_global_allocator" => Ok(self::DepKind::has_global_allocator),
        "has_alloc_error_handler" =>
            Ok(self::DepKind::has_alloc_error_handler),
        "has_panic_handler" => Ok(self::DepKind::has_panic_handler),
        "is_profiler_runtime" => Ok(self::DepKind::is_profiler_runtime),
        "has_ffi_unwind_calls" => Ok(self::DepKind::has_ffi_unwind_calls),
        "required_panic_strategy" =>
            Ok(self::DepKind::required_panic_strategy),
        "panic_in_drop_strategy" => Ok(self::DepKind::panic_in_drop_strategy),
        "is_no_builtins" => Ok(self::DepKind::is_no_builtins),
        "symbol_mangling_version" =>
            Ok(self::DepKind::symbol_mangling_version),
        "extern_crate" => Ok(self::DepKind::extern_crate),
        "specialization_enabled_in" =>
            Ok(self::DepKind::specialization_enabled_in),
        "specializes" => Ok(self::DepKind::specializes),
        "defaultness" => Ok(self::DepKind::defaultness),
        "default_field" => Ok(self::DepKind::default_field),
        "check_well_formed" => Ok(self::DepKind::check_well_formed),
        "enforce_impl_non_lifetime_params_are_constrained" =>
            Ok(self::DepKind::enforce_impl_non_lifetime_params_are_constrained),
        "reachable_non_generics" => Ok(self::DepKind::reachable_non_generics),
        "is_reachable_non_generic" =>
            Ok(self::DepKind::is_reachable_non_generic),
        "is_unreachable_local_definition" =>
            Ok(self::DepKind::is_unreachable_local_definition),
        "upstream_monomorphizations" =>
            Ok(self::DepKind::upstream_monomorphizations),
        "upstream_monomorphizations_for" =>
            Ok(self::DepKind::upstream_monomorphizations_for),
        "upstream_drop_glue_for" => Ok(self::DepKind::upstream_drop_glue_for),
        "upstream_async_drop_glue_for" =>
            Ok(self::DepKind::upstream_async_drop_glue_for),
        "foreign_modules" => Ok(self::DepKind::foreign_modules),
        "clashing_extern_declarations" =>
            Ok(self::DepKind::clashing_extern_declarations),
        "entry_fn" => Ok(self::DepKind::entry_fn),
        "proc_macro_decls_static" =>
            Ok(self::DepKind::proc_macro_decls_static),
        "crate_hash" => Ok(self::DepKind::crate_hash),
        "crate_host_hash" => Ok(self::DepKind::crate_host_hash),
        "extra_filename" => Ok(self::DepKind::extra_filename),
        "crate_extern_paths" => Ok(self::DepKind::crate_extern_paths),
        "implementations_of_trait" =>
            Ok(self::DepKind::implementations_of_trait),
        "crate_incoherent_impls" => Ok(self::DepKind::crate_incoherent_impls),
        "native_library" => Ok(self::DepKind::native_library),
        "inherit_sig_for_delegation_item" =>
            Ok(self::DepKind::inherit_sig_for_delegation_item),
        "delegation_user_specified_args" =>
            Ok(self::DepKind::delegation_user_specified_args),
        "resolve_bound_vars" => Ok(self::DepKind::resolve_bound_vars),
        "named_variable_map" => Ok(self::DepKind::named_variable_map),
        "is_late_bound_map" => Ok(self::DepKind::is_late_bound_map),
        "object_lifetime_default" =>
            Ok(self::DepKind::object_lifetime_default),
        "late_bound_vars_map" => Ok(self::DepKind::late_bound_vars_map),
        "opaque_captured_lifetimes" =>
            Ok(self::DepKind::opaque_captured_lifetimes),
        "live_args_for_alias_from_outlives_bounds" =>
            Ok(self::DepKind::live_args_for_alias_from_outlives_bounds),
        "args_known_to_outlive_alias_params" =>
            Ok(self::DepKind::args_known_to_outlive_alias_params),
        "visibility" => Ok(self::DepKind::visibility),
        "inhabited_predicate_adt" =>
            Ok(self::DepKind::inhabited_predicate_adt),
        "inhabited_predicate_type" =>
            Ok(self::DepKind::inhabited_predicate_type),
        "is_opsem_inhabited_raw" => Ok(self::DepKind::is_opsem_inhabited_raw),
        "crate_dep_kind" => Ok(self::DepKind::crate_dep_kind),
        "crate_name" => Ok(self::DepKind::crate_name),
        "module_children" => Ok(self::DepKind::module_children),
        "num_extern_def_ids" => Ok(self::DepKind::num_extern_def_ids),
        "lib_features" => Ok(self::DepKind::lib_features),
        "stability_implications" => Ok(self::DepKind::stability_implications),
        "intrinsic_raw" => Ok(self::DepKind::intrinsic_raw),
        "get_lang_items" => Ok(self::DepKind::get_lang_items),
        "all_diagnostic_items" => Ok(self::DepKind::all_diagnostic_items),
        "all_canonical_symbols" => Ok(self::DepKind::all_canonical_symbols),
        "defined_lang_items" => Ok(self::DepKind::defined_lang_items),
        "diagnostic_items" => Ok(self::DepKind::diagnostic_items),
        "canonical_symbols" => Ok(self::DepKind::canonical_symbols),
        "missing_lang_items" => Ok(self::DepKind::missing_lang_items),
        "visible_parent_map" => Ok(self::DepKind::visible_parent_map),
        "trimmed_def_paths" => Ok(self::DepKind::trimmed_def_paths),
        "missing_extern_crate_item" =>
            Ok(self::DepKind::missing_extern_crate_item),
        "used_crate_source" => Ok(self::DepKind::used_crate_source),
        "debugger_visualizers" => Ok(self::DepKind::debugger_visualizers),
        "postorder_cnums" => Ok(self::DepKind::postorder_cnums),
        "is_private_dep" => Ok(self::DepKind::is_private_dep),
        "allocator_kind" => Ok(self::DepKind::allocator_kind),
        "alloc_error_handler_kind" =>
            Ok(self::DepKind::alloc_error_handler_kind),
        "upvars_mentioned" => Ok(self::DepKind::upvars_mentioned),
        "crates" => Ok(self::DepKind::crates),
        "used_crates" => Ok(self::DepKind::used_crates),
        "duplicate_crate_names" => Ok(self::DepKind::duplicate_crate_names),
        "traits" => Ok(self::DepKind::traits),
        "trait_impls_in_crate" => Ok(self::DepKind::trait_impls_in_crate),
        "stable_order_of_exportable_impls" =>
            Ok(self::DepKind::stable_order_of_exportable_impls),
        "exportable_items" => Ok(self::DepKind::exportable_items),
        "exported_non_generic_symbols" =>
            Ok(self::DepKind::exported_non_generic_symbols),
        "exported_generic_symbols" =>
            Ok(self::DepKind::exported_generic_symbols),
        "collect_and_partition_mono_items" =>
            Ok(self::DepKind::collect_and_partition_mono_items),
        "is_codegened_item" => Ok(self::DepKind::is_codegened_item),
        "codegen_unit" => Ok(self::DepKind::codegen_unit),
        "backend_optimization_level" =>
            Ok(self::DepKind::backend_optimization_level),
        "output_filenames" => Ok(self::DepKind::output_filenames),
        "normalize_canonicalized_projection" =>
            Ok(self::DepKind::normalize_canonicalized_projection),
        "normalize_canonicalized_free_alias" =>
            Ok(self::DepKind::normalize_canonicalized_free_alias),
        "normalize_canonicalized_inherent_projection" =>
            Ok(self::DepKind::normalize_canonicalized_inherent_projection),
        "try_normalize_generic_arg_after_erasing_regions" =>
            Ok(self::DepKind::try_normalize_generic_arg_after_erasing_regions),
        "implied_outlives_bounds" =>
            Ok(self::DepKind::implied_outlives_bounds),
        "mir_borrowck_implied_outlives_bounds" =>
            Ok(self::DepKind::mir_borrowck_implied_outlives_bounds),
        "dropck_outlives" => Ok(self::DepKind::dropck_outlives),
        "evaluate_obligation" => Ok(self::DepKind::evaluate_obligation),
        "type_op_ascribe_user_type" =>
            Ok(self::DepKind::type_op_ascribe_user_type),
        "type_op_prove_predicate" =>
            Ok(self::DepKind::type_op_prove_predicate),
        "type_op_normalize_ty" => Ok(self::DepKind::type_op_normalize_ty),
        "type_op_normalize_clause" =>
            Ok(self::DepKind::type_op_normalize_clause),
        "type_op_normalize_poly_fn_sig" =>
            Ok(self::DepKind::type_op_normalize_poly_fn_sig),
        "type_op_normalize_fn_sig" =>
            Ok(self::DepKind::type_op_normalize_fn_sig),
        "instantiate_and_check_impossible_clauses" =>
            Ok(self::DepKind::instantiate_and_check_impossible_clauses),
        "is_impossible_associated_item" =>
            Ok(self::DepKind::is_impossible_associated_item),
        "method_autoderef_steps" => Ok(self::DepKind::method_autoderef_steps),
        "evaluate_root_goal_for_proof_tree_raw" =>
            Ok(self::DepKind::evaluate_root_goal_for_proof_tree_raw),
        "rust_target_features" => Ok(self::DepKind::rust_target_features),
        "implied_target_features" =>
            Ok(self::DepKind::implied_target_features),
        "features_query" => Ok(self::DepKind::features_query),
        "crate_for_resolver" => Ok(self::DepKind::crate_for_resolver),
        "resolve_instance_raw" => Ok(self::DepKind::resolve_instance_raw),
        "reveal_opaque_types_in_bounds" =>
            Ok(self::DepKind::reveal_opaque_types_in_bounds),
        "limits" => Ok(self::DepKind::limits),
        "diagnostic_hir_wf_check" =>
            Ok(self::DepKind::diagnostic_hir_wf_check),
        "global_backend_features" =>
            Ok(self::DepKind::global_backend_features),
        "check_validity_requirement" =>
            Ok(self::DepKind::check_validity_requirement),
        "compare_impl_item" => Ok(self::DepKind::compare_impl_item),
        "deduced_param_attrs" => Ok(self::DepKind::deduced_param_attrs),
        "doc_link_resolutions" => Ok(self::DepKind::doc_link_resolutions),
        "doc_link_traits_in_scope" =>
            Ok(self::DepKind::doc_link_traits_in_scope),
        "stripped_cfg_items" => Ok(self::DepKind::stripped_cfg_items),
        "generics_require_sized_self" =>
            Ok(self::DepKind::generics_require_sized_self),
        "cross_crate_inlinable" => Ok(self::DepKind::cross_crate_inlinable),
        "check_mono_item" => Ok(self::DepKind::check_mono_item),
        "items_of_instance" => Ok(self::DepKind::items_of_instance),
        "size_estimate" => Ok(self::DepKind::size_estimate),
        "anon_const_kind" => Ok(self::DepKind::anon_const_kind),
        "trivial_const" => Ok(self::DepKind::trivial_const),
        "sanitizer_settings_for" => Ok(self::DepKind::sanitizer_settings_for),
        "check_externally_implementable_items" =>
            Ok(self::DepKind::check_externally_implementable_items),
        "externally_implementable_items" =>
            Ok(self::DepKind::externally_implementable_items),
        _ => Err(()),
    }
}crate::queries::rustc_with_all_queries! { define_dep_nodes! }
304
305// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
306// Be very careful changing this type signature!
307pub(crate) fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode {
308    DepNode::construct(tcx, DepKind::CompileCodegenUnit, &name)
309}
310
311// WARNING: `construct` is generic and does not know that `CompileMonoItem` takes `MonoItem`s as keys.
312// Be very careful changing this type signature!
313pub(crate) fn make_compile_mono_item<'tcx>(
314    tcx: TyCtxt<'tcx>,
315    mono_item: &MonoItem<'tcx>,
316) -> DepNode {
317    DepNode::construct(tcx, DepKind::CompileMonoItem, mono_item)
318}
319
320// WARNING: `construct` is generic and does not know that `Metadata` takes `()`s as keys.
321// Be very careful changing this type signature!
322pub(crate) fn make_metadata(tcx: TyCtxt<'_>) -> DepNode {
323    DepNode::construct(tcx, DepKind::Metadata, &())
324}
325
326impl DepNode {
327    /// Extracts the DefId corresponding to this DepNode. This will work
328    /// if two conditions are met:
329    ///
330    /// 1. The Fingerprint of the DepNode actually is a DefPathHash, and
331    /// 2. the item that the DefPath refers to exists in the current tcx.
332    ///
333    /// Condition (1) is determined by the DepKind variant of the
334    /// DepNode. Condition (2) might not be fulfilled if a DepNode
335    /// refers to something from the previous compilation session that
336    /// has been removed.
337    pub fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
338        if tcx.key_fingerprint_style(self.kind) == KeyFingerprintStyle::DefPathHash {
339            tcx.def_path_hash_to_def_id(DefPathHash(self.key_fingerprint.into()))
340        } else {
341            None
342        }
343    }
344
345    pub fn from_label_string(
346        tcx: TyCtxt<'_>,
347        label: &str,
348        def_path_hash: DefPathHash,
349    ) -> Result<DepNode, ()> {
350        let kind = dep_kind_from_label_string(label)?;
351
352        match tcx.key_fingerprint_style(kind) {
353            KeyFingerprintStyle::Opaque | KeyFingerprintStyle::HirId => Err(()),
354            KeyFingerprintStyle::Unit => Ok(DepNode::new_no_params(tcx, kind)),
355            KeyFingerprintStyle::DefPathHash => {
356                Ok(DepNode::from_def_path_hash(tcx, def_path_hash, kind))
357            }
358        }
359    }
360
361    pub fn has_label_string(label: &str) -> bool {
362        dep_kind_from_label_string(label).is_ok()
363    }
364}
365
366/// Maps a query label to its DepKind. Panics if a query with the given label does not exist.
367pub fn dep_kind_from_label(label: &str) -> DepKind {
368    dep_kind_from_label_string(label)
369        .unwrap_or_else(|_| {
    ::core::panicking::panic_fmt(format_args!("Query label {0} does not exist",
            label));
}panic!("Query label {label} does not exist"))
370}
371
372// Some types are used a lot. Make sure they don't unintentionally get bigger.
373#[cfg(target_pointer_width = "64")]
374mod size_asserts {
375    use rustc_data_structures::static_assert_size;
376
377    use super::*;
378    // tidy-alphabetical-start
379    const _: [(); 2] = [(); ::std::mem::size_of::<DepKind>()];static_assert_size!(DepKind, 2);
380    const _: [(); 18] = [(); ::std::mem::size_of::<DepNode>()];static_assert_size!(DepNode, 18);
381    // tidy-alphabetical-end
382}