summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_query_system/src/error.rs
blob: 7a20eaceba0247682a7ae74451ddcbf3eeeb7772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_session::Limit;
use rustc_span::{Span, Symbol};

#[derive(Subdiagnostic)]
#[note(query_system_cycle_stack_middle)]
pub struct CycleStack {
    #[primary_span]
    pub span: Span,
    pub desc: String,
}

#[derive(Copy, Clone)]
pub enum HandleCycleError {
    Error,
    Fatal,
    DelayBug,
}

#[derive(Subdiagnostic)]
pub enum StackCount {
    #[note(query_system_cycle_stack_single)]
    Single,
    #[note(query_system_cycle_stack_multiple)]
    Multiple,
}

#[derive(Subdiagnostic)]
pub enum Alias {
    #[note(query_system_cycle_recursive_ty_alias)]
    #[help(query_system_cycle_recursive_ty_alias_help1)]
    #[help(query_system_cycle_recursive_ty_alias_help2)]
    Ty,
    #[note(query_system_cycle_recursive_trait_alias)]
    Trait,
}

#[derive(Subdiagnostic)]
#[note(query_system_cycle_usage)]
pub struct CycleUsage {
    #[primary_span]
    pub span: Span,
    pub usage: String,
}

#[derive(Diagnostic)]
#[diag(query_system_cycle, code = "E0391")]
pub struct Cycle {
    #[primary_span]
    pub span: Span,
    pub stack_bottom: String,
    #[subdiagnostic(eager)]
    pub cycle_stack: Vec<CycleStack>,
    #[subdiagnostic]
    pub stack_count: StackCount,
    #[subdiagnostic]
    pub alias: Option<Alias>,
    #[subdiagnostic]
    pub cycle_usage: Option<CycleUsage>,
}

#[derive(Diagnostic)]
#[diag(query_system_reentrant)]
pub struct Reentrant;

#[derive(Diagnostic)]
#[diag(query_system_increment_compilation)]
#[help]
#[note(query_system_increment_compilation_note1)]
#[note(query_system_increment_compilation_note2)]
pub struct IncrementCompilation {
    pub run_cmd: String,
    pub dep_node: String,
}

#[derive(Diagnostic)]
#[help]
#[diag(query_system_query_overflow)]
pub struct QueryOverflow {
    #[primary_span]
    pub span: Option<Span>,
    #[subdiagnostic]
    pub layout_of_depth: Option<LayoutOfDepth>,
    pub suggested_limit: Limit,
    pub crate_name: Symbol,
}

#[derive(Subdiagnostic)]
#[note(query_system_layout_of_depth)]
pub struct LayoutOfDepth {
    pub desc: String,
    pub depth: usize,
}