rustc_hir/
lints.rs

1use rustc_data_structures::fingerprint::Fingerprint;
2use rustc_macros::HashStable_Generic;
3use rustc_span::Span;
4
5use crate::{AttrPath, HirId, Target};
6
7#[derive(Debug)]
8pub struct DelayedLints {
9    pub lints: Box<[DelayedLint]>,
10    // Only present when the crate hash is needed.
11    pub opt_hash: Option<Fingerprint>,
12}
13
14/// During ast lowering, no lints can be emitted.
15/// That is because lints attach to nodes either in the AST, or on the built HIR.
16/// When attached to AST nodes, they're emitted just before building HIR,
17/// and then there's a gap where no lints can be emitted until HIR is done.
18/// The variants in this enum represent lints that are temporarily stashed during
19/// AST lowering to be emitted once HIR is built.
20#[derive(Clone, Debug, HashStable_Generic)]
21pub enum DelayedLint {
22    AttributeParsing(AttributeLint<HirId>),
23}
24
25#[derive(Clone, Debug, HashStable_Generic)]
26pub struct AttributeLint<Id> {
27    pub id: Id,
28    pub span: Span,
29    pub kind: AttributeLintKind,
30}
31
32#[derive(Clone, Debug, HashStable_Generic)]
33pub enum AttributeLintKind {
34    /// Copy of `IllFormedAttributeInput`
35    /// specifically for the `invalid_macro_export_arguments` lint until that is removed,
36    /// see <https://github.com/rust-lang/rust/pull/143857#issuecomment-3079175663>
37    InvalidMacroExportArguments {
38        suggestions: Vec<String>,
39    },
40    UnusedDuplicate {
41        this: Span,
42        other: Span,
43        warning: bool,
44    },
45    IllFormedAttributeInput {
46        suggestions: Vec<String>,
47    },
48    EmptyAttribute {
49        first_span: Span,
50        attr_path: AttrPath,
51        valid_without_list: bool,
52    },
53    InvalidTarget {
54        name: AttrPath,
55        target: Target,
56        applied: Vec<String>,
57        only: &'static str,
58    },
59    InvalidStyle {
60        name: AttrPath,
61        is_used_as_inner: bool,
62        target: Target,
63        target_span: Span,
64    },
65}