1use std::io;
2use std::path::Path;
3
4use rustc_errors::codes::*;
5use rustc_macros::{Diagnostic, Subdiagnostic};
6use rustc_span::{Span, Symbol};
7
8use crate::ty::{Instance, Ty};
9
10#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overflow while adding drop-check rules for `{$ty}`")));
diag.code(E0320);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overflowed on `{$overflow_ty}`")));
;
diag.arg("ty", __binding_1);
diag.arg("overflow_ty", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
11#[diag("overflow while adding drop-check rules for `{$ty}`", code = E0320)]
12#[note("overflowed on `{$overflow_ty}`")]
13pub(crate) struct DropCheckOverflow<'tcx> {
14 #[primary_span]
15 pub span: Span,
16 pub ty: Ty<'tcx>,
17 pub overflow_ty: Ty<'tcx>,
18}
19
20#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to write file {$path}: {$error}\"")));
;
diag.arg("path", __binding_0);
diag.arg("error", __binding_1);
diag
}
}
}
}
};Diagnostic)]
21#[diag("failed to write file {$path}: {$error}\"")]
22pub(crate) struct FailedWritingFile<'a> {
23 pub path: &'a Path,
24 pub error: io::Error,
25}
26
27#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("concrete type differs from previous defining opaque type use")));
;
diag.arg("self_ty", __binding_0);
diag.arg("other_ty", __binding_1);
diag.span(__binding_2);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{$self_ty}`, got `{$other_ty}`")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
28#[diag("concrete type differs from previous defining opaque type use")]
29pub(crate) struct OpaqueHiddenTypeMismatch<'tcx> {
30 pub self_ty: Ty<'tcx>,
31 pub other_ty: Ty<'tcx>,
32 #[primary_span]
33 #[label("expected `{$self_ty}`, got `{$other_ty}`")]
34 pub other_span: Span,
35 #[subdiagnostic]
36 pub sub: TypeMismatchReason,
37}
38
39#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("we don't support unions yet: '{$ty_name}'")));
;
diag.arg("ty_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
40#[diag("we don't support unions yet: '{$ty_name}'")]
41pub struct UnsupportedUnion {
42 pub ty_name: String,
43}
44
45#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reading from a `Duplicated` const {$ty} is unsafe")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
47#[diag("reading from a `Duplicated` const {$ty} is unsafe")]
48pub struct AutodiffUnsafeInnerConstRef<'tcx> {
49 #[primary_span]
50 pub span: Span,
51 pub ty: Ty<'tcx>,
52}
53
54#[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 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression supplies two conflicting concrete types for the same opaque type")),
&sub_args);
diag.span_label(__binding_0, __message);
}
TypeMismatchReason::PreviousUse { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous use here")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
55pub enum TypeMismatchReason {
56 #[label("this expression supplies two conflicting concrete types for the same opaque type")]
57 ConflictType {
58 #[primary_span]
59 span: Span,
60 },
61 #[note("previous use here")]
62 PreviousUse {
63 #[primary_span]
64 span: Span,
65 },
66}
67
68#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reached the recursion limit finding the struct tail for `{$ty}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]`")));
;
diag.arg("ty", __binding_1);
diag.arg("suggested_limit", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
69#[diag("reached the recursion limit finding the struct tail for `{$ty}`")]
70#[help(
71 "consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]`"
72)]
73pub(crate) struct RecursionLimitReached<'tcx> {
74 #[primary_span]
75 pub span: Span,
76 pub ty: Ty<'tcx>,
77 pub suggested_limit: rustc_hir::limit::Limit,
78}
79
80#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant evaluation of enum discriminant resulted in non-integer")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
81#[diag("constant evaluation of enum discriminant resulted in non-integer")]
82pub(crate) struct ConstEvalNonIntError {
83 #[primary_span]
84 pub span: Span,
85}
86
87#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("due to this attribute")));
diag
}
}
}
}
};Diagnostic)]
88#[diag(
89 "to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled"
90)]
91pub(crate) struct StrictCoherenceNeedsNegativeCoherence {
92 #[primary_span]
93 pub span: Span,
94 #[label("due to this attribute")]
95 pub attr_span: Span,
96}
97
98#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("requires `{$name}` lang_item")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
99#[diag("requires `{$name}` lang_item")]
100pub(crate) struct RequiresLangItem {
101 #[primary_span]
102 pub span: Span,
103 pub name: Symbol,
104}
105
106#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias")));
;
diag.arg("ct", __binding_0);
diag.span(__binding_1);
diag
}
}
}
}
};Diagnostic)]
107#[diag(
108 "const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias"
109)]
110pub(super) struct ConstNotUsedTraitAlias {
111 pub ct: String,
112 #[primary_span]
113 pub span: Span,
114}
115
116#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("erroneous constant encountered")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
117#[diag("erroneous constant encountered")]
118pub(crate) struct ErroneousConstant {
119 #[primary_span]
120 pub span: Span,
121}
122
123#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reached the type-length limit while instantiating `{$instance}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a `#![type_length_limit=\"{$type_length}\"]` attribute to your crate")));
;
diag.arg("instance", __binding_1);
diag.arg("type_length", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
124#[diag("reached the type-length limit while instantiating `{$instance}`")]
125#[help("consider adding a `#![type_length_limit=\"{$type_length}\"]` attribute to your crate")]
126pub(crate) struct TypeLengthLimit<'tcx> {
127 #[primary_span]
128 pub span: Span,
129 pub instance: Instance<'tcx>,
130 pub type_length: usize,
131}
132
133#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("maximum number of nodes exceeded in constant {$global_const_id}")));
;
diag.arg("global_const_id", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
134#[diag("maximum number of nodes exceeded in constant {$global_const_id}")]
135pub(crate) struct MaxNumNodesInValtree {
136 #[primary_span]
137 pub span: Span,
138 pub global_const_id: String,
139}
140
141#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant {$global_const_id} cannot be used as pattern")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constants that reference mutable or external memory cannot be used as patterns")));
;
diag.arg("global_const_id", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
142#[diag("constant {$global_const_id} cannot be used as pattern")]
143#[note("constants that reference mutable or external memory cannot be used as patterns")]
144pub(crate) struct InvalidConstInValtree {
145 #[primary_span]
146 pub span: Span,
147 pub global_const_id: String,
148}
149
150#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for Reentrant
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 {
Reentrant => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("internal compiler error: reentrant incremental verify failure, suppressing message")));
;
diag
}
}
}
}
};Diagnostic)]
151#[diag("internal compiler error: reentrant incremental verify failure, suppressing message")]
152pub(crate) struct Reentrant;
153
154#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncrementCompilation 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 {
IncrementCompilation {
run_cmd: __binding_0, dep_node: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("internal compiler error: encountered incremental compilation error with {$dep_node}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("please follow the instructions below to create a bug report with the provided information")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for incremental compilation bugs, having a reproduction is vital")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an ideal reproduction consists of the code before and some patch that then triggers the bug when applied and compiled again")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("as a workaround, you can run {$run_cmd} to allow your project to compile")));
;
diag.arg("run_cmd", __binding_0);
diag.arg("dep_node", __binding_1);
diag
}
}
}
}
};Diagnostic)]
155#[diag("internal compiler error: encountered incremental compilation error with {$dep_node}")]
156#[note("please follow the instructions below to create a bug report with the provided information")]
157#[note("for incremental compilation bugs, having a reproduction is vital")]
158#[note(
159 "an ideal reproduction consists of the code before and some patch that then triggers the bug when applied and compiled again"
160)]
161#[note("as a workaround, you can run {$run_cmd} to allow your project to compile")]
162pub(crate) struct IncrementCompilation {
163 pub run_cmd: String,
164 pub dep_node: String,
165}