Skip to main content

rustc_middle/middle/
dead_code.rs

1use rustc_data_structures::fx::FxIndexSet;
2use rustc_hir::def_id::{DefId, LocalDefIdMap, LocalDefIdSet};
3use rustc_macros::StableHash;
4
5/// A single snapshot of dead-code liveness analysis state.
6#[derive(#[automatically_derived]
impl ::core::clone::Clone for DeadCodeLivenessSnapshot {
    #[inline]
    fn clone(&self) -> DeadCodeLivenessSnapshot {
        DeadCodeLivenessSnapshot {
            live_symbols: ::core::clone::Clone::clone(&self.live_symbols),
            ignored_derived_traits: ::core::clone::Clone::clone(&self.ignored_derived_traits),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DeadCodeLivenessSnapshot {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "DeadCodeLivenessSnapshot", "live_symbols", &self.live_symbols,
            "ignored_derived_traits", &&self.ignored_derived_traits)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hasher::StableHash for
            DeadCodeLivenessSnapshot {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    DeadCodeLivenessSnapshot {
                        live_symbols: ref __binding_0,
                        ignored_derived_traits: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
7pub struct DeadCodeLivenessSnapshot {
8    pub live_symbols: LocalDefIdSet,
9    /// Maps each ADT to derived traits (for example `Debug` and `Clone`) that should be ignored
10    /// when checking for dead code diagnostics.
11    pub ignored_derived_traits: LocalDefIdMap<FxIndexSet<DefId>>,
12}
13
14/// Dead-code liveness data for both analysis phases.
15///
16/// `pre_deferred_seeding` is computed before reachable-public and `#[allow(dead_code)]` seeding,
17/// and is used for lint `dead_code_pub_in_binary`.
18/// `final_result` is the final liveness snapshot used for lint `dead_code`.
19#[derive(#[automatically_derived]
impl ::core::clone::Clone for DeadCodeLivenessSummary {
    #[inline]
    fn clone(&self) -> DeadCodeLivenessSummary {
        DeadCodeLivenessSummary {
            pre_deferred_seeding: ::core::clone::Clone::clone(&self.pre_deferred_seeding),
            final_result: ::core::clone::Clone::clone(&self.final_result),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DeadCodeLivenessSummary {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "DeadCodeLivenessSummary", "pre_deferred_seeding",
            &self.pre_deferred_seeding, "final_result", &&self.final_result)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hasher::StableHash for
            DeadCodeLivenessSummary {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    DeadCodeLivenessSummary {
                        pre_deferred_seeding: ref __binding_0,
                        final_result: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
20pub struct DeadCodeLivenessSummary {
21    pub pre_deferred_seeding: DeadCodeLivenessSnapshot,
22    pub final_result: DeadCodeLivenessSnapshot,
23}