rustc_ty_utils/
errors.rs

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