• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Errors emitted by ty_utils
2 
3 use rustc_macros::{Diagnostic, Subdiagnostic};
4 use rustc_middle::ty::{GenericArg, Ty};
5 use rustc_span::Span;
6 
7 #[derive(Diagnostic)]
8 #[diag(ty_utils_needs_drop_overflow)]
9 pub struct NeedsDropOverflow<'tcx> {
10     pub query_ty: Ty<'tcx>,
11 }
12 
13 #[derive(Diagnostic)]
14 #[diag(ty_utils_generic_constant_too_complex)]
15 #[help]
16 pub struct GenericConstantTooComplex {
17     #[primary_span]
18     pub span: Span,
19     #[note(ty_utils_maybe_supported)]
20     pub maybe_supported: Option<()>,
21     #[subdiagnostic]
22     pub sub: GenericConstantTooComplexSub,
23 }
24 
25 #[derive(Subdiagnostic)]
26 pub enum GenericConstantTooComplexSub {
27     #[label(ty_utils_borrow_not_supported)]
28     BorrowNotSupported(#[primary_span] Span),
29     #[label(ty_utils_address_and_deref_not_supported)]
30     AddressAndDerefNotSupported(#[primary_span] Span),
31     #[label(ty_utils_array_not_supported)]
32     ArrayNotSupported(#[primary_span] Span),
33     #[label(ty_utils_block_not_supported)]
34     BlockNotSupported(#[primary_span] Span),
35     #[label(ty_utils_never_to_any_not_supported)]
36     NeverToAnyNotSupported(#[primary_span] Span),
37     #[label(ty_utils_tuple_not_supported)]
38     TupleNotSupported(#[primary_span] Span),
39     #[label(ty_utils_index_not_supported)]
40     IndexNotSupported(#[primary_span] Span),
41     #[label(ty_utils_field_not_supported)]
42     FieldNotSupported(#[primary_span] Span),
43     #[label(ty_utils_const_block_not_supported)]
44     ConstBlockNotSupported(#[primary_span] Span),
45     #[label(ty_utils_adt_not_supported)]
46     AdtNotSupported(#[primary_span] Span),
47     #[label(ty_utils_pointer_not_supported)]
48     PointerNotSupported(#[primary_span] Span),
49     #[label(ty_utils_yield_not_supported)]
50     YieldNotSupported(#[primary_span] Span),
51     #[label(ty_utils_loop_not_supported)]
52     LoopNotSupported(#[primary_span] Span),
53     #[label(ty_utils_box_not_supported)]
54     BoxNotSupported(#[primary_span] Span),
55     #[label(ty_utils_binary_not_supported)]
56     BinaryNotSupported(#[primary_span] Span),
57     #[label(ty_utils_logical_op_not_supported)]
58     LogicalOpNotSupported(#[primary_span] Span),
59     #[label(ty_utils_assign_not_supported)]
60     AssignNotSupported(#[primary_span] Span),
61     #[label(ty_utils_closure_and_return_not_supported)]
62     ClosureAndReturnNotSupported(#[primary_span] Span),
63     #[label(ty_utils_control_flow_not_supported)]
64     ControlFlowNotSupported(#[primary_span] Span),
65     #[label(ty_utils_inline_asm_not_supported)]
66     InlineAsmNotSupported(#[primary_span] Span),
67     #[label(ty_utils_operation_not_supported)]
68     OperationNotSupported(#[primary_span] Span),
69 }
70 
71 #[derive(Diagnostic)]
72 #[diag(ty_utils_unexpected_fnptr_associated_item)]
73 pub struct UnexpectedFnPtrAssociatedItem {
74     #[primary_span]
75     pub span: Span,
76 }
77 
78 #[derive(Diagnostic)]
79 #[diag(ty_utils_zero_length_simd_type)]
80 pub struct ZeroLengthSimdType<'tcx> {
81     pub ty: Ty<'tcx>,
82 }
83 
84 #[derive(Diagnostic)]
85 #[diag(ty_utils_multiple_array_fields_simd_type)]
86 pub struct MultipleArrayFieldsSimdType<'tcx> {
87     pub ty: Ty<'tcx>,
88 }
89 
90 #[derive(Diagnostic)]
91 #[diag(ty_utils_oversized_simd_type)]
92 pub struct OversizedSimdType<'tcx> {
93     pub ty: Ty<'tcx>,
94     pub max_lanes: u64,
95 }
96 
97 #[derive(Diagnostic)]
98 #[diag(ty_utils_non_primitive_simd_type)]
99 pub struct NonPrimitiveSimdType<'tcx> {
100     pub ty: Ty<'tcx>,
101     pub e_ty: Ty<'tcx>,
102 }
103 
104 #[derive(Diagnostic)]
105 #[diag(ty_utils_impl_trait_duplicate_arg)]
106 pub struct DuplicateArg<'tcx> {
107     pub arg: GenericArg<'tcx>,
108     #[primary_span]
109     #[label]
110     pub span: Span,
111     #[note]
112     pub opaque_span: Span,
113 }
114 
115 #[derive(Diagnostic)]
116 #[diag(ty_utils_impl_trait_not_param, code = "E0792")]
117 pub struct NotParam<'tcx> {
118     pub arg: GenericArg<'tcx>,
119     #[primary_span]
120     #[label]
121     pub span: Span,
122     #[note]
123     pub opaque_span: Span,
124 }
125