]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_hir_analysis/src/errors.rs
New upstream version 1.71.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};
353b0b11 8use rustc_macros::{Diagnostic, 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
04454e1e
FG
187pub struct MissingTypeParams {
188 pub span: Span,
189 pub def_span: Span,
f2b60f7d 190 pub span_snippet: Option<String>,
064997fb 191 pub missing_type_params: Vec<Symbol>,
04454e1e
FG
192 pub empty_generic_args: bool,
193}
194
2b03887a
FG
195// Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`.
196impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
487cf647 197 #[track_caller]
f2b60f7d
FG
198 fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
199 let mut err = handler.struct_span_err_with_code(
04454e1e 200 self.span,
9ffffee4 201 fluent::hir_analysis_missing_type_params,
04454e1e
FG
202 error_code!(E0393),
203 );
204 err.set_arg("parameterCount", self.missing_type_params.len());
205 err.set_arg(
206 "parameters",
207 self.missing_type_params
208 .iter()
209 .map(|n| format!("`{}`", n))
210 .collect::<Vec<_>>()
211 .join(", "),
212 );
213
9ffffee4 214 err.span_label(self.def_span, fluent::hir_analysis_label);
04454e1e
FG
215
216 let mut suggested = false;
f2b60f7d
FG
217 // Don't suggest setting the type params if there are some already: the order is
218 // tricky to get right and the user will already know what the syntax is.
219 if let Some(snippet) = self.span_snippet && self.empty_generic_args {
04454e1e
FG
220 if snippet.ends_with('>') {
221 // The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion
222 // we would have to preserve the right order. For now, as clearly the user is
223 // aware of the syntax, we do nothing.
224 } else {
225 // The user wrote `Iterator`, so we don't have a type we can suggest, but at
226 // least we can clue them to the correct syntax `Iterator<Type>`.
227 err.span_suggestion(
228 self.span,
9ffffee4 229 fluent::hir_analysis_suggestion,
064997fb
FG
230 format!(
231 "{}<{}>",
232 snippet,
233 self.missing_type_params
234 .iter()
235 .map(|n| n.to_string())
236 .collect::<Vec<_>>()
237 .join(", ")
238 ),
04454e1e
FG
239 Applicability::HasPlaceholders,
240 );
241 suggested = true;
242 }
243 }
244 if !suggested {
9ffffee4 245 err.span_label(self.span, fluent::hir_analysis_no_suggestion_label);
04454e1e
FG
246 }
247
9ffffee4 248 err.note(fluent::hir_analysis_note);
04454e1e
FG
249 err
250 }
251}
252
2b03887a
FG
253#[derive(Diagnostic)]
254#[diag(hir_analysis_manual_implementation, code = "E0183")]
04454e1e
FG
255#[help]
256pub struct ManualImplementation {
257 #[primary_span]
258 #[label]
259 pub span: Span,
260 pub trait_name: String,
261}
262
2b03887a
FG
263#[derive(Diagnostic)]
264#[diag(hir_analysis_substs_on_overridden_impl)]
04454e1e
FG
265pub struct SubstsOnOverriddenImpl {
266 #[primary_span]
1b1a35ee
XL
267 pub span: Span,
268}
f2b60f7d 269
2b03887a
FG
270#[derive(Diagnostic)]
271#[diag(hir_analysis_const_impl_for_non_const_trait)]
272pub struct ConstImplForNonConstTrait {
273 #[primary_span]
274 pub trait_ref_span: Span,
275 pub trait_name: String,
276 #[suggestion(applicability = "machine-applicable", code = "#[const_trait]")]
277 pub local_trait_span: Option<Span>,
278 #[note]
279 pub marking: (),
9ffffee4 280 #[note(hir_analysis_adding)]
2b03887a
FG
281 pub adding: (),
282}
283
284#[derive(Diagnostic)]
285#[diag(hir_analysis_const_bound_for_non_const_trait)]
286pub struct ConstBoundForNonConstTrait {
287 #[primary_span]
288 pub span: Span,
289}
290
291#[derive(Diagnostic)]
292#[diag(hir_analysis_self_in_impl_self)]
293pub struct SelfInImplSelf {
294 #[primary_span]
295 pub span: MultiSpan,
296 #[note]
297 pub note: (),
298}
487cf647
FG
299
300#[derive(Diagnostic)]
301#[diag(hir_analysis_linkage_type, code = "E0791")]
302pub(crate) struct LinkageType {
303 #[primary_span]
304 pub span: Span,
305}
9c376795
FG
306
307#[derive(Diagnostic)]
308#[help]
309#[diag(hir_analysis_auto_deref_reached_recursion_limit, code = "E0055")]
310pub struct AutoDerefReachedRecursionLimit<'a> {
311 #[primary_span]
312 #[label]
313 pub span: Span,
314 pub ty: Ty<'a>,
315 pub suggested_limit: rustc_session::Limit,
316 pub crate_name: Symbol,
317}
9ffffee4
FG
318
319#[derive(Diagnostic)]
320#[diag(hir_analysis_where_clause_on_main, code = "E0646")]
321pub(crate) struct WhereClauseOnMain {
322 #[primary_span]
323 pub span: Span,
324 #[label]
325 pub generics_span: Option<Span>,
326}
327
328#[derive(Diagnostic)]
329#[diag(hir_analysis_track_caller_on_main)]
330pub(crate) struct TrackCallerOnMain {
331 #[primary_span]
332 #[suggestion(applicability = "maybe-incorrect", code = "")]
333 pub span: Span,
334 #[label(hir_analysis_track_caller_on_main)]
335 pub annotated: Span,
336}
337
353b0b11
FG
338#[derive(Diagnostic)]
339#[diag(hir_analysis_target_feature_on_main)]
340pub(crate) struct TargetFeatureOnMain {
341 #[primary_span]
342 #[label(hir_analysis_target_feature_on_main)]
343 pub main: Span,
344}
345
9ffffee4
FG
346#[derive(Diagnostic)]
347#[diag(hir_analysis_start_not_track_caller)]
348pub(crate) struct StartTrackCaller {
349 #[primary_span]
350 pub span: Span,
351 #[label]
352 pub start: Span,
353}
354
353b0b11
FG
355#[derive(Diagnostic)]
356#[diag(hir_analysis_start_not_target_feature)]
357pub(crate) struct StartTargetFeature {
358 #[primary_span]
359 pub span: Span,
360 #[label]
361 pub start: Span,
362}
363
9ffffee4
FG
364#[derive(Diagnostic)]
365#[diag(hir_analysis_start_not_async, code = "E0752")]
366pub(crate) struct StartAsync {
367 #[primary_span]
368 #[label]
369 pub span: Span,
370}
371
372#[derive(Diagnostic)]
373#[diag(hir_analysis_start_function_where, code = "E0647")]
374pub(crate) struct StartFunctionWhere {
375 #[primary_span]
376 #[label]
377 pub span: Span,
378}
379
380#[derive(Diagnostic)]
381#[diag(hir_analysis_start_function_parameters, code = "E0132")]
382pub(crate) struct StartFunctionParameters {
383 #[primary_span]
384 #[label]
385 pub span: Span,
386}
387
388#[derive(Diagnostic)]
389#[diag(hir_analysis_main_function_return_type_generic, code = "E0131")]
390pub(crate) struct MainFunctionReturnTypeGeneric {
391 #[primary_span]
392 pub span: Span,
393}
394
395#[derive(Diagnostic)]
396#[diag(hir_analysis_main_function_async, code = "E0752")]
397pub(crate) struct MainFunctionAsync {
398 #[primary_span]
399 pub span: Span,
400 #[label]
401 pub asyncness: Option<Span>,
402}
403
404#[derive(Diagnostic)]
405#[diag(hir_analysis_main_function_generic_parameters, code = "E0131")]
406pub(crate) struct MainFunctionGenericParameters {
407 #[primary_span]
408 pub span: Span,
409 #[label]
410 pub label_span: Option<Span>,
411}
412
413#[derive(Diagnostic)]
414#[diag(hir_analysis_variadic_function_compatible_convention, code = "E0045")]
415pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
416 #[primary_span]
417 #[label]
418 pub span: Span,
419 pub conventions: &'a str,
420}
421
422#[derive(Diagnostic)]
423pub(crate) enum CannotCaptureLateBoundInAnonConst {
424 #[diag(hir_analysis_cannot_capture_late_bound_ty_in_anon_const)]
425 Type {
426 #[primary_span]
427 use_span: Span,
428 #[label]
429 def_span: Span,
430 },
431 #[diag(hir_analysis_cannot_capture_late_bound_const_in_anon_const)]
432 Const {
433 #[primary_span]
434 use_span: Span,
435 #[label]
436 def_span: Span,
437 },
438}
353b0b11
FG
439
440#[derive(Diagnostic)]
441#[diag(hir_analysis_variances_of)]
442pub(crate) struct VariancesOf {
443 #[primary_span]
444 pub span: Span,
445 pub variances_of: String,
446}
447
448#[derive(Diagnostic)]
449#[diag(hir_analysis_pass_to_variadic_function, code = "E0617")]
450pub(crate) struct PassToVariadicFunction<'tcx, 'a> {
451 #[primary_span]
452 pub span: Span,
453 pub ty: Ty<'tcx>,
454 pub cast_ty: &'a str,
455 #[suggestion(code = "{replace}", applicability = "machine-applicable")]
456 pub sugg_span: Option<Span>,
457 pub replace: String,
458 #[help]
459 pub help: Option<()>,
460}
461
462#[derive(Diagnostic)]
463#[diag(hir_analysis_cast_thin_pointer_to_fat_pointer, code = "E0607")]
464pub(crate) struct CastThinPointerToFatPointer<'tcx> {
465 #[primary_span]
466 pub span: Span,
467 pub expr_ty: Ty<'tcx>,
468 pub cast_ty: String,
469}
470
471#[derive(Diagnostic)]
472#[diag(hir_analysis_invalid_union_field, code = "E0740")]
473pub(crate) struct InvalidUnionField {
474 #[primary_span]
475 pub field_span: Span,
476 #[subdiagnostic]
477 pub sugg: InvalidUnionFieldSuggestion,
478 #[note]
479 pub note: (),
480}
481
482#[derive(Diagnostic)]
483#[diag(hir_analysis_return_type_notation_on_non_rpitit)]
484pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
485 #[primary_span]
486 pub span: Span,
487 pub ty: Ty<'tcx>,
488 #[label]
489 pub fn_span: Option<Span>,
490 #[note]
491 pub note: (),
492}
493
494#[derive(Subdiagnostic)]
495#[multipart_suggestion(hir_analysis_invalid_union_field_sugg, applicability = "machine-applicable")]
496pub(crate) struct InvalidUnionFieldSuggestion {
497 #[suggestion_part(code = "std::mem::ManuallyDrop<")]
498 pub lo: Span,
499 #[suggestion_part(code = ">")]
500 pub hi: Span,
501}
502
503#[derive(Diagnostic)]
504#[diag(hir_analysis_return_type_notation_equality_bound)]
505pub(crate) struct ReturnTypeNotationEqualityBound {
506 #[primary_span]
507 pub span: Span,
508}
509
510#[derive(Diagnostic)]
511#[diag(hir_analysis_return_type_notation_missing_method)]
512pub(crate) struct ReturnTypeNotationMissingMethod {
513 #[primary_span]
514 pub span: Span,
49aad941 515 pub ty_name: String,
353b0b11
FG
516 pub assoc_name: Symbol,
517}
518
49aad941
FG
519#[derive(Diagnostic)]
520#[diag(hir_analysis_return_type_notation_conflicting_bound)]
521#[note]
522pub(crate) struct ReturnTypeNotationConflictingBound<'tcx> {
523 #[primary_span]
524 pub span: Span,
525 pub ty_name: String,
526 pub assoc_name: Symbol,
527 pub first_bound: ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
528 pub second_bound: ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
529}
530
353b0b11
FG
531#[derive(Diagnostic)]
532#[diag(hir_analysis_placeholder_not_allowed_item_signatures, code = "E0121")]
533pub(crate) struct PlaceholderNotAllowedItemSignatures {
534 #[primary_span]
535 #[label]
536 pub spans: Vec<Span>,
537 pub kind: String,
538}
539
540#[derive(Diagnostic)]
541#[diag(hir_analysis_associated_type_trait_uninferred_generic_params, code = "E0212")]
542pub(crate) struct AssociatedTypeTraitUninferredGenericParams {
543 #[primary_span]
544 pub span: Span,
545 #[suggestion(style = "verbose", applicability = "maybe-incorrect", code = "{bound}")]
546 pub inferred_sugg: Option<Span>,
547 pub bound: String,
548 #[subdiagnostic]
549 pub mpart_sugg: Option<AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion>,
550}
551
552#[derive(Subdiagnostic)]
553#[multipart_suggestion(
554 hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion,
555 applicability = "maybe-incorrect"
556)]
557pub(crate) struct AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion {
558 #[suggestion_part(code = "{first}")]
559 pub fspan: Span,
560 pub first: String,
561 #[suggestion_part(code = "{second}")]
562 pub sspan: Span,
563 pub second: String,
564}
565
566#[derive(Diagnostic)]
567#[diag(hir_analysis_enum_discriminant_overflowed, code = "E0370")]
568#[note]
569pub(crate) struct EnumDiscriminantOverflowed {
570 #[primary_span]
571 #[label]
572 pub span: Span,
573 pub discr: String,
574 pub item_name: Symbol,
575 pub wrapped_discr: String,
576}
577
578#[derive(Diagnostic)]
579#[diag(hir_analysis_paren_sugar_attribute)]
580#[help]
581pub(crate) struct ParenSugarAttribute {
582 #[primary_span]
583 pub span: Span,
584}
585
586#[derive(Diagnostic)]
587#[diag(hir_analysis_must_implement_one_of_attribute)]
588pub(crate) struct MustImplementOneOfAttribute {
589 #[primary_span]
590 pub span: Span,
591}
592
593#[derive(Diagnostic)]
594#[diag(hir_analysis_must_be_name_of_associated_function)]
595pub(crate) struct MustBeNameOfAssociatedFunction {
596 #[primary_span]
597 pub span: Span,
598}
599
600#[derive(Diagnostic)]
601#[diag(hir_analysis_function_not_have_default_implementation)]
602pub(crate) struct FunctionNotHaveDefaultImplementation {
603 #[primary_span]
604 pub span: Span,
605 #[note]
606 pub note_span: Span,
607}
608
609#[derive(Diagnostic)]
610#[diag(hir_analysis_must_implement_not_function)]
611pub(crate) struct MustImplementNotFunction {
612 #[primary_span]
613 pub span: Span,
614 #[subdiagnostic]
615 pub span_note: MustImplementNotFunctionSpanNote,
616 #[subdiagnostic]
617 pub note: MustImplementNotFunctionNote,
618}
619
620#[derive(Subdiagnostic)]
621#[note(hir_analysis_must_implement_not_function_span_note)]
622pub(crate) struct MustImplementNotFunctionSpanNote {
623 #[primary_span]
624 pub span: Span,
625}
626
627#[derive(Subdiagnostic)]
628#[note(hir_analysis_must_implement_not_function_note)]
629pub(crate) struct MustImplementNotFunctionNote {}
630
631#[derive(Diagnostic)]
632#[diag(hir_analysis_function_not_found_in_trait)]
633pub(crate) struct FunctionNotFoundInTrait {
634 #[primary_span]
635 pub span: Span,
636}
637
638#[derive(Diagnostic)]
639#[diag(hir_analysis_functions_names_duplicated)]
640#[note]
641pub(crate) struct FunctionNamesDuplicated {
642 #[primary_span]
643 pub spans: Vec<Span>,
644}
645
646#[derive(Diagnostic)]
647#[diag(hir_analysis_simd_ffi_highly_experimental)]
648#[help]
649pub(crate) struct SIMDFFIHighlyExperimental {
650 #[primary_span]
651 pub span: Span,
652 pub snip: String,
653}
49aad941
FG
654
655#[derive(Diagnostic)]
656
657pub enum ImplNotMarkedDefault {
658 #[diag(hir_analysis_impl_not_marked_default, code = "E0520")]
659 #[note]
660 Ok {
661 #[primary_span]
662 #[label]
663 span: Span,
664 #[label(hir_analysis_ok_label)]
665 ok_label: Span,
666 ident: Symbol,
667 },
668 #[diag(hir_analysis_impl_not_marked_default_err, code = "E0520")]
669 #[note]
670 Err {
671 #[primary_span]
672 span: Span,
673 cname: Symbol,
674 ident: Symbol,
675 },
676}
677
678#[derive(Diagnostic)]
679#[diag(hir_analysis_missing_trait_item, code = "E0046")]
680pub(crate) struct MissingTraitItem {
681 #[primary_span]
682 #[label]
683 pub span: Span,
684 #[subdiagnostic]
685 pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
686 #[subdiagnostic]
687 pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
688 #[subdiagnostic]
689 pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
690 pub missing_items_msg: String,
691}
692
693#[derive(Subdiagnostic)]
694#[label(hir_analysis_missing_trait_item_label)]
695pub(crate) struct MissingTraitItemLabel {
696 #[primary_span]
697 pub span: Span,
698 pub item: Symbol,
699}
700
701#[derive(Subdiagnostic)]
702#[suggestion(
703 hir_analysis_missing_trait_item_suggestion,
704 style = "tool-only",
705 applicability = "has-placeholders",
706 code = "{code}"
707)]
708pub(crate) struct MissingTraitItemSuggestion {
709 #[primary_span]
710 pub span: Span,
711 pub code: String,
712 pub snippet: String,
713}
714
715#[derive(Subdiagnostic)]
716#[suggestion(
717 hir_analysis_missing_trait_item_suggestion,
718 style = "hidden",
719 applicability = "has-placeholders",
720 code = "{code}"
721)]
722pub(crate) struct MissingTraitItemSuggestionNone {
723 #[primary_span]
724 pub span: Span,
725 pub code: String,
726 pub snippet: String,
727}
728
729#[derive(Diagnostic)]
730#[diag(hir_analysis_missing_one_of_trait_item, code = "E0046")]
731pub(crate) struct MissingOneOfTraitItem {
732 #[primary_span]
733 #[label]
734 pub span: Span,
735 #[note]
736 pub note: Option<Span>,
737 pub missing_items_msg: String,
738}
739
740#[derive(Diagnostic)]
741#[diag(hir_analysis_missing_trait_item_unstable, code = "E0046")]
742#[note]
743pub(crate) struct MissingTraitItemUnstable {
744 #[primary_span]
745 pub span: Span,
746 #[note(hir_analysis_some_note)]
747 pub some_note: bool,
748 #[note(hir_analysis_none_note)]
749 pub none_note: bool,
750 pub missing_item_name: Symbol,
751 pub feature: Symbol,
752 pub reason: String,
753}
754
755#[derive(Diagnostic)]
756#[diag(hir_analysis_transparent_enum_variant, code = "E0731")]
757pub(crate) struct TransparentEnumVariant {
758 #[primary_span]
759 #[label]
760 pub span: Span,
761 #[label(hir_analysis_multi_label)]
762 pub spans: Vec<Span>,
763 #[label(hir_analysis_many_label)]
764 pub many: Option<Span>,
765 pub number: usize,
766 pub path: String,
767}
768
769#[derive(Diagnostic)]
770#[diag(hir_analysis_transparent_non_zero_sized_enum, code = "E0690")]
771pub(crate) struct TransparentNonZeroSizedEnum<'a> {
772 #[primary_span]
773 #[label]
774 pub span: Span,
775 #[label(hir_analysis_labels)]
776 pub spans: Vec<Span>,
777 pub field_count: usize,
778 pub desc: &'a str,
779}
780
781#[derive(Diagnostic)]
782#[diag(hir_analysis_transparent_non_zero_sized, code = "E0690")]
783pub(crate) struct TransparentNonZeroSized<'a> {
784 #[primary_span]
785 #[label]
786 pub span: Span,
787 #[label(hir_analysis_labels)]
788 pub spans: Vec<Span>,
789 pub field_count: usize,
790 pub desc: &'a str,
791}
792
793#[derive(Diagnostic)]
794#[diag(hir_analysis_too_large_static)]
795pub(crate) struct TooLargeStatic {
796 #[primary_span]
797 pub span: Span,
798}
799
800#[derive(Diagnostic)]
801#[diag(hir_analysis_specialization_trait)]
802#[help]
803pub(crate) struct SpecializationTrait {
804 #[primary_span]
805 pub span: Span,
806}
807
808#[derive(Diagnostic)]
809#[diag(hir_analysis_closure_implicit_hrtb)]
810pub(crate) struct ClosureImplicitHrtb {
811 #[primary_span]
812 pub spans: Vec<Span>,
813 #[label]
814 pub for_sp: Span,
815}
816
817#[derive(Diagnostic)]
818#[diag(hir_analysis_empty_specialization)]
819pub(crate) struct EmptySpecialization {
820 #[primary_span]
821 pub span: Span,
822 #[note]
823 pub base_impl_span: Span,
824}
825
826#[derive(Diagnostic)]
827#[diag(hir_analysis_const_specialize)]
828pub(crate) struct ConstSpecialize {
829 #[primary_span]
830 pub span: Span,
831}
832
833#[derive(Diagnostic)]
834#[diag(hir_analysis_static_specialize)]
835pub(crate) struct StaticSpecialize {
836 #[primary_span]
837 pub span: Span,
838}
839
840#[derive(Diagnostic)]
841#[diag(hir_analysis_missing_tilde_const)]
842pub(crate) struct MissingTildeConst {
843 #[primary_span]
844 pub span: Span,
845}
846
847#[derive(Diagnostic)]
848pub(crate) enum DropImplPolarity {
849 #[diag(hir_analysis_drop_impl_negative)]
850 Negative {
851 #[primary_span]
852 span: Span,
853 },
854 #[diag(hir_analysis_drop_impl_reservation)]
855 Reservation {
856 #[primary_span]
857 span: Span,
858 },
859}