]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_passes/src/errors.rs
Rollup merge of #98710 - mojave2:string, r=JohnTitor
[rust.git] / compiler / rustc_passes / src / errors.rs
1 use rustc_errors::{Applicability, MultiSpan};
2 use rustc_macros::{LintDiagnostic, SessionDiagnostic};
3 use rustc_span::{Span, Symbol};
4
5 #[derive(LintDiagnostic)]
6 #[lint(passes::outer_crate_level_attr)]
7 pub struct OuterCrateLevelAttr;
8
9 #[derive(LintDiagnostic)]
10 #[lint(passes::inner_crate_level_attr)]
11 pub struct InnerCrateLevelAttr;
12
13 #[derive(LintDiagnostic)]
14 #[lint(passes::ignored_attr_with_macro)]
15 pub struct IgnoredAttrWithMacro<'a> {
16     pub sym: &'a str,
17 }
18
19 #[derive(LintDiagnostic)]
20 #[lint(passes::ignored_attr)]
21 pub struct IgnoredAttr<'a> {
22     pub sym: &'a str,
23 }
24
25 #[derive(LintDiagnostic)]
26 #[lint(passes::inline_ignored_function_prototype)]
27 pub struct IgnoredInlineAttrFnProto;
28
29 #[derive(LintDiagnostic)]
30 #[lint(passes::inline_ignored_constants)]
31 #[warn_]
32 #[note]
33 pub struct IgnoredInlineAttrConstants;
34
35 #[derive(SessionDiagnostic)]
36 #[error(passes::inline_not_fn_or_closure, code = "E0518")]
37 pub struct InlineNotFnOrClosure {
38     #[primary_span]
39     pub attr_span: Span,
40     #[label]
41     pub defn_span: Span,
42 }
43
44 #[derive(LintDiagnostic)]
45 #[lint(passes::no_coverage_ignored_function_prototype)]
46 pub struct IgnoredNoCoverageFnProto;
47
48 #[derive(LintDiagnostic)]
49 #[lint(passes::no_coverage_propagate)]
50 pub struct IgnoredNoCoveragePropagate;
51
52 #[derive(LintDiagnostic)]
53 #[lint(passes::no_coverage_fn_defn)]
54 pub struct IgnoredNoCoverageFnDefn;
55
56 #[derive(SessionDiagnostic)]
57 #[error(passes::no_coverage_not_coverable, code = "E0788")]
58 pub struct IgnoredNoCoverageNotCoverable {
59     #[primary_span]
60     pub attr_span: Span,
61     #[label]
62     pub defn_span: Span,
63 }
64
65 #[derive(SessionDiagnostic)]
66 #[error(passes::should_be_applied_to_fn)]
67 pub struct AttrShouldBeAppliedToFn {
68     #[primary_span]
69     pub attr_span: Span,
70     #[label]
71     pub defn_span: Span,
72 }
73
74 #[derive(SessionDiagnostic)]
75 #[error(passes::naked_tracked_caller, code = "E0736")]
76 pub struct NakedTrackedCaller {
77     #[primary_span]
78     pub attr_span: Span,
79 }
80
81 #[derive(SessionDiagnostic)]
82 #[error(passes::should_be_applied_to_fn, code = "E0739")]
83 pub struct TrackedCallerWrongLocation {
84     #[primary_span]
85     pub attr_span: Span,
86     #[label]
87     pub defn_span: Span,
88 }
89
90 #[derive(SessionDiagnostic)]
91 #[error(passes::should_be_applied_to_struct_enum, code = "E0701")]
92 pub struct NonExhaustiveWrongLocation {
93     #[primary_span]
94     pub attr_span: Span,
95     #[label]
96     pub defn_span: Span,
97 }
98
99 #[derive(SessionDiagnostic)]
100 #[error(passes::should_be_applied_to_trait)]
101 pub struct AttrShouldBeAppliedToTrait {
102     #[primary_span]
103     pub attr_span: Span,
104     #[label]
105     pub defn_span: Span,
106 }
107
108 #[derive(LintDiagnostic)]
109 #[lint(passes::target_feature_on_statement)]
110 pub struct TargetFeatureOnStatement;
111
112 #[derive(SessionDiagnostic)]
113 #[error(passes::should_be_applied_to_static)]
114 pub struct AttrShouldBeAppliedToStatic {
115     #[primary_span]
116     pub attr_span: Span,
117     #[label]
118     pub defn_span: Span,
119 }
120
121 #[derive(SessionDiagnostic)]
122 #[error(passes::doc_expect_str)]
123 pub struct DocExpectStr<'a> {
124     #[primary_span]
125     pub attr_span: Span,
126     pub attr_name: &'a str,
127 }
128
129 #[derive(SessionDiagnostic)]
130 #[error(passes::doc_alias_empty)]
131 pub struct DocAliasEmpty<'a> {
132     #[primary_span]
133     pub span: Span,
134     pub attr_str: &'a str,
135 }
136
137 #[derive(SessionDiagnostic)]
138 #[error(passes::doc_alias_bad_char)]
139 pub struct DocAliasBadChar<'a> {
140     #[primary_span]
141     pub span: Span,
142     pub attr_str: &'a str,
143     pub char_: char,
144 }
145
146 #[derive(SessionDiagnostic)]
147 #[error(passes::doc_alias_start_end)]
148 pub struct DocAliasStartEnd<'a> {
149     #[primary_span]
150     pub span: Span,
151     pub attr_str: &'a str,
152 }
153
154 #[derive(SessionDiagnostic)]
155 #[error(passes::doc_alias_bad_location)]
156 pub struct DocAliasBadLocation<'a> {
157     #[primary_span]
158     pub span: Span,
159     pub attr_str: &'a str,
160     pub location: &'a str,
161 }
162
163 #[derive(SessionDiagnostic)]
164 #[error(passes::doc_alias_not_an_alias)]
165 pub struct DocAliasNotAnAlias<'a> {
166     #[primary_span]
167     pub span: Span,
168     pub attr_str: &'a str,
169 }
170
171 #[derive(LintDiagnostic)]
172 #[lint(passes::doc_alias_duplicated)]
173 pub struct DocAliasDuplicated {
174     #[label]
175     pub first_defn: Span,
176 }
177
178 #[derive(SessionDiagnostic)]
179 #[error(passes::doc_alias_not_string_literal)]
180 pub struct DocAliasNotStringLiteral {
181     #[primary_span]
182     pub span: Span,
183 }
184
185 #[derive(SessionDiagnostic)]
186 #[error(passes::doc_alias_malformed)]
187 pub struct DocAliasMalformed {
188     #[primary_span]
189     pub span: Span,
190 }
191
192 #[derive(SessionDiagnostic)]
193 #[error(passes::doc_keyword_empty_mod)]
194 pub struct DocKeywordEmptyMod {
195     #[primary_span]
196     pub span: Span,
197 }
198
199 #[derive(SessionDiagnostic)]
200 #[error(passes::doc_keyword_not_mod)]
201 pub struct DocKeywordNotMod {
202     #[primary_span]
203     pub span: Span,
204 }
205
206 #[derive(SessionDiagnostic)]
207 #[error(passes::doc_keyword_invalid_ident)]
208 pub struct DocKeywordInvalidIdent {
209     #[primary_span]
210     pub span: Span,
211     pub doc_keyword: Symbol,
212 }
213
214 #[derive(SessionDiagnostic)]
215 #[error(passes::doc_fake_variadic_not_valid)]
216 pub struct DocFakeVariadicNotValid {
217     #[primary_span]
218     pub span: Span,
219 }
220
221 #[derive(SessionDiagnostic)]
222 #[error(passes::doc_keyword_only_impl)]
223 pub struct DocKeywordOnlyImpl {
224     #[primary_span]
225     pub span: Span,
226 }
227
228 #[derive(SessionDiagnostic)]
229 #[error(passes::doc_inline_conflict)]
230 #[help]
231 pub struct DocKeywordConflict {
232     #[primary_span]
233     pub spans: MultiSpan,
234 }
235
236 #[derive(LintDiagnostic)]
237 #[lint(passes::doc_inline_only_use)]
238 #[note]
239 pub struct DocInlineOnlyUse {
240     #[label]
241     pub attr_span: Span,
242     #[label(passes::not_a_use_item_label)]
243     pub item_span: Option<Span>,
244 }
245
246 #[derive(SessionDiagnostic)]
247 #[error(passes::doc_attr_not_crate_level)]
248 pub struct DocAttrNotCrateLevel<'a> {
249     #[primary_span]
250     pub span: Span,
251     pub attr_name: &'a str,
252 }
253
254 #[derive(LintDiagnostic)]
255 #[lint(passes::doc_test_unknown)]
256 pub struct DocTestUnknown {
257     pub path: String,
258 }
259
260 #[derive(LintDiagnostic)]
261 #[lint(passes::doc_test_takes_list)]
262 pub struct DocTestTakesList;
263
264 #[derive(LintDiagnostic)]
265 #[lint(passes::doc_primitive)]
266 pub struct DocPrimitive;
267
268 #[derive(LintDiagnostic)]
269 #[lint(passes::doc_test_unknown_any)]
270 pub struct DocTestUnknownAny {
271     pub path: String,
272 }
273
274 #[derive(LintDiagnostic)]
275 #[lint(passes::doc_test_unknown_spotlight)]
276 #[note]
277 #[note(passes::no_op_note)]
278 pub struct DocTestUnknownSpotlight {
279     pub path: String,
280     #[suggestion_short(applicability = "machine-applicable", code = "notable_trait")]
281     pub span: Span,
282 }
283
284 #[derive(LintDiagnostic)]
285 #[lint(passes::doc_test_unknown_include)]
286 pub struct DocTestUnknownInclude {
287     pub path: String,
288     pub value: String,
289     pub inner: &'static str,
290     #[suggestion(code = "#{inner}[doc = include_str!(\"{value}\")]")]
291     pub sugg: (Span, Applicability),
292 }
293
294 #[derive(LintDiagnostic)]
295 #[lint(passes::doc_invalid)]
296 pub struct DocInvalid;
297
298 #[derive(SessionDiagnostic)]
299 #[error(passes::pass_by_value)]
300 pub struct PassByValue {
301     #[primary_span]
302     pub attr_span: Span,
303     #[label]
304     pub span: Span,
305 }
306
307 #[derive(SessionDiagnostic)]
308 #[error(passes::allow_incoherent_impl)]
309 pub struct AllowIncoherentImpl {
310     #[primary_span]
311     pub attr_span: Span,
312     #[label]
313     pub span: Span,
314 }
315
316 #[derive(SessionDiagnostic)]
317 #[error(passes::has_incoherent_inherent_impl)]
318 pub struct HasIncoherentInherentImpl {
319     #[primary_span]
320     pub attr_span: Span,
321     #[label]
322     pub span: Span,
323 }
324
325 #[derive(LintDiagnostic)]
326 #[lint(passes::must_use_async)]
327 pub struct MustUseAsync {
328     #[label]
329     pub span: Span,
330 }
331
332 #[derive(LintDiagnostic)]
333 #[lint(passes::must_use_no_effect)]
334 pub struct MustUseNoEffect {
335     pub article: &'static str,
336     pub target: rustc_hir::Target,
337 }
338
339 #[derive(SessionDiagnostic)]
340 #[error(passes::must_not_suspend)]
341 pub struct MustNotSuspend {
342     #[primary_span]
343     pub attr_span: Span,
344     #[label]
345     pub span: Span,
346 }
347
348 #[derive(LintDiagnostic)]
349 #[lint(passes::cold)]
350 #[warn_]
351 pub struct Cold {
352     #[label]
353     pub span: Span,
354 }
355
356 #[derive(LintDiagnostic)]
357 #[lint(passes::link)]
358 #[warn_]
359 pub struct Link {
360     #[label]
361     pub span: Option<Span>,
362 }