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(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(Debug, HashStable_Generic)]
23pub enum DelayedLint {
24 AttributeParsing(AttributeLint<HirId>),
25}
26
27#[derive(Debug, HashStable_Generic)]
28pub struct AttributeLint<Id> {
29 pub lint_id: LintId,
30 pub id: Id,
31 pub span: Span,
32 pub kind: AttributeLintKind,
33}