]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_const_eval/src/errors.rs
Rollup merge of #103084 - inquisitivecrystal:control-flow, r=scottmcm
[rust.git] / compiler / rustc_const_eval / src / errors.rs
1 use rustc_hir::ConstContext;
2 use rustc_macros::Diagnostic;
3 use rustc_span::Span;
4
5 #[derive(Diagnostic)]
6 #[diag(const_eval_unstable_in_stable)]
7 pub(crate) struct UnstableInStable {
8     pub gate: String,
9     #[primary_span]
10     pub span: Span,
11     #[suggestion(
12         unstable_sugg,
13         code = "#[rustc_const_unstable(feature = \"...\", issue = \"...\")]\n",
14         applicability = "has-placeholders"
15     )]
16     #[suggestion(
17         bypass_sugg,
18         code = "#[rustc_allow_const_fn_unstable({gate})]\n",
19         applicability = "has-placeholders"
20     )]
21     pub attr_span: Span,
22 }
23
24 #[derive(Diagnostic)]
25 #[diag(const_eval_thread_local_access, code = "E0625")]
26 pub(crate) struct NonConstOpErr {
27     #[primary_span]
28     pub span: Span,
29 }
30
31 #[derive(Diagnostic)]
32 #[diag(const_eval_static_access, code = "E0013")]
33 #[help]
34 pub(crate) struct StaticAccessErr {
35     #[primary_span]
36     pub span: Span,
37     pub kind: ConstContext,
38     #[note(teach_note)]
39     #[help(teach_help)]
40     pub teach: Option<()>,
41 }
42
43 #[derive(Diagnostic)]
44 #[diag(const_eval_raw_ptr_to_int)]
45 #[note]
46 #[note(note2)]
47 pub(crate) struct RawPtrToIntErr {
48     #[primary_span]
49     pub span: Span,
50 }
51
52 #[derive(Diagnostic)]
53 #[diag(const_eval_raw_ptr_comparison)]
54 #[note]
55 pub(crate) struct RawPtrComparisonErr {
56     #[primary_span]
57     pub span: Span,
58 }
59
60 #[derive(Diagnostic)]
61 #[diag(const_eval_panic_non_str)]
62 pub(crate) struct PanicNonStrErr {
63     #[primary_span]
64     pub span: Span,
65 }
66
67 #[derive(Diagnostic)]
68 #[diag(const_eval_mut_deref, code = "E0658")]
69 pub(crate) struct MutDerefErr {
70     #[primary_span]
71     pub span: Span,
72     pub kind: ConstContext,
73 }
74
75 #[derive(Diagnostic)]
76 #[diag(const_eval_transient_mut_borrow, code = "E0658")]
77 pub(crate) struct TransientMutBorrowErr {
78     #[primary_span]
79     pub span: Span,
80     pub kind: ConstContext,
81 }
82
83 #[derive(Diagnostic)]
84 #[diag(const_eval_transient_mut_borrow_raw, code = "E0658")]
85 pub(crate) struct TransientMutBorrowErrRaw {
86     #[primary_span]
87     pub span: Span,
88     pub kind: ConstContext,
89 }
90
91 #[derive(Diagnostic)]
92 #[diag(const_eval_max_num_nodes_in_const)]
93 pub(crate) struct MaxNumNodesInConstErr {
94     #[primary_span]
95     pub span: Span,
96     pub global_const_id: String,
97 }
98
99 #[derive(Diagnostic)]
100 #[diag(const_eval_unallowed_fn_pointer_call)]
101 pub(crate) struct UnallowedFnPointerCall {
102     #[primary_span]
103     pub span: Span,
104     pub kind: ConstContext,
105 }
106
107 #[derive(Diagnostic)]
108 #[diag(const_eval_unstable_const_fn)]
109 pub(crate) struct UnstableConstFn {
110     #[primary_span]
111     pub span: Span,
112     pub def_path: String,
113 }
114
115 #[derive(Diagnostic)]
116 #[diag(const_eval_unallowed_mutable_refs, code = "E0764")]
117 pub(crate) struct UnallowedMutableRefs {
118     #[primary_span]
119     pub span: Span,
120     pub kind: ConstContext,
121     #[note(teach_note)]
122     pub teach: Option<()>,
123 }
124
125 #[derive(Diagnostic)]
126 #[diag(const_eval_unallowed_mutable_refs_raw, code = "E0764")]
127 pub(crate) struct UnallowedMutableRefsRaw {
128     #[primary_span]
129     pub span: Span,
130     pub kind: ConstContext,
131     #[note(teach_note)]
132     pub teach: Option<()>,
133 }
134 #[derive(Diagnostic)]
135 #[diag(const_eval_non_const_fmt_macro_call, code = "E0015")]
136 pub(crate) struct NonConstFmtMacroCall {
137     #[primary_span]
138     pub span: Span,
139     pub kind: ConstContext,
140 }
141
142 #[derive(Diagnostic)]
143 #[diag(const_eval_non_const_fn_call, code = "E0015")]
144 pub(crate) struct NonConstFnCall {
145     #[primary_span]
146     pub span: Span,
147     pub def_path_str: String,
148     pub kind: ConstContext,
149 }
150
151 #[derive(Diagnostic)]
152 #[diag(const_eval_unallowed_op_in_const_context)]
153 pub(crate) struct UnallowedOpInConstContext {
154     #[primary_span]
155     pub span: Span,
156     pub msg: String,
157 }
158
159 #[derive(Diagnostic)]
160 #[diag(const_eval_unallowed_heap_allocations, code = "E0010")]
161 pub(crate) struct UnallowedHeapAllocations {
162     #[primary_span]
163     #[label]
164     pub span: Span,
165     pub kind: ConstContext,
166     #[note(teach_note)]
167     pub teach: Option<()>,
168 }
169
170 #[derive(Diagnostic)]
171 #[diag(const_eval_unallowed_inline_asm, code = "E0015")]
172 pub(crate) struct UnallowedInlineAsm {
173     #[primary_span]
174     pub span: Span,
175     pub kind: ConstContext,
176 }
177
178 #[derive(Diagnostic)]
179 #[diag(const_eval_interior_mutable_data_refer, code = "E0492")]
180 pub(crate) struct InteriorMutableDataRefer {
181     #[primary_span]
182     #[label]
183     pub span: Span,
184     #[help]
185     pub opt_help: Option<()>,
186     pub kind: ConstContext,
187     #[note(teach_note)]
188     pub teach: Option<()>,
189 }
190
191 #[derive(Diagnostic)]
192 #[diag(const_eval_interior_mutability_borrow)]
193 pub(crate) struct InteriorMutabilityBorrow {
194     #[primary_span]
195     pub span: Span,
196 }