]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_hir_analysis/src/errors.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / compiler / rustc_hir_analysis / src / errors.rs
CommitLineData
2b03887a
FG
1//! Errors emitted by `rustc_hir_analysis`.
2
9ffffee4
FG
3use crate::fluent_generated as fluent;
4use rustc_errors::{
5 error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
6 MultiSpan,
7};
fe692bf9 8use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
49aad941 9use rustc_middle::ty::{self, print::TraitRefPrintOnlyTraitPath, Ty};
1b1a35ee
XL
10use rustc_span::{symbol::Ident, Span, Symbol};
11
2b03887a
FG
12#[derive(Diagnostic)]
13#[diag(hir_analysis_unrecognized_atomic_operation, code = "E0092")]
1b1a35ee 14pub struct UnrecognizedAtomicOperation<'a> {
04454e1e
FG
15 #[primary_span]
16 #[label]
1b1a35ee
XL
17 pub span: Span,
18 pub op: &'a str,
19}
20
2b03887a
FG
21#[derive(Diagnostic)]
22#[diag(hir_analysis_wrong_number_of_generic_arguments_to_intrinsic, code = "E0094")]
136023e0 23pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
04454e1e
FG
24 #[primary_span]
25 #[label]
1b1a35ee
XL
26 pub span: Span,
27 pub found: usize,
28 pub expected: usize,
136023e0 29 pub descr: &'a str,
1b1a35ee
XL
30}
31
2b03887a
FG
32#[derive(Diagnostic)]
33#[diag(hir_analysis_unrecognized_intrinsic_function, code = "E0093")]
1b1a35ee 34pub struct UnrecognizedIntrinsicFunction {
04454e1e
FG
35 #[primary_span]
36 #[label]
1b1a35ee
XL
37 pub span: Span,
38 pub name: Symbol,
39}
40
2b03887a
FG
41#[derive(Diagnostic)]
42#[diag(hir_analysis_lifetimes_or_bounds_mismatch_on_trait, code = "E0195")]
1b1a35ee 43pub struct LifetimesOrBoundsMismatchOnTrait {
04454e1e
FG
44 #[primary_span]
45 #[label]
1b1a35ee 46 pub span: Span,
9ffffee4 47 #[label(hir_analysis_generics_label)]
1b1a35ee 48 pub generics_span: Option<Span>,
9ffffee4 49 #[label(hir_analysis_where_label)]
487cf647 50 pub where_span: Option<Span>,
9ffffee4 51 #[label(hir_analysis_bounds_label)]
487cf647 52 pub bounds_span: Vec<Span>,
1b1a35ee
XL
53 pub item_kind: &'static str,
54 pub ident: Ident,
55}
56
9c376795
FG
57#[derive(Diagnostic)]
58#[diag(hir_analysis_async_trait_impl_should_be_async)]
59pub struct AsyncTraitImplShouldBeAsync {
60 #[primary_span]
61 // #[label]
62 pub span: Span,
9ffffee4 63 #[label(hir_analysis_trait_item_label)]
9c376795
FG
64 pub trait_item_span: Option<Span>,
65 pub method_name: Symbol,
66}
67
2b03887a
FG
68#[derive(Diagnostic)]
69#[diag(hir_analysis_drop_impl_on_wrong_item, code = "E0120")]
1b1a35ee 70pub struct DropImplOnWrongItem {
04454e1e
FG
71 #[primary_span]
72 #[label]
1b1a35ee
XL
73 pub span: Span,
74}
75
2b03887a
FG
76#[derive(Diagnostic)]
77#[diag(hir_analysis_field_already_declared, code = "E0124")]
1b1a35ee
XL
78pub struct FieldAlreadyDeclared {
79 pub field_name: Ident,
04454e1e
FG
80 #[primary_span]
81 #[label]
1b1a35ee 82 pub span: Span,
9ffffee4 83 #[label(hir_analysis_previous_decl_label)]
1b1a35ee
XL
84 pub prev_span: Span,
85}
86
2b03887a
FG
87#[derive(Diagnostic)]
88#[diag(hir_analysis_copy_impl_on_type_with_dtor, code = "E0184")]
1b1a35ee 89pub struct CopyImplOnTypeWithDtor {
04454e1e
FG
90 #[primary_span]
91 #[label]
1b1a35ee
XL
92 pub span: Span,
93}
94
2b03887a
FG
95#[derive(Diagnostic)]
96#[diag(hir_analysis_multiple_relaxed_default_bounds, code = "E0203")]
1b1a35ee 97pub struct MultipleRelaxedDefaultBounds {
04454e1e 98 #[primary_span]
1b1a35ee
XL
99 pub span: Span,
100}
101
2b03887a
FG
102#[derive(Diagnostic)]
103#[diag(hir_analysis_copy_impl_on_non_adt, code = "E0206")]
1b1a35ee 104pub struct CopyImplOnNonAdt {
04454e1e
FG
105 #[primary_span]
106 #[label]
1b1a35ee
XL
107 pub span: Span,
108}
109
49aad941
FG
110#[derive(Diagnostic)]
111#[diag(hir_analysis_const_param_ty_impl_on_non_adt)]
112pub struct ConstParamTyImplOnNonAdt {
113 #[primary_span]
114 #[label]
115 pub span: Span,
116}
117
2b03887a
FG
118#[derive(Diagnostic)]
119#[diag(hir_analysis_trait_object_declared_with_no_traits, code = "E0224")]
1b1a35ee 120pub struct TraitObjectDeclaredWithNoTraits {
04454e1e 121 #[primary_span]
1b1a35ee 122 pub span: Span,
9ffffee4 123 #[label(hir_analysis_alias_span)]
04454e1e 124 pub trait_alias_span: Option<Span>,
1b1a35ee
XL
125}
126
2b03887a
FG
127#[derive(Diagnostic)]
128#[diag(hir_analysis_ambiguous_lifetime_bound, code = "E0227")]
1b1a35ee 129pub struct AmbiguousLifetimeBound {
04454e1e 130 #[primary_span]
1b1a35ee
XL
131 pub span: Span,
132}
133
2b03887a
FG
134#[derive(Diagnostic)]
135#[diag(hir_analysis_assoc_type_binding_not_allowed, code = "E0229")]
1b1a35ee 136pub struct AssocTypeBindingNotAllowed {
04454e1e
FG
137 #[primary_span]
138 #[label]
1b1a35ee 139 pub span: Span,
353b0b11
FG
140
141 #[subdiagnostic]
142 pub fn_trait_expansion: Option<ParenthesizedFnTraitExpansion>,
143}
144
145#[derive(Subdiagnostic)]
146#[help(hir_analysis_parenthesized_fn_trait_expansion)]
147pub struct ParenthesizedFnTraitExpansion {
148 #[primary_span]
149 pub span: Span,
150
151 pub expanded_type: String,
1b1a35ee
XL
152}
153
2b03887a
FG
154#[derive(Diagnostic)]
155#[diag(hir_analysis_typeof_reserved_keyword_used, code = "E0516")]
04454e1e
FG
156pub struct TypeofReservedKeywordUsed<'tcx> {
157 pub ty: Ty<'tcx>,
158 #[primary_span]
159 #[label]
1b1a35ee 160 pub span: Span,
487cf647 161 #[suggestion(style = "verbose", code = "{ty}")]
04454e1e 162 pub opt_sugg: Option<(Span, Applicability)>,
1b1a35ee
XL
163}
164
2b03887a
FG
165#[derive(Diagnostic)]
166#[diag(hir_analysis_value_of_associated_struct_already_specified, code = "E0719")]
1b1a35ee 167pub struct ValueOfAssociatedStructAlreadySpecified {
04454e1e
FG
168 #[primary_span]
169 #[label]
1b1a35ee 170 pub span: Span,
9ffffee4 171 #[label(hir_analysis_previous_bound_label)]
1b1a35ee
XL
172 pub prev_span: Span,
173 pub item_name: Ident,
174 pub def_path: String,
175}
176
2b03887a
FG
177#[derive(Diagnostic)]
178#[diag(hir_analysis_unconstrained_opaque_type)]
04454e1e
FG
179#[note]
180pub struct UnconstrainedOpaqueType {
181 #[primary_span]
182 pub span: Span,
183 pub name: Symbol,
2b03887a 184 pub what: &'static str,
04454e1e
FG
185}
186
fe692bf9
FG
187#[derive(Diagnostic)]
188#[diag(hir_analysis_tait_forward_compat)]
189#[note]
190pub struct TaitForwardCompat {
191 #[primary_span]
192 pub span: Span,
193 #[note]
194 pub item_span: Span,
195}
196
04454e1e
FG
197pub struct MissingTypeParams {
198 pub span: Span,
199 pub def_span: Span,
f2b60f7d 200 pub span_snippet: Option<String>,
064997fb 201 pub missing_type_params: Vec<Symbol>,
04454e1e
FG
202 pub empty_generic_args: bool,
203}
204
2b03887a
FG
205// Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`.
206impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
487cf647 207 #[track_caller]
f2b60f7d
FG
208 fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
209 let mut err = handler.struct_span_err_with_code(
04454e1e 210 self.span,
9ffffee4 211 fluent::hir_analysis_missing_type_params,
04454e1e
FG
212 error_code!(E0393),
213 );
214 err.set_arg("parameterCount", self.missing_type_params.len());
215 err.set_arg(
216 "parameters",
217 self.missing_type_params
218 .iter()
add651ee 219 .map(|n| format!("`{n}`"))
04454e1e
FG
220 .collect::<Vec<_>>()
221 .join(", "),
222 );
223
9ffffee4 224 err.span_label(self.def_span, fluent::hir_analysis_label);
04454e1e
FG
225
226 let mut suggested = false;
f2b60f7d
FG
227 // Don't suggest setting the type params if there are some already: the order is
228 // tricky to get right and the user will already know what the syntax is.
229 if let Some(snippet) = self.span_snippet && self.empty_generic_args {
04454e1e
FG
230 if snippet.ends_with('>') {
231 // The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion
232 // we would have to preserve the right order. For now, as clearly the user is
233 // aware of the syntax, we do nothing.
234 } else {
235 // The user wrote `Iterator`, so we don't have a type we can suggest, but at
236 // least we can clue them to the correct syntax `Iterator<Type>`.
237 err.span_suggestion(
238 self.span,
9ffffee4 239 fluent::hir_analysis_suggestion,
064997fb
FG
240 format!(
241 "{}<{}>",
242 snippet,
243 self.missing_type_params
244 .iter()
245 .map(|n| n.to_string())
246 .collect::<Vec<_>>()
247 .join(", ")
248 ),
04454e1e
FG
249 Applicability::HasPlaceholders,
250 );
251 suggested = true;
252 }
253 }
254 if !suggested {
9ffffee4 255 err.span_label(self.span, fluent::hir_analysis_no_suggestion_label);
04454e1e
FG
256 }
257
9ffffee4 258 err.note(fluent::hir_analysis_note);
04454e1e
FG
259 err
260 }
261}
262
2b03887a
FG
263#[derive(Diagnostic)]
264#[diag(hir_analysis_manual_implementation, code = "E0183")]
04454e1e
FG
265#[help]
266pub struct ManualImplementation {
267 #[primary_span]
268 #[label]
269 pub span: Span,
270 pub trait_name: String,
271}
272
2b03887a
FG
273#[derive(Diagnostic)]
274#[diag(hir_analysis_substs_on_overridden_impl)]
04454e1e
FG
275pub struct SubstsOnOverriddenImpl {
276 #[primary_span]
1b1a35ee
XL
277 pub span: Span,
278}
f2b60f7d 279
2b03887a
FG
280#[derive(Diagnostic)]
281#[diag(hir_analysis_const_impl_for_non_const_trait)]
282pub struct ConstImplForNonConstTrait {
283 #[primary_span]
284 pub trait_ref_span: Span,
285 pub trait_name: String,
286 #[suggestion(applicability = "machine-applicable", code = "#[const_trait]")]
287 pub local_trait_span: Option<Span>,
288 #[note]
289 pub marking: (),
9ffffee4 290 #[note(hir_analysis_adding)]
2b03887a
FG
291 pub adding: (),
292}
293
294#[derive(Diagnostic)]
295#[diag(hir_analysis_const_bound_for_non_const_trait)]
296pub struct ConstBoundForNonConstTrait {
297 #[primary_span]
298 pub span: Span,
299}
300
301#[derive(Diagnostic)]
302#[diag(hir_analysis_self_in_impl_self)]
303pub struct SelfInImplSelf {
304 #[primary_span]
305 pub span: MultiSpan,
306 #[note]
307 pub note: (),
308}
487cf647
FG
309
310#[derive(Diagnostic)]
311#[diag(hir_analysis_linkage_type, code = "E0791")]
312pub(crate) struct LinkageType {
313 #[primary_span]
314 pub span: Span,
315}
9c376795
FG
316
317#[derive(Diagnostic)]
318#[help]
319#[diag(hir_analysis_auto_deref_reached_recursion_limit, code = "E0055")]
320pub struct AutoDerefReachedRecursionLimit<'a> {
321 #[primary_span]
322 #[label]
323 pub span: Span,
324 pub ty: Ty<'a>,
325 pub suggested_limit: rustc_session::Limit,
326 pub crate_name: Symbol,
327}
9ffffee4
FG
328
329#[derive(Diagnostic)]
330#[diag(hir_analysis_where_clause_on_main, code = "E0646")]
331pub(crate) struct WhereClauseOnMain {
332 #[primary_span]
333 pub span: Span,
334 #[label]
335 pub generics_span: Option<Span>,
336}
337
338#[derive(Diagnostic)]
339#[diag(hir_analysis_track_caller_on_main)]
340pub(crate) struct TrackCallerOnMain {
341 #[primary_span]
342 #[suggestion(applicability = "maybe-incorrect", code = "")]
343 pub span: Span,
344 #[label(hir_analysis_track_caller_on_main)]
345 pub annotated: Span,
346}
347
353b0b11
FG
348#[derive(Diagnostic)]
349#[diag(hir_analysis_target_feature_on_main)]
350pub(crate) struct TargetFeatureOnMain {
351 #[primary_span]
352 #[label(hir_analysis_target_feature_on_main)]
353 pub main: Span,
354}
355
9ffffee4
FG
356#[derive(Diagnostic)]
357#[diag(hir_analysis_start_not_track_caller)]
358pub(crate) struct StartTrackCaller {
359 #[primary_span]
360 pub span: Span,
361 #[label]
362 pub start: Span,
363}
364
353b0b11
FG
365#[derive(Diagnostic)]
366#[diag(hir_analysis_start_not_target_feature)]
367pub(crate) struct StartTargetFeature {
368 #[primary_span]
369 pub span: Span,
370 #[label]
371 pub start: Span,
372}
373
9ffffee4
FG
374#[derive(Diagnostic)]
375#[diag(hir_analysis_start_not_async, code = "E0752")]
376pub(crate) struct StartAsync {
377 #[primary_span]
378 #[label]
379 pub span: Span,
380}
381
382#[derive(Diagnostic)]
383#[diag(hir_analysis_start_function_where, code = "E0647")]
384pub(crate) struct StartFunctionWhere {
385 #[primary_span]
386 #[label]
387 pub span: Span,
388}
389
390#[derive(Diagnostic)]
391#[diag(hir_analysis_start_function_parameters, code = "E0132")]
392pub(crate) struct StartFunctionParameters {
393 #[primary_span]
394 #[label]
395 pub span: Span,
396}
397
398#[derive(Diagnostic)]
399#[diag(hir_analysis_main_function_return_type_generic, code = "E0131")]
400pub(crate) struct MainFunctionReturnTypeGeneric {
401 #[primary_span]
402 pub span: Span,
403}
404
405#[derive(Diagnostic)]
406#[diag(hir_analysis_main_function_async, code = "E0752")]
407pub(crate) struct MainFunctionAsync {
408 #[primary_span]
409 pub span: Span,
410 #[label]
411 pub asyncness: Option<Span>,
412}
413
414#[derive(Diagnostic)]
415#[diag(hir_analysis_main_function_generic_parameters, code = "E0131")]
416pub(crate) struct MainFunctionGenericParameters {
417 #[primary_span]
418 pub span: Span,
419 #[label]
420 pub label_span: Option<Span>,
421}
422
423#[derive(Diagnostic)]
424#[diag(hir_analysis_variadic_function_compatible_convention, code = "E0045")]
425pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
426 #[primary_span]
427 #[label]
428 pub span: Span,
429 pub conventions: &'a str,
430}
431
432#[derive(Diagnostic)]
781aab86
FG
433pub(crate) enum CannotCaptureLateBound {
434 #[diag(hir_analysis_cannot_capture_late_bound_ty)]
9ffffee4
FG
435 Type {
436 #[primary_span]
437 use_span: Span,
438 #[label]
439 def_span: Span,
781aab86 440 what: &'static str,
9ffffee4 441 },
781aab86 442 #[diag(hir_analysis_cannot_capture_late_bound_const)]
9ffffee4
FG
443 Const {
444 #[primary_span]
445 use_span: Span,
446 #[label]
447 def_span: Span,
781aab86
FG
448 what: &'static str,
449 },
450 #[diag(hir_analysis_cannot_capture_late_bound_lifetime)]
451 Lifetime {
452 #[primary_span]
453 use_span: Span,
454 #[label]
455 def_span: Span,
456 what: &'static str,
9ffffee4
FG
457 },
458}
353b0b11
FG
459
460#[derive(Diagnostic)]
461#[diag(hir_analysis_variances_of)]
462pub(crate) struct VariancesOf {
463 #[primary_span]
464 pub span: Span,
465 pub variances_of: String,
466}
467
468#[derive(Diagnostic)]
469#[diag(hir_analysis_pass_to_variadic_function, code = "E0617")]
470pub(crate) struct PassToVariadicFunction<'tcx, 'a> {
471 #[primary_span]
472 pub span: Span,
473 pub ty: Ty<'tcx>,
474 pub cast_ty: &'a str,
475 #[suggestion(code = "{replace}", applicability = "machine-applicable")]
476 pub sugg_span: Option<Span>,
477 pub replace: String,
478 #[help]
479 pub help: Option<()>,
480}
481
482#[derive(Diagnostic)]
483#[diag(hir_analysis_cast_thin_pointer_to_fat_pointer, code = "E0607")]
484pub(crate) struct CastThinPointerToFatPointer<'tcx> {
485 #[primary_span]
486 pub span: Span,
487 pub expr_ty: Ty<'tcx>,
488 pub cast_ty: String,
489}
490
491#[derive(Diagnostic)]
492#[diag(hir_analysis_invalid_union_field, code = "E0740")]
493pub(crate) struct InvalidUnionField {
494 #[primary_span]
495 pub field_span: Span,
496 #[subdiagnostic]
497 pub sugg: InvalidUnionFieldSuggestion,
498 #[note]
499 pub note: (),
500}
501
502#[derive(Diagnostic)]
503#[diag(hir_analysis_return_type_notation_on_non_rpitit)]
504pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
505 #[primary_span]
506 pub span: Span,
507 pub ty: Ty<'tcx>,
508 #[label]
509 pub fn_span: Option<Span>,
510 #[note]
511 pub note: (),
512}
513
514#[derive(Subdiagnostic)]
515#[multipart_suggestion(hir_analysis_invalid_union_field_sugg, applicability = "machine-applicable")]
516pub(crate) struct InvalidUnionFieldSuggestion {
517 #[suggestion_part(code = "std::mem::ManuallyDrop<")]
518 pub lo: Span,
519 #[suggestion_part(code = ">")]
520 pub hi: Span,
521}
522
523#[derive(Diagnostic)]
524#[diag(hir_analysis_return_type_notation_equality_bound)]
525pub(crate) struct ReturnTypeNotationEqualityBound {
526 #[primary_span]
527 pub span: Span,
528}
529
530#[derive(Diagnostic)]
531#[diag(hir_analysis_return_type_notation_missing_method)]
532pub(crate) struct ReturnTypeNotationMissingMethod {
533 #[primary_span]
534 pub span: Span,
49aad941 535 pub ty_name: String,
353b0b11
FG
536 pub assoc_name: Symbol,
537}
538
49aad941
FG
539#[derive(Diagnostic)]
540#[diag(hir_analysis_return_type_notation_conflicting_bound)]
541#[note]
542pub(crate) struct ReturnTypeNotationConflictingBound<'tcx> {
543 #[primary_span]
544 pub span: Span,
545 pub ty_name: String,
546 pub assoc_name: Symbol,
547 pub first_bound: ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
548 pub second_bound: ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
549}
550
353b0b11
FG
551#[derive(Diagnostic)]
552#[diag(hir_analysis_placeholder_not_allowed_item_signatures, code = "E0121")]
553pub(crate) struct PlaceholderNotAllowedItemSignatures {
554 #[primary_span]
555 #[label]
556 pub spans: Vec<Span>,
557 pub kind: String,
558}
559
560#[derive(Diagnostic)]
561#[diag(hir_analysis_associated_type_trait_uninferred_generic_params, code = "E0212")]
562pub(crate) struct AssociatedTypeTraitUninferredGenericParams {
563 #[primary_span]
564 pub span: Span,
565 #[suggestion(style = "verbose", applicability = "maybe-incorrect", code = "{bound}")]
566 pub inferred_sugg: Option<Span>,
567 pub bound: String,
568 #[subdiagnostic]
569 pub mpart_sugg: Option<AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion>,
570}
571
572#[derive(Subdiagnostic)]
573#[multipart_suggestion(
574 hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion,
575 applicability = "maybe-incorrect"
576)]
577pub(crate) struct AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion {
578 #[suggestion_part(code = "{first}")]
579 pub fspan: Span,
580 pub first: String,
581 #[suggestion_part(code = "{second}")]
582 pub sspan: Span,
583 pub second: String,
584}
585
586#[derive(Diagnostic)]
587#[diag(hir_analysis_enum_discriminant_overflowed, code = "E0370")]
588#[note]
589pub(crate) struct EnumDiscriminantOverflowed {
590 #[primary_span]
591 #[label]
592 pub span: Span,
593 pub discr: String,
594 pub item_name: Symbol,
595 pub wrapped_discr: String,
596}
597
598#[derive(Diagnostic)]
599#[diag(hir_analysis_paren_sugar_attribute)]
600#[help]
601pub(crate) struct ParenSugarAttribute {
602 #[primary_span]
603 pub span: Span,
604}
605
606#[derive(Diagnostic)]
607#[diag(hir_analysis_must_implement_one_of_attribute)]
608pub(crate) struct MustImplementOneOfAttribute {
609 #[primary_span]
610 pub span: Span,
611}
612
613#[derive(Diagnostic)]
614#[diag(hir_analysis_must_be_name_of_associated_function)]
615pub(crate) struct MustBeNameOfAssociatedFunction {
616 #[primary_span]
617 pub span: Span,
618}
619
620#[derive(Diagnostic)]
621#[diag(hir_analysis_function_not_have_default_implementation)]
622pub(crate) struct FunctionNotHaveDefaultImplementation {
623 #[primary_span]
624 pub span: Span,
625 #[note]
626 pub note_span: Span,
627}
628
629#[derive(Diagnostic)]
630#[diag(hir_analysis_must_implement_not_function)]
631pub(crate) struct MustImplementNotFunction {
632 #[primary_span]
633 pub span: Span,
634 #[subdiagnostic]
635 pub span_note: MustImplementNotFunctionSpanNote,
636 #[subdiagnostic]
637 pub note: MustImplementNotFunctionNote,
638}
639
640#[derive(Subdiagnostic)]
641#[note(hir_analysis_must_implement_not_function_span_note)]
642pub(crate) struct MustImplementNotFunctionSpanNote {
643 #[primary_span]
644 pub span: Span,
645}
646
647#[derive(Subdiagnostic)]
648#[note(hir_analysis_must_implement_not_function_note)]
649pub(crate) struct MustImplementNotFunctionNote {}
650
651#[derive(Diagnostic)]
652#[diag(hir_analysis_function_not_found_in_trait)]
653pub(crate) struct FunctionNotFoundInTrait {
654 #[primary_span]
655 pub span: Span,
656}
657
658#[derive(Diagnostic)]
659#[diag(hir_analysis_functions_names_duplicated)]
660#[note]
661pub(crate) struct FunctionNamesDuplicated {
662 #[primary_span]
663 pub spans: Vec<Span>,
664}
665
666#[derive(Diagnostic)]
667#[diag(hir_analysis_simd_ffi_highly_experimental)]
668#[help]
669pub(crate) struct SIMDFFIHighlyExperimental {
670 #[primary_span]
671 pub span: Span,
672 pub snip: String,
673}
49aad941
FG
674
675#[derive(Diagnostic)]
676
677pub enum ImplNotMarkedDefault {
678 #[diag(hir_analysis_impl_not_marked_default, code = "E0520")]
679 #[note]
680 Ok {
681 #[primary_span]
682 #[label]
683 span: Span,
684 #[label(hir_analysis_ok_label)]
685 ok_label: Span,
686 ident: Symbol,
687 },
688 #[diag(hir_analysis_impl_not_marked_default_err, code = "E0520")]
689 #[note]
690 Err {
691 #[primary_span]
692 span: Span,
693 cname: Symbol,
694 ident: Symbol,
695 },
696}
697
698#[derive(Diagnostic)]
699#[diag(hir_analysis_missing_trait_item, code = "E0046")]
700pub(crate) struct MissingTraitItem {
701 #[primary_span]
702 #[label]
703 pub span: Span,
704 #[subdiagnostic]
705 pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
706 #[subdiagnostic]
707 pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
708 #[subdiagnostic]
709 pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
710 pub missing_items_msg: String,
711}
712
713#[derive(Subdiagnostic)]
714#[label(hir_analysis_missing_trait_item_label)]
715pub(crate) struct MissingTraitItemLabel {
716 #[primary_span]
717 pub span: Span,
718 pub item: Symbol,
719}
720
721#[derive(Subdiagnostic)]
722#[suggestion(
723 hir_analysis_missing_trait_item_suggestion,
724 style = "tool-only",
725 applicability = "has-placeholders",
726 code = "{code}"
727)]
728pub(crate) struct MissingTraitItemSuggestion {
729 #[primary_span]
730 pub span: Span,
731 pub code: String,
732 pub snippet: String,
733}
734
735#[derive(Subdiagnostic)]
736#[suggestion(
737 hir_analysis_missing_trait_item_suggestion,
738 style = "hidden",
739 applicability = "has-placeholders",
740 code = "{code}"
741)]
742pub(crate) struct MissingTraitItemSuggestionNone {
743 #[primary_span]
744 pub span: Span,
745 pub code: String,
746 pub snippet: String,
747}
748
749#[derive(Diagnostic)]
750#[diag(hir_analysis_missing_one_of_trait_item, code = "E0046")]
751pub(crate) struct MissingOneOfTraitItem {
752 #[primary_span]
753 #[label]
754 pub span: Span,
755 #[note]
756 pub note: Option<Span>,
757 pub missing_items_msg: String,
758}
759
760#[derive(Diagnostic)]
761#[diag(hir_analysis_missing_trait_item_unstable, code = "E0046")]
762#[note]
763pub(crate) struct MissingTraitItemUnstable {
764 #[primary_span]
765 pub span: Span,
766 #[note(hir_analysis_some_note)]
767 pub some_note: bool,
768 #[note(hir_analysis_none_note)]
769 pub none_note: bool,
770 pub missing_item_name: Symbol,
771 pub feature: Symbol,
772 pub reason: String,
773}
774
775#[derive(Diagnostic)]
776#[diag(hir_analysis_transparent_enum_variant, code = "E0731")]
777pub(crate) struct TransparentEnumVariant {
778 #[primary_span]
779 #[label]
780 pub span: Span,
781 #[label(hir_analysis_multi_label)]
782 pub spans: Vec<Span>,
783 #[label(hir_analysis_many_label)]
784 pub many: Option<Span>,
785 pub number: usize,
786 pub path: String,
787}
788
789#[derive(Diagnostic)]
790#[diag(hir_analysis_transparent_non_zero_sized_enum, code = "E0690")]
791pub(crate) struct TransparentNonZeroSizedEnum<'a> {
792 #[primary_span]
793 #[label]
794 pub span: Span,
795 #[label(hir_analysis_labels)]
796 pub spans: Vec<Span>,
797 pub field_count: usize,
798 pub desc: &'a str,
799}
800
801#[derive(Diagnostic)]
802#[diag(hir_analysis_transparent_non_zero_sized, code = "E0690")]
803pub(crate) struct TransparentNonZeroSized<'a> {
804 #[primary_span]
805 #[label]
806 pub span: Span,
807 #[label(hir_analysis_labels)]
808 pub spans: Vec<Span>,
809 pub field_count: usize,
810 pub desc: &'a str,
811}
812
813#[derive(Diagnostic)]
814#[diag(hir_analysis_too_large_static)]
815pub(crate) struct TooLargeStatic {
816 #[primary_span]
817 pub span: Span,
818}
819
820#[derive(Diagnostic)]
821#[diag(hir_analysis_specialization_trait)]
822#[help]
823pub(crate) struct SpecializationTrait {
824 #[primary_span]
825 pub span: Span,
826}
827
828#[derive(Diagnostic)]
829#[diag(hir_analysis_closure_implicit_hrtb)]
830pub(crate) struct ClosureImplicitHrtb {
831 #[primary_span]
832 pub spans: Vec<Span>,
833 #[label]
834 pub for_sp: Span,
835}
836
837#[derive(Diagnostic)]
838#[diag(hir_analysis_empty_specialization)]
839pub(crate) struct EmptySpecialization {
840 #[primary_span]
841 pub span: Span,
842 #[note]
843 pub base_impl_span: Span,
844}
845
846#[derive(Diagnostic)]
847#[diag(hir_analysis_const_specialize)]
848pub(crate) struct ConstSpecialize {
849 #[primary_span]
850 pub span: Span,
851}
852
853#[derive(Diagnostic)]
854#[diag(hir_analysis_static_specialize)]
855pub(crate) struct StaticSpecialize {
856 #[primary_span]
857 pub span: Span,
858}
859
860#[derive(Diagnostic)]
861#[diag(hir_analysis_missing_tilde_const)]
862pub(crate) struct MissingTildeConst {
863 #[primary_span]
864 pub span: Span,
865}
866
867#[derive(Diagnostic)]
868pub(crate) enum DropImplPolarity {
869 #[diag(hir_analysis_drop_impl_negative)]
870 Negative {
871 #[primary_span]
872 span: Span,
873 },
874 #[diag(hir_analysis_drop_impl_reservation)]
875 Reservation {
876 #[primary_span]
877 span: Span,
878 },
879}
fe692bf9
FG
880
881#[derive(Diagnostic)]
882pub(crate) enum ReturnTypeNotationIllegalParam {
883 #[diag(hir_analysis_return_type_notation_illegal_param_type)]
884 Type {
885 #[primary_span]
886 span: Span,
887 #[label]
888 param_span: Span,
889 },
890 #[diag(hir_analysis_return_type_notation_illegal_param_const)]
891 Const {
892 #[primary_span]
893 span: Span,
894 #[label]
895 param_span: Span,
896 },
897}
898
899#[derive(Diagnostic)]
900pub(crate) enum LateBoundInApit {
901 #[diag(hir_analysis_late_bound_type_in_apit)]
902 Type {
903 #[primary_span]
904 span: Span,
905 #[label]
906 param_span: Span,
907 },
908 #[diag(hir_analysis_late_bound_const_in_apit)]
909 Const {
910 #[primary_span]
911 span: Span,
912 #[label]
913 param_span: Span,
914 },
915 #[diag(hir_analysis_late_bound_lifetime_in_apit)]
916 Lifetime {
917 #[primary_span]
918 span: Span,
919 #[label]
920 param_span: Span,
921 },
922}
923
924#[derive(LintDiagnostic)]
925#[diag(hir_analysis_unused_associated_type_bounds)]
926#[note]
927pub struct UnusedAssociatedTypeBounds {
928 #[suggestion(code = "")]
929 pub span: Span,
930}
add651ee 931
781aab86
FG
932#[derive(LintDiagnostic)]
933#[diag(hir_analysis_rpitit_refined)]
934#[note]
935pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
936 #[suggestion(applicability = "maybe-incorrect", code = "{pre}{return_ty}{post}")]
937 pub impl_return_span: Span,
938 #[label]
939 pub trait_return_span: Option<Span>,
940 #[label(hir_analysis_unmatched_bound_label)]
941 pub unmatched_bound: Option<Span>,
942
943 pub pre: &'static str,
944 pub post: &'static str,
945 pub return_ty: Ty<'tcx>,
946}
947
add651ee
FG
948#[derive(Diagnostic)]
949#[diag(hir_analysis_assoc_bound_on_const)]
950#[note]
951pub struct AssocBoundOnConst {
952 #[primary_span]
953 pub span: Span,
954 pub descr: &'static str,
955}
781aab86
FG
956
957#[derive(Diagnostic)]
958#[diag(hir_analysis_inherent_ty_outside, code = "E0390")]
959#[help]
960pub struct InherentTyOutside {
961 #[primary_span]
962 #[help(hir_analysis_span_help)]
963 pub span: Span,
964}
965
966#[derive(Diagnostic)]
967#[diag(hir_analysis_coerce_unsized_may, code = "E0378")]
968pub struct DispatchFromDynCoercion<'a> {
969 #[primary_span]
970 pub span: Span,
971 pub trait_name: &'a str,
972 #[note(hir_analysis_coercion_between_struct_same_note)]
973 pub note: bool,
974 pub source_path: String,
975 pub target_path: String,
976}
977
978#[derive(Diagnostic)]
979#[diag(hir_analysis_dispatch_from_dyn_repr, code = "E0378")]
980pub struct DispatchFromDynRepr {
981 #[primary_span]
982 pub span: Span,
983}
984
985#[derive(Diagnostic)]
986#[diag(hir_analysis_inherent_ty_outside_relevant, code = "E0390")]
987#[help]
988pub struct InherentTyOutsideRelevant {
989 #[primary_span]
990 pub span: Span,
991 #[help(hir_analysis_span_help)]
992 pub help_span: Span,
993}
994
995#[derive(Diagnostic)]
996#[diag(hir_analysis_inherent_ty_outside_new, code = "E0116")]
997#[note]
998pub struct InherentTyOutsideNew {
999 #[primary_span]
1000 #[label]
1001 pub span: Span,
1002}
1003
1004#[derive(Diagnostic)]
1005#[diag(hir_analysis_inherent_ty_outside_primitive, code = "E0390")]
1006#[help]
1007pub struct InherentTyOutsidePrimitive {
1008 #[primary_span]
1009 pub span: Span,
1010 #[help(hir_analysis_span_help)]
1011 pub help_span: Span,
1012}
1013
1014#[derive(Diagnostic)]
1015#[diag(hir_analysis_inherent_primitive_ty, code = "E0390")]
1016#[help]
1017pub struct InherentPrimitiveTy<'a> {
1018 #[primary_span]
1019 pub span: Span,
1020 #[subdiagnostic]
1021 pub note: Option<InherentPrimitiveTyNote<'a>>,
1022}
1023
1024#[derive(Subdiagnostic)]
1025#[note(hir_analysis_inherent_primitive_ty_note)]
1026pub struct InherentPrimitiveTyNote<'a> {
1027 pub subty: Ty<'a>,
1028}
1029
1030#[derive(Diagnostic)]
1031#[diag(hir_analysis_inherent_dyn, code = "E0785")]
1032#[note]
1033pub struct InherentDyn {
1034 #[primary_span]
1035 #[label]
1036 pub span: Span,
1037}
1038
1039#[derive(Diagnostic)]
1040#[diag(hir_analysis_inherent_nominal, code = "E0118")]
1041#[note]
1042pub struct InherentNominal {
1043 #[primary_span]
1044 #[label]
1045 pub span: Span,
1046}
1047
1048#[derive(Diagnostic)]
1049#[diag(hir_analysis_dispatch_from_dyn_zst, code = "E0378")]
1050#[note]
1051pub struct DispatchFromDynZST<'a> {
1052 #[primary_span]
1053 pub span: Span,
1054 pub name: Symbol,
1055 pub ty: Ty<'a>,
1056}
1057
1058#[derive(Diagnostic)]
1059#[diag(hir_analysis_coerce_unsized_may, code = "E0378")]
1060pub struct DispatchFromDynSingle<'a> {
1061 #[primary_span]
1062 pub span: Span,
1063 pub trait_name: &'a str,
1064 #[note(hir_analysis_coercion_between_struct_single_note)]
1065 pub note: bool,
1066}
1067
1068#[derive(Diagnostic)]
1069#[diag(hir_analysis_dispatch_from_dyn_multi, code = "E0378")]
1070#[note]
1071pub struct DispatchFromDynMulti {
1072 #[primary_span]
1073 pub span: Span,
1074 #[note(hir_analysis_coercions_note)]
1075 pub coercions_note: bool,
1076 pub number: usize,
1077 pub coercions: String,
1078}
1079
1080#[derive(Diagnostic)]
1081#[diag(hir_analysis_coerce_unsized_may, code = "E0376")]
1082pub struct DispatchFromDynStruct<'a> {
1083 #[primary_span]
1084 pub span: Span,
1085 pub trait_name: &'a str,
1086}
1087
1088#[derive(Diagnostic)]
1089#[diag(hir_analysis_coerce_unsized_may, code = "E0377")]
1090pub struct DispatchFromDynSame<'a> {
1091 #[primary_span]
1092 pub span: Span,
1093 pub trait_name: &'a str,
1094 #[note(hir_analysis_coercion_between_struct_same_note)]
1095 pub note: bool,
1096 pub source_path: String,
1097 pub target_path: String,
1098}
1099
1100#[derive(Diagnostic)]
1101#[diag(hir_analysis_coerce_unsized_may, code = "E0374")]
1102pub struct CoerceUnsizedOneField<'a> {
1103 #[primary_span]
1104 pub span: Span,
1105 pub trait_name: &'a str,
1106 #[note(hir_analysis_coercion_between_struct_single_note)]
1107 pub note: bool,
1108}
1109
1110#[derive(Diagnostic)]
1111#[diag(hir_analysis_coerce_unsized_multi, code = "E0375")]
1112#[note]
1113pub struct CoerceUnsizedMulti {
1114 #[primary_span]
1115 #[label]
1116 pub span: Span,
1117 #[note(hir_analysis_coercions_note)]
1118 pub coercions_note: bool,
1119 pub number: usize,
1120 pub coercions: String,
1121}
1122
1123#[derive(Diagnostic)]
1124#[diag(hir_analysis_coerce_unsized_may, code = "E0378")]
1125pub struct CoerceUnsizedMay<'a> {
1126 #[primary_span]
1127 pub span: Span,
1128 pub trait_name: &'a str,
1129}
1130
1131#[derive(Diagnostic)]
1132#[diag(hir_analysis_trait_cannot_impl_for_ty, code = "E0204")]
1133pub struct TraitCannotImplForTy {
1134 #[primary_span]
1135 pub span: Span,
1136 pub trait_name: String,
1137 #[label]
1138 pub label_spans: Vec<Span>,
1139 #[subdiagnostic]
1140 pub notes: Vec<ImplForTyRequires>,
1141}
1142
1143#[derive(Subdiagnostic)]
1144#[note(hir_analysis_requires_note)]
1145pub struct ImplForTyRequires {
1146 #[primary_span]
1147 pub span: MultiSpan,
1148 pub error_predicate: String,
1149 pub trait_name: String,
1150 pub ty: String,
1151}