1use std::path::Path;
2use std::{fmt, io};
3
4use rustc_errors::codes::*;
5use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage};
6use rustc_macros::{Diagnostic, Subdiagnostic};
7use rustc_span::{Span, Symbol};
8
9use crate::ty::{Instance, Ty};
10
11#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
DropCheckOverflow<'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 {
DropCheckOverflow {
span: __binding_0, ty: __binding_1, overflow_ty: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_drop_check_overflow);
diag.code(E0320);
diag.note(crate::fluent_generated::_subdiag::note);
;
diag.arg("ty", __binding_1);
diag.arg("overflow_ty", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
12#[diag(middle_drop_check_overflow, code = E0320)]
13#[note]
14pub(crate) struct DropCheckOverflow<'tcx> {
15 #[primary_span]
16 pub span: Span,
17 pub ty: Ty<'tcx>,
18 pub overflow_ty: Ty<'tcx>,
19}
20
21#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
FailedWritingFile<'a> 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 {
FailedWritingFile { path: __binding_0, error: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_failed_writing_file);
;
diag.arg("path", __binding_0);
diag.arg("error", __binding_1);
diag
}
}
}
}
};Diagnostic)]
22#[diag(middle_failed_writing_file)]
23pub(crate) struct FailedWritingFile<'a> {
24 pub path: &'a Path,
25 pub error: io::Error,
26}
27
28#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
OpaqueHiddenTypeMismatch<'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 {
OpaqueHiddenTypeMismatch {
self_ty: __binding_0,
other_ty: __binding_1,
other_span: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_opaque_hidden_type_mismatch);
;
diag.arg("self_ty", __binding_0);
diag.arg("other_ty", __binding_1);
diag.span(__binding_2);
diag.span_label(__binding_2,
crate::fluent_generated::_subdiag::label);
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
29#[diag(middle_opaque_hidden_type_mismatch)]
30pub(crate) struct OpaqueHiddenTypeMismatch<'tcx> {
31 pub self_ty: Ty<'tcx>,
32 pub other_ty: Ty<'tcx>,
33 #[primary_span]
34 #[label]
35 pub other_span: Span,
36 #[subdiagnostic]
37 pub sub: TypeMismatchReason,
38}
39
40#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedUnion 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 {
UnsupportedUnion { ty_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_unsupported_union);
;
diag.arg("ty_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
41#[diag(middle_unsupported_union)]
42pub struct UnsupportedUnion {
43 pub ty_name: String,
44}
45
46#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
AutodiffUnsafeInnerConstRef<'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 {
AutodiffUnsafeInnerConstRef {
span: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_autodiff_unsafe_inner_const_ref);
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
48#[diag(middle_autodiff_unsafe_inner_const_ref)]
49pub struct AutodiffUnsafeInnerConstRef<'tcx> {
50 #[primary_span]
51 pub span: Span,
52 pub ty: Ty<'tcx>,
53}
54
55#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TypeMismatchReason {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TypeMismatchReason::ConflictType { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::middle_conflict_types);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
TypeMismatchReason::PreviousUse { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::middle_previous_use_here);
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
56pub enum TypeMismatchReason {
57 #[label(middle_conflict_types)]
58 ConflictType {
59 #[primary_span]
60 span: Span,
61 },
62 #[note(middle_previous_use_here)]
63 PreviousUse {
64 #[primary_span]
65 span: Span,
66 },
67}
68
69#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
RecursionLimitReached<'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 {
RecursionLimitReached {
span: __binding_0,
ty: __binding_1,
suggested_limit: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_recursion_limit_reached);
diag.help(crate::fluent_generated::_subdiag::help);
;
diag.arg("ty", __binding_1);
diag.arg("suggested_limit", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
70#[diag(middle_recursion_limit_reached)]
71#[help]
72pub(crate) struct RecursionLimitReached<'tcx> {
73 #[primary_span]
74 pub span: Span,
75 pub ty: Ty<'tcx>,
76 pub suggested_limit: rustc_hir::limit::Limit,
77}
78
79#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstEvalNonIntError 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 {
ConstEvalNonIntError { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_const_eval_non_int);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
80#[diag(middle_const_eval_non_int)]
81pub(crate) struct ConstEvalNonIntError {
82 #[primary_span]
83 pub span: Span,
84}
85
86#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StrictCoherenceNeedsNegativeCoherence 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 {
StrictCoherenceNeedsNegativeCoherence {
span: __binding_0, attr_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_strict_coherence_needs_negative_coherence);
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
crate::fluent_generated::_subdiag::label);
}
diag
}
}
}
}
};Diagnostic)]
87#[diag(middle_strict_coherence_needs_negative_coherence)]
88pub(crate) struct StrictCoherenceNeedsNegativeCoherence {
89 #[primary_span]
90 pub span: Span,
91 #[label]
92 pub attr_span: Option<Span>,
93}
94
95#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RequiresLangItem 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 {
RequiresLangItem { span: __binding_0, name: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_requires_lang_item);
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
96#[diag(middle_requires_lang_item)]
97pub(crate) struct RequiresLangItem {
98 #[primary_span]
99 pub span: Span,
100 pub name: Symbol,
101}
102
103#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstNotUsedTraitAlias 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 {
ConstNotUsedTraitAlias { ct: __binding_0, span: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_const_not_used_in_type_alias);
;
diag.arg("ct", __binding_0);
diag.span(__binding_1);
diag
}
}
}
}
};Diagnostic)]
104#[diag(middle_const_not_used_in_type_alias)]
105pub(super) struct ConstNotUsedTraitAlias {
106 pub ct: String,
107 #[primary_span]
108 pub span: Span,
109}
110
111pub struct CustomSubdiagnostic<'a> {
112 pub msg: fn() -> DiagMessage,
113 pub add_args: Box<dyn FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>,
114}
115
116impl<'a> CustomSubdiagnostic<'a> {
117 pub fn label(x: fn() -> DiagMessage) -> Self {
118 Self::label_and_then(x, |_| {})
119 }
120 pub fn label_and_then<F: FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>(
121 msg: fn() -> DiagMessage,
122 f: F,
123 ) -> Self {
124 Self { msg, add_args: Box::new(move |x| f(x)) }
125 }
126}
127
128impl fmt::Debug for CustomSubdiagnostic<'_> {
129 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
130 f.debug_struct("CustomSubdiagnostic").finish_non_exhaustive()
131 }
132}
133
134#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
LayoutError<'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 {
LayoutError::Unknown { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_unknown);
;
diag.arg("ty", __binding_0);
diag
}
LayoutError::TooGeneric { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_too_generic);
;
diag.arg("ty", __binding_0);
diag
}
LayoutError::Overflow { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_size_overflow);
;
diag.arg("ty", __binding_0);
diag
}
LayoutError::SimdTooManyLanes {
ty: __binding_0, max_lanes: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_simd_too_many);
;
diag.arg("ty", __binding_0);
diag.arg("max_lanes", __binding_1);
diag
}
LayoutError::SimdZeroLength { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_simd_zero_length);
;
diag.arg("ty", __binding_0);
diag
}
LayoutError::NormalizationFailure {
ty: __binding_0, failure_ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_normalization_failure);
;
diag.arg("ty", __binding_0);
diag.arg("failure_ty", __binding_1);
diag
}
LayoutError::Cycle => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_cycle);
;
diag
}
LayoutError::ReferencesError => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_layout_references_error);
;
diag
}
}
}
}
};Diagnostic)]
135pub enum LayoutError<'tcx> {
136 #[diag(middle_layout_unknown)]
137 Unknown { ty: Ty<'tcx> },
138
139 #[diag(middle_layout_too_generic)]
140 TooGeneric { ty: Ty<'tcx> },
141
142 #[diag(middle_layout_size_overflow)]
143 Overflow { ty: Ty<'tcx> },
144
145 #[diag(middle_layout_simd_too_many)]
146 SimdTooManyLanes { ty: Ty<'tcx>, max_lanes: u64 },
147
148 #[diag(middle_layout_simd_zero_length)]
149 SimdZeroLength { ty: Ty<'tcx> },
150
151 #[diag(middle_layout_normalization_failure)]
152 NormalizationFailure { ty: Ty<'tcx>, failure_ty: String },
153
154 #[diag(middle_layout_cycle)]
155 Cycle,
156
157 #[diag(middle_layout_references_error)]
158 ReferencesError,
159}
160
161#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ErroneousConstant 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 {
ErroneousConstant { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_erroneous_constant);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
162#[diag(middle_erroneous_constant)]
163pub(crate) struct ErroneousConstant {
164 #[primary_span]
165 pub span: Span,
166}
167
168#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
TypeLengthLimit<'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 {
TypeLengthLimit {
span: __binding_0,
instance: __binding_1,
type_length: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_type_length_limit);
diag.help(crate::fluent_generated::middle_consider_type_length_limit);
;
diag.arg("instance", __binding_1);
diag.arg("type_length", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
169#[diag(middle_type_length_limit)]
170#[help(middle_consider_type_length_limit)]
171pub(crate) struct TypeLengthLimit<'tcx> {
172 #[primary_span]
173 pub span: Span,
174 pub instance: Instance<'tcx>,
175 pub type_length: usize,
176}
177
178#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MaxNumNodesInValtree 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 {
MaxNumNodesInValtree {
span: __binding_0, global_const_id: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_max_num_nodes_in_valtree);
;
diag.arg("global_const_id", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
179#[diag(middle_max_num_nodes_in_valtree)]
180pub(crate) struct MaxNumNodesInValtree {
181 #[primary_span]
182 pub span: Span,
183 pub global_const_id: String,
184}
185
186#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidConstInValtree 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 {
InvalidConstInValtree {
span: __binding_0, global_const_id: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::middle_invalid_const_in_valtree);
diag.note(crate::fluent_generated::_subdiag::note);
;
diag.arg("global_const_id", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
187#[diag(middle_invalid_const_in_valtree)]
188#[note]
189pub(crate) struct InvalidConstInValtree {
190 #[primary_span]
191 pub span: Span,
192 pub global_const_id: String,
193}