]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_query_system/src/error.rs
:arrow_up: rust-analyzer
[rust.git] / compiler / rustc_query_system / src / error.rs
1 use rustc_errors::AddSubdiagnostic;
2 use rustc_span::Span;
3
4 pub struct CycleStack {
5     pub span: Span,
6     pub desc: String,
7 }
8
9 impl AddSubdiagnostic for CycleStack {
10     fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
11         diag.span_note(self.span, &format!("...which requires {}...", self.desc));
12     }
13 }
14
15 #[derive(SessionSubdiagnostic)]
16 pub enum StackCount {
17     #[note(query_system::cycle_stack_single)]
18     Single,
19     #[note(query_system::cycle_stack_multiple)]
20     Multiple,
21 }
22
23 #[derive(SessionSubdiagnostic)]
24 pub enum Alias {
25     #[note(query_system::cycle_recursive_ty_alias)]
26     #[help(query_system::cycle_recursive_ty_alias_help1)]
27     #[help(query_system::cycle_recursive_ty_alias_help2)]
28     Ty,
29     #[note(query_system::cycle_recursive_trait_alias)]
30     Trait,
31 }
32
33 #[derive(SessionSubdiagnostic)]
34 #[note(query_system::cycle_usage)]
35 pub struct CycleUsage {
36     #[primary_span]
37     pub span: Span,
38     pub usage: String,
39 }
40
41 #[derive(SessionDiagnostic)]
42 #[diag(query_system::cycle, code = "E0391")]
43 pub struct Cycle {
44     #[primary_span]
45     pub span: Span,
46     pub stack_bottom: String,
47     #[subdiagnostic]
48     pub cycle_stack: Vec<CycleStack>,
49     #[subdiagnostic]
50     pub stack_count: StackCount,
51     #[subdiagnostic]
52     pub alias: Option<Alias>,
53     #[subdiagnostic]
54     pub cycle_usage: Option<CycleUsage>,
55 }
56
57 #[derive(SessionDiagnostic)]
58 #[diag(query_system::reentrant)]
59 pub struct Reentrant;
60
61 #[derive(SessionDiagnostic)]
62 #[diag(query_system::increment_compilation)]
63 #[help]
64 #[note(query_system::increment_compilation_note1)]
65 #[note(query_system::increment_compilation_note2)]
66 pub struct IncrementCompilation {
67     pub run_cmd: String,
68     pub dep_node: String,
69 }
70
71 #[derive(SessionDiagnostic)]
72 #[diag(query_system::query_overflow)]
73 pub struct QueryOverflow;