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(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            NeedsDropOverflow<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NeedsDropOverflow { query_ty: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::ty_utils_needs_drop_overflow);
                        ;
                        diag.arg("query_ty", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
9#[diag(ty_utils_needs_drop_overflow)]
10pub(crate) struct NeedsDropOverflow<'tcx> {
11    pub query_ty: Ty<'tcx>,
12}
13
14#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            GenericConstantTooComplex where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    GenericConstantTooComplex {
                        span: __binding_0,
                        maybe_supported: __binding_1,
                        sub: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::ty_utils_generic_constant_too_complex);
                        diag.help(crate::fluent_generated::_subdiag::help);
                        ;
                        diag.span(__binding_0);
                        if __binding_1 {
                            diag.note(crate::fluent_generated::ty_utils_maybe_supported);
                        }
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };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(const _: () =
    {
        impl rustc_errors::Subdiagnostic for GenericConstantTooComplexSub {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    GenericConstantTooComplexSub::BorrowNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_borrow_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::AddressAndDerefNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_address_and_deref_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::ArrayNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_array_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::BlockNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_block_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::NeverToAnyNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_never_to_any_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::TupleNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_tuple_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::IndexNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_index_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::FieldNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_field_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::ConstBlockNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_const_block_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::AdtNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_adt_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::PointerNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_pointer_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::YieldNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_yield_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::LoopNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_loop_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::BoxNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_box_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::BinaryNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_binary_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::ByUseNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_by_use_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::LogicalOpNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_logical_op_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::AssignNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_assign_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::ClosureAndReturnNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_closure_and_return_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::ControlFlowNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_control_flow_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::InlineAsmNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_inline_asm_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                    GenericConstantTooComplexSub::OperationNotSupported(__binding_0)
                        => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::ty_utils_operation_not_supported);
                        diag.span_label(__binding_0, __message);
                        diag.restore_args();
                    }
                }
            }
        }
    };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(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnexpectedFnPtrAssociatedItem where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnexpectedFnPtrAssociatedItem { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::ty_utils_unexpected_fnptr_associated_item);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
75#[diag(ty_utils_unexpected_fnptr_associated_item)]
76pub(crate) struct UnexpectedFnPtrAssociatedItem {
77    #[primary_span]
78    pub span: Span,
79}
80
81#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            NonPrimitiveSimdType<'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NonPrimitiveSimdType { ty: __binding_0, e_ty: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::ty_utils_non_primitive_simd_type);
                        ;
                        diag.arg("ty", __binding_0);
                        diag.arg("e_ty", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
82#[diag(ty_utils_non_primitive_simd_type)]
83pub(crate) struct NonPrimitiveSimdType<'tcx> {
84    pub ty: Ty<'tcx>,
85    pub e_ty: Ty<'tcx>,
86}
87
88#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            DuplicateArg<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DuplicateArg {
                        arg: __binding_0,
                        span: __binding_1,
                        opaque_span: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::ty_utils_impl_trait_duplicate_arg);
                        ;
                        diag.arg("arg", __binding_0);
                        diag.span(__binding_1);
                        diag.span_label(__binding_1,
                            crate::fluent_generated::_subdiag::label);
                        diag.span_note(__binding_2,
                            crate::fluent_generated::_subdiag::note);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
89#[diag(ty_utils_impl_trait_duplicate_arg)]
90pub(crate) struct DuplicateArg<'tcx> {
91    pub arg: GenericArg<'tcx>,
92    #[primary_span]
93    #[label]
94    pub span: Span,
95    #[note]
96    pub opaque_span: Span,
97}
98
99#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            NotParam<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NotParam {
                        arg: __binding_0,
                        span: __binding_1,
                        opaque_span: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::ty_utils_impl_trait_not_param);
                        diag.code(E0792);
                        ;
                        diag.arg("arg", __binding_0);
                        diag.span(__binding_1);
                        diag.span_label(__binding_1,
                            crate::fluent_generated::_subdiag::label);
                        diag.span_note(__binding_2,
                            crate::fluent_generated::_subdiag::note);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
100#[diag(ty_utils_impl_trait_not_param, code = E0792)]
101pub(crate) struct NotParam<'tcx> {
102    pub arg: GenericArg<'tcx>,
103    #[primary_span]
104    #[label]
105    pub span: Span,
106    #[note]
107    pub opaque_span: Span,
108}