]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_query_system/src/error.rs
Auto merge of #99497 - vladimir-ea:stdlib_os_api_watchos, r=thomcc
[rust.git] / compiler / rustc_query_system / src / error.rs
1 use rustc_errors::AddToDiagnostic;
2 use rustc_macros::{Diagnostic, Subdiagnostic};
3 use rustc_session::Limit;
4 use rustc_span::{Span, Symbol};
5
6 pub struct CycleStack {
7     pub span: Span,
8     pub desc: String,
9 }
10
11 impl AddToDiagnostic for CycleStack {
12     fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
13         diag.span_note(self.span, &format!("...which requires {}...", self.desc));
14     }
15 }
16
17 #[derive(Copy, Clone)]
18 pub enum HandleCycleError {
19     Error,
20     Fatal,
21     DelayBug,
22 }
23
24 #[derive(Subdiagnostic)]
25 pub enum StackCount {
26     #[note(query_system::cycle_stack_single)]
27     Single,
28     #[note(query_system::cycle_stack_multiple)]
29     Multiple,
30 }
31
32 #[derive(Subdiagnostic)]
33 pub enum Alias {
34     #[note(query_system::cycle_recursive_ty_alias)]
35     #[help(query_system::cycle_recursive_ty_alias_help1)]
36     #[help(query_system::cycle_recursive_ty_alias_help2)]
37     Ty,
38     #[note(query_system::cycle_recursive_trait_alias)]
39     Trait,
40 }
41
42 #[derive(Subdiagnostic)]
43 #[note(query_system::cycle_usage)]
44 pub struct CycleUsage {
45     #[primary_span]
46     pub span: Span,
47     pub usage: String,
48 }
49
50 #[derive(Diagnostic)]
51 #[diag(query_system::cycle, code = "E0391")]
52 pub struct Cycle {
53     #[primary_span]
54     pub span: Span,
55     pub stack_bottom: String,
56     #[subdiagnostic]
57     pub cycle_stack: Vec<CycleStack>,
58     #[subdiagnostic]
59     pub stack_count: StackCount,
60     #[subdiagnostic]
61     pub alias: Option<Alias>,
62     #[subdiagnostic]
63     pub cycle_usage: Option<CycleUsage>,
64 }
65
66 #[derive(Diagnostic)]
67 #[diag(query_system::reentrant)]
68 pub struct Reentrant;
69
70 #[derive(Diagnostic)]
71 #[diag(query_system::increment_compilation)]
72 #[help]
73 #[note(query_system::increment_compilation_note1)]
74 #[note(query_system::increment_compilation_note2)]
75 pub struct IncrementCompilation {
76     pub run_cmd: String,
77     pub dep_node: String,
78 }
79
80 #[derive(Diagnostic)]
81 #[help]
82 #[diag(query_system::query_overflow)]
83 pub struct QueryOverflow {
84     #[primary_span]
85     pub span: Option<Span>,
86     #[subdiagnostic]
87     pub layout_of_depth: Option<LayoutOfDepth>,
88     pub suggested_limit: Limit,
89     pub crate_name: Symbol,
90 }
91
92 #[derive(Subdiagnostic)]
93 #[note(query_system::layout_of_depth)]
94 pub struct LayoutOfDepth {
95     pub desc: String,
96     pub depth: usize,
97 }