rustc_hir/
lints.rs

1use rustc_data_structures::fingerprint::Fingerprint;
2pub use rustc_lint_defs::AttributeLintKind;
3use rustc_lint_defs::LintId;
4use rustc_macros::HashStable_Generic;
5use rustc_span::Span;
6
7use crate::HirId;
8
9#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelayedLints {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "DelayedLints",
            "lints", &self.lints, "opt_hash", &&self.opt_hash)
    }
}Debug)]
10pub struct DelayedLints {
11    pub lints: Box<[DelayedLint]>,
12    // Only present when the crate hash is needed.
13    pub opt_hash: Option<Fingerprint>,
14}
15
16/// During ast lowering, no lints can be emitted.
17/// That is because lints attach to nodes either in the AST, or on the built HIR.
18/// When attached to AST nodes, they're emitted just before building HIR,
19/// and then there's a gap where no lints can be emitted until HIR is done.
20/// The variants in this enum represent lints that are temporarily stashed during
21/// AST lowering to be emitted once HIR is built.
22#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelayedLint {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            DelayedLint::AttributeParsing(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "AttributeParsing", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for DelayedLint where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    DelayedLint::AttributeParsing(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
23pub enum DelayedLint {
24    AttributeParsing(AttributeLint<HirId>),
25}
26
27#[derive(#[automatically_derived]
impl<Id: ::core::fmt::Debug> ::core::fmt::Debug for AttributeLint<Id> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "AttributeLint",
            "lint_id", &self.lint_id, "id", &self.id, "span", &self.span,
            "kind", &&self.kind)
    }
}Debug, const _: () =
    {
        impl<Id, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            AttributeLint<Id> where __CTX: crate::HashStableContext,
            Id: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    AttributeLint {
                        lint_id: ref __binding_0,
                        id: ref __binding_1,
                        span: ref __binding_2,
                        kind: ref __binding_3 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
28pub struct AttributeLint<Id> {
29    pub lint_id: LintId,
30    pub id: Id,
31    pub span: Span,
32    pub kind: AttributeLintKind,
33}