1use rustc_abi::ExternAbi;
4use rustc_errors::codes::*;
5use rustc_errors::{
6 Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, Level, MultiSpan, listify, msg,
7};
8use rustc_macros::{Diagnostic, Subdiagnostic};
9use rustc_middle::ty::{self, Ty};
10use rustc_span::{Ident, Span, Symbol};
11use rustc_structures::Limit;
12pub(crate) mod wrong_number_of_generic_args;
13
14mod precise_captures;
15pub(crate) use precise_captures::*;
16
17pub(crate) mod remove_or_use_generic;
18
19#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ComplexConstArg {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ComplexConstArg { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("complex const arguments must be placed inside of a `const` block")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
20#[diag("complex const arguments must be placed inside of a `const` block")]
21pub(crate) struct ComplexConstArg {
22 #[primary_span]
23 pub span: Span,
24}
25
26#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
AmbiguousAssocItem<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AmbiguousAssocItem {
span: __binding_0,
assoc_kind: __binding_1,
assoc_ident: __binding_2,
qself: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous associated {$assoc_kind} `{$assoc_ident}` in bounds of `{$qself}`")));
;
diag.arg("assoc_kind", __binding_1);
diag.arg("assoc_ident", __binding_2);
diag.arg("qself", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous associated {$assoc_kind} `{$assoc_ident}`")));
diag
}
}
}
}
};Diagnostic)]
27#[diag("ambiguous associated {$assoc_kind} `{$assoc_ident}` in bounds of `{$qself}`")]
28pub(crate) struct AmbiguousAssocItem<'a> {
29 #[primary_span]
30 #[label("ambiguous associated {$assoc_kind} `{$assoc_ident}`")]
31 pub span: Span,
32 pub assoc_kind: &'static str,
33 pub assoc_ident: Ident,
34 pub qself: &'a str,
35}
36
37#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AssocKindMismatch {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AssocKindMismatch {
span: __binding_0,
item_span: __binding_1,
enclosing_span: __binding_2,
expected: __binding_3,
got: __binding_4,
expected_because_label: __binding_5,
assoc_kind: __binding_6,
def_span: __binding_7,
bound_on_assoc_const_label: __binding_8,
wrap_in_braces_sugg: __binding_9 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected {$expected}, found {$got}")));
;
diag.arg("expected", __binding_3);
diag.arg("got", __binding_4);
diag.arg("assoc_kind", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected {$got}")));
diag.span_context(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.span_context(__binding_2);
}
if let Some(__binding_5) = __binding_5 {
diag.span_label(__binding_5,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a {$expected} because of this associated {$expected}")));
}
diag.span_note(__binding_7,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the associated {$assoc_kind} is defined here")));
if let Some(__binding_8) = __binding_8 {
diag.span_label(__binding_8,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds are not allowed on associated constants")));
}
if let Some(__binding_9) = __binding_9 {
diag.subdiagnostic(__binding_9);
}
diag
}
}
}
}
};Diagnostic)]
38#[diag("expected {$expected}, found {$got}")]
39pub(crate) struct AssocKindMismatch {
40 #[primary_span]
41 #[label("unexpected {$got}")]
42 pub span: Span,
43 #[context]
44 pub item_span: Span,
45 #[context]
46 pub enclosing_span: Option<Span>,
47 pub expected: &'static str,
48 pub got: &'static str,
49 #[label("expected a {$expected} because of this associated {$expected}")]
50 pub expected_because_label: Option<Span>,
51 pub assoc_kind: &'static str,
52 #[note("the associated {$assoc_kind} is defined here")]
53 pub def_span: MultiSpan,
54 #[label("bounds are not allowed on associated constants")]
55 pub bound_on_assoc_const_label: Option<Span>,
56 #[subdiagnostic]
57 pub wrap_in_braces_sugg: Option<AssocKindMismatchWrapInBracesSugg>,
58}
59
60#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AssocKindMismatchWrapInBracesSugg
{
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AssocKindMismatchWrapInBracesSugg {
lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_0 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ "))
});
let __code_1 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_0, __code_0));
suggestions.push((__binding_1, __code_1));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding braces here")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
61#[multipart_suggestion("consider adding braces here", applicability = "maybe-incorrect")]
62pub(crate) struct AssocKindMismatchWrapInBracesSugg {
63 #[suggestion_part(code = "{{ ")]
64 pub lo: Span,
65 #[suggestion_part(code = " }}")]
66 pub hi: Span,
67}
68
69#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AssocItemIsPrivate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AssocItemIsPrivate {
span: __binding_0,
kind: __binding_1,
name: __binding_2,
defined_here_label: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind} `{$name}` is private")));
diag.code(E0624);
;
diag.arg("kind", __binding_1);
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("private {$kind}")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$kind} is defined here")));
diag
}
}
}
}
};Diagnostic)]
70#[diag("{$kind} `{$name}` is private", code = E0624)]
71pub(crate) struct AssocItemIsPrivate {
72 #[primary_span]
73 #[label("private {$kind}")]
74 pub span: Span,
75 pub kind: &'static str,
76 pub name: Ident,
77 #[label("the {$kind} is defined here")]
78 pub defined_here_label: Span,
79}
80
81#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
AssocItemNotFound<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AssocItemNotFound {
span: __binding_0,
assoc_ident: __binding_1,
assoc_kind: __binding_2,
qself: __binding_3,
label: __binding_4,
sugg: __binding_5,
within_macro_span: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated {$assoc_kind} `{$assoc_ident}` not found for `{$qself}`")));
diag.code(E0220);
;
diag.arg("assoc_ident", __binding_1);
diag.arg("assoc_kind", __binding_2);
diag.arg("qself", __binding_3);
diag.span(__binding_0);
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
if let Some(__binding_6) = __binding_6 {
diag.span_label(__binding_6,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("due to this macro variable")));
}
diag
}
}
}
}
};Diagnostic)]
82#[diag("associated {$assoc_kind} `{$assoc_ident}` not found for `{$qself}`", code = E0220)]
83pub(crate) struct AssocItemNotFound<'a> {
84 #[primary_span]
85 pub span: Span,
86 pub assoc_ident: Ident,
87 pub assoc_kind: &'static str,
88 pub qself: &'a str,
89 #[subdiagnostic]
90 pub label: Option<AssocItemNotFoundLabel<'a>>,
91 #[subdiagnostic]
92 pub sugg: Option<AssocItemNotFoundSugg<'a>>,
93 #[label("due to this macro variable")]
94 pub within_macro_span: Option<Span>,
95}
96
97#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for AssocItemNotFoundLabel<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AssocItemNotFoundLabel::NotFound {
span: __binding_0,
assoc_ident: __binding_1,
assoc_kind: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("assoc_ident".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("assoc_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated {$assoc_kind} `{$assoc_ident}` not found")),
&sub_args);
diag.span_label(__binding_0, __message);
}
AssocItemNotFoundLabel::FoundInOtherTrait {
span: __binding_0,
assoc_kind: __binding_1,
trait_name: __binding_2,
suggested_name: __binding_3,
identically_named: __binding_4 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("assoc_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("trait_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("suggested_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("identically_named".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is {$identically_named ->\n [true] an\n *[false] a similarly named\n } associated {$assoc_kind} `{$suggested_name}` in the trait `{$trait_name}`")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
98pub(crate) enum AssocItemNotFoundLabel<'a> {
99 #[label("associated {$assoc_kind} `{$assoc_ident}` not found")]
100 NotFound {
101 #[primary_span]
102 span: Span,
103 assoc_ident: Ident,
104 assoc_kind: &'static str,
105 },
106 #[label(
107 "there is {$identically_named ->
108 [true] an
109 *[false] a similarly named
110 } associated {$assoc_kind} `{$suggested_name}` in the trait `{$trait_name}`"
111 )]
112 FoundInOtherTrait {
113 #[primary_span]
114 span: Span,
115 assoc_kind: &'static str,
116 trait_name: &'a str,
117 suggested_name: Symbol,
118 identically_named: bool,
119 },
120}
121
122#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for AssocItemNotFoundSugg<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AssocItemNotFoundSugg::Similar {
span: __binding_0,
assoc_kind: __binding_1,
suggested_name: __binding_2 } => {
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("assoc_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated {$assoc_kind} with a similar name")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
AssocItemNotFoundSugg::SimilarInOtherTrait {
span: __binding_0,
trait_name: __binding_1,
assoc_kind: __binding_2,
suggested_name: __binding_3 } => {
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("trait_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("assoc_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("suggested_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("change the associated {$assoc_kind} name to use `{$suggested_name}` from `{$trait_name}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_3, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
AssocItemNotFoundSugg::SimilarInOtherTraitQPath {
lo: __binding_0,
mi: __binding_1,
hi: __binding_2,
trait_ref: __binding_3,
suggested_name: __binding_4,
identically_named: __binding_5,
assoc_kind: __binding_6,
applicability: __binding_7 } => {
let mut suggestions = Vec::new();
let __code_4 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_5 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" as {0}>", __binding_3))
});
let __code_6 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
});
suggestions.push((__binding_0, __code_4));
suggestions.push((__binding_1, __code_5));
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_6));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggested_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
sub_args.insert("identically_named".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_5,
&mut diag.long_ty_path));
sub_args.insert("assoc_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_6,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider fully qualifying{$identically_named ->\n [true] {\"\"}\n *[false] {\" \"}and renaming\n } the associated {$assoc_kind}")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
__binding_7, rustc_errors::SuggestionStyle::ShowAlways);
}
AssocItemNotFoundSugg::Other {
span: __binding_0,
qself: __binding_1,
assoc_kind: __binding_2,
suggested_name: __binding_3 } => {
let __code_7 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("qself".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("assoc_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("suggested_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$qself}` has the following associated {$assoc_kind}")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_7, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
123
124pub(crate) enum AssocItemNotFoundSugg<'a> {
125 #[suggestion(
126 "there is an associated {$assoc_kind} with a similar name",
127 code = "{suggested_name}",
128 applicability = "maybe-incorrect"
129 )]
130 Similar {
131 #[primary_span]
132 span: Span,
133 assoc_kind: &'static str,
134 suggested_name: Symbol,
135 },
136 #[suggestion(
137 "change the associated {$assoc_kind} name to use `{$suggested_name}` from `{$trait_name}`",
138 code = "{suggested_name}",
139 style = "verbose",
140 applicability = "maybe-incorrect"
141 )]
142 SimilarInOtherTrait {
143 #[primary_span]
144 span: Span,
145 trait_name: &'a str,
146 assoc_kind: &'static str,
147 suggested_name: Symbol,
148 },
149 #[multipart_suggestion(
150 "consider fully qualifying{$identically_named ->
151 [true] {\"\"}
152 *[false] {\" \"}and renaming
153 } the associated {$assoc_kind}",
154 style = "verbose"
155 )]
156 SimilarInOtherTraitQPath {
157 #[suggestion_part(code = "<")]
158 lo: Span,
159 #[suggestion_part(code = " as {trait_ref}>")]
160 mi: Span,
161 #[suggestion_part(code = "{suggested_name}")]
162 hi: Option<Span>,
163 trait_ref: String,
164 suggested_name: Symbol,
165 identically_named: bool,
166 assoc_kind: &'static str,
167 #[applicability]
168 applicability: Applicability,
169 },
170 #[suggestion(
171 "`{$qself}` has the following associated {$assoc_kind}",
172 code = "{suggested_name}",
173 applicability = "maybe-incorrect"
174 )]
175 Other {
176 #[primary_span]
177 span: Span,
178 qself: &'a str,
179 assoc_kind: &'static str,
180 suggested_name: Symbol,
181 },
182}
183
184#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
WrongNumberOfGenericArgumentsToIntrinsic<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
WrongNumberOfGenericArgumentsToIntrinsic {
span: __binding_0,
found: __binding_1,
expected: __binding_2,
descr: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}")));
diag.code(E0094);
;
diag.arg("found", __binding_1);
diag.arg("expected", __binding_2);
diag.arg("descr", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected {$expected} {$descr} {$expected ->\n [one] parameter\n *[other] parameters\n }")));
diag
}
}
}
}
};Diagnostic)]
185#[diag("intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}", code = E0094)]
186pub(crate) struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
187 #[primary_span]
188 #[label(
189 "expected {$expected} {$descr} {$expected ->
190 [one] parameter
191 *[other] parameters
192 }"
193 )]
194 pub span: Span,
195 pub found: usize,
196 pub expected: usize,
197 pub descr: &'a str,
198}
199
200#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnrecognizedIntrinsicFunction {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnrecognizedIntrinsicFunction {
span: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unrecognized intrinsic function: `{$name}`")));
diag.code(E0093);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you're adding an intrinsic, be sure to update `check_intrinsic_type`")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unrecognized intrinsic")));
diag
}
}
}
}
};Diagnostic)]
201#[diag("unrecognized intrinsic function: `{$name}`", code = E0093)]
202#[help("if you're adding an intrinsic, be sure to update `check_intrinsic_type`")]
203pub(crate) struct UnrecognizedIntrinsicFunction {
204 #[primary_span]
205 #[label("unrecognized intrinsic")]
206 pub span: Span,
207 pub name: Symbol,
208}
209
210#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
LifetimesOrBoundsMismatchOnTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LifetimesOrBoundsMismatchOnTrait {
span: __binding_0,
generics_span: __binding_1,
where_span: __binding_2,
bounds_span: __binding_3,
item_kind: __binding_4,
ident: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration")));
diag.code(E0195);
;
diag.arg("item_kind", __binding_4);
diag.arg("ident", __binding_5);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes do not match {$item_kind} in trait")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes in impl do not match this {$item_kind} in trait")));
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `where` clause might not match the one in the trait")));
}
for __binding_3 in __binding_3 {
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this bound might be missing in the impl")));
}
diag
}
}
}
}
};Diagnostic)]
211#[diag("lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration", code = E0195)]
212pub(crate) struct LifetimesOrBoundsMismatchOnTrait {
213 #[primary_span]
214 #[label("lifetimes do not match {$item_kind} in trait")]
215 pub span: Span,
216 #[label("lifetimes in impl do not match this {$item_kind} in trait")]
217 pub generics_span: Span,
218 #[label("this `where` clause might not match the one in the trait")]
219 pub where_span: Option<Span>,
220 #[label("this bound might be missing in the impl")]
221 pub bounds_span: Vec<Span>,
222 pub item_kind: &'static str,
223 pub ident: Ident,
224}
225
226#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for DropImplOnWrongItem
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DropImplOnWrongItem { span: __binding_0, trait_: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$trait_}` trait may only be implemented for local structs, enums, and unions")));
diag.code(E0120);
;
diag.arg("trait_", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("must be a struct, enum, or union in the current crate")));
diag
}
}
}
}
};Diagnostic)]
227#[diag("the `{$trait_}` trait may only be implemented for local structs, enums, and unions", code = E0120)]
228pub(crate) struct DropImplOnWrongItem {
229 #[primary_span]
230 #[label("must be a struct, enum, or union in the current crate")]
231 pub span: Span,
232 pub trait_: Symbol,
233}
234
235#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FieldAlreadyDeclared
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FieldAlreadyDeclared::NotNested {
field_name: __binding_0,
span: __binding_1,
prev_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` is already declared")));
diag.code(E0124);
;
diag.arg("field_name", __binding_0);
diag.span(__binding_1);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field already declared")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$field_name}` first declared here")));
diag
}
FieldAlreadyDeclared::CurrentNested {
field_name: __binding_0,
span: __binding_1,
nested_field_span: __binding_2,
help: __binding_3,
prev_span: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` is already declared")));
;
diag.arg("field_name", __binding_0);
diag.span(__binding_1);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` declared in this unnamed field")));
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` declared here")));
diag.subdiagnostic(__binding_3);
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$field_name}` first declared here")));
diag
}
FieldAlreadyDeclared::PreviousNested {
field_name: __binding_0,
span: __binding_1,
prev_span: __binding_2,
prev_nested_field_span: __binding_3,
prev_help: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` is already declared")));
;
diag.arg("field_name", __binding_0);
diag.span(__binding_1);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field already declared")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$field_name}` first declared here in this unnamed field")));
diag.span_note(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` first declared here")));
diag.subdiagnostic(__binding_4);
diag
}
FieldAlreadyDeclared::BothNested {
field_name: __binding_0,
span: __binding_1,
nested_field_span: __binding_2,
help: __binding_3,
prev_span: __binding_4,
prev_nested_field_span: __binding_5,
prev_help: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` is already declared")));
;
diag.arg("field_name", __binding_0);
diag.span(__binding_1);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` declared in this unnamed field")));
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` declared here")));
diag.subdiagnostic(__binding_3);
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$field_name}` first declared here in this unnamed field")));
diag.span_note(__binding_5,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field_name}` first declared here")));
diag.subdiagnostic(__binding_6);
diag
}
}
}
}
};Diagnostic)]
236pub(crate) enum FieldAlreadyDeclared {
237 #[diag("field `{$field_name}` is already declared", code = E0124)]
238 NotNested {
239 field_name: Ident,
240 #[primary_span]
241 #[label("field already declared")]
242 span: Span,
243 #[label("`{$field_name}` first declared here")]
244 prev_span: Span,
245 },
246 #[diag("field `{$field_name}` is already declared")]
247 CurrentNested {
248 field_name: Ident,
249 #[primary_span]
250 #[label("field `{$field_name}` declared in this unnamed field")]
251 span: Span,
252 #[note("field `{$field_name}` declared here")]
253 nested_field_span: Span,
254 #[subdiagnostic]
255 help: FieldAlreadyDeclaredNestedHelp,
256 #[label("`{$field_name}` first declared here")]
257 prev_span: Span,
258 },
259 #[diag("field `{$field_name}` is already declared")]
260 PreviousNested {
261 field_name: Ident,
262 #[primary_span]
263 #[label("field already declared")]
264 span: Span,
265 #[label("`{$field_name}` first declared here in this unnamed field")]
266 prev_span: Span,
267 #[note("field `{$field_name}` first declared here")]
268 prev_nested_field_span: Span,
269 #[subdiagnostic]
270 prev_help: FieldAlreadyDeclaredNestedHelp,
271 },
272 #[diag("field `{$field_name}` is already declared")]
273 BothNested {
274 field_name: Ident,
275 #[primary_span]
276 #[label("field `{$field_name}` declared in this unnamed field")]
277 span: Span,
278 #[note("field `{$field_name}` declared here")]
279 nested_field_span: Span,
280 #[subdiagnostic]
281 help: FieldAlreadyDeclaredNestedHelp,
282 #[label("`{$field_name}` first declared here in this unnamed field")]
283 prev_span: Span,
284 #[note("field `{$field_name}` first declared here")]
285 prev_nested_field_span: Span,
286 #[subdiagnostic]
287 prev_help: FieldAlreadyDeclaredNestedHelp,
288 },
289}
290
291#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FieldAlreadyDeclaredNestedHelp {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
FieldAlreadyDeclaredNestedHelp { 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("fields from the type of this unnamed field are considered fields of the outer type")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
292#[help("fields from the type of this unnamed field are considered fields of the outer type")]
293pub(crate) struct FieldAlreadyDeclaredNestedHelp {
294 #[primary_span]
295 pub span: Span,
296}
297
298#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
TraitImplOnTypeWithDtor {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TraitImplOnTypeWithDtor {
span: __binding_0,
impl_: __binding_1,
trait_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `{$trait_name}` cannot be implemented for this type; the type has a destructor")));
diag.code(E0184);
;
diag.arg("trait_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$trait_name}` not allowed on types with destructors")));
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("destructor declared here")));
diag
}
}
}
}
};Diagnostic)]
299#[diag("the trait `{$trait_name}` cannot be implemented for this type; the type has a destructor", code = E0184)]
300pub(crate) struct TraitImplOnTypeWithDtor {
301 #[primary_span]
302 #[label("`{$trait_name}` not allowed on types with destructors")]
303 pub span: Span,
304 #[note("destructor declared here")]
305 pub impl_: Span,
306 pub trait_name: Symbol,
307}
308
309#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CopyImplOnNonAdt {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CopyImplOnNonAdt { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `Copy` cannot be implemented for this type")));
diag.code(E0206);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type is not a structure or enumeration")));
diag
}
}
}
}
};Diagnostic)]
310#[diag("the trait `Copy` cannot be implemented for this type", code = E0206)]
311pub(crate) struct CopyImplOnNonAdt {
312 #[primary_span]
313 #[label("type is not a structure or enumeration")]
314 pub span: Span,
315}
316
317#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstParamTyImplOnUnsized {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstParamTyImplOnUnsized { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `ConstParamTy` may not be implemented for this type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type is not `Sized`")));
diag
}
}
}
}
};Diagnostic)]
318#[diag("the trait `ConstParamTy` may not be implemented for this type")]
319pub(crate) struct ConstParamTyImplOnUnsized {
320 #[primary_span]
321 #[label("type is not `Sized`")]
322 pub span: Span,
323}
324
325#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstParamTyImplOnNonAdt {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstParamTyImplOnNonAdt { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `ConstParamTy` may not be implemented for this type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type is not a structure or enumeration")));
diag
}
}
}
}
};Diagnostic)]
326#[diag("the trait `ConstParamTy` may not be implemented for this type")]
327pub(crate) struct ConstParamTyImplOnNonAdt {
328 #[primary_span]
329 #[label("type is not a structure or enumeration")]
330 pub span: Span,
331}
332
333#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstParamTyImplOnNonExhaustive {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstParamTyImplOnNonExhaustive {
defn_span: __binding_0, attr_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `ConstParamTy` may not be implemented for this type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non exhaustive const params are forbidden")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("caused by this attribute")));
diag
}
}
}
}
};Diagnostic)]
334#[diag("the trait `ConstParamTy` may not be implemented for this type")]
335pub(crate) struct ConstParamTyImplOnNonExhaustive {
336 #[primary_span]
337 #[label("non exhaustive const params are forbidden")]
338 pub defn_span: Span,
339 #[label("caused by this attribute")]
340 pub attr_span: Span,
341}
342
343#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstParamTyFieldVisMismatch {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstParamTyFieldVisMismatch { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `ConstParamTy` may not be implemented for this struct")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("struct fields are less visible than the struct")));
diag
}
}
}
}
};Diagnostic)]
344#[diag("the trait `ConstParamTy` may not be implemented for this struct")]
345pub(crate) struct ConstParamTyFieldVisMismatch {
346 #[primary_span]
347 #[label("struct fields are less visible than the struct")]
348 pub span: Span,
349}
350
351#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
TraitObjectDeclaredWithNoTraits {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TraitObjectDeclaredWithNoTraits {
span: __binding_0, trait_alias_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("at least one trait is required for an object type")));
diag.code(E0224);
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this alias does not contain a trait")));
}
diag
}
}
}
}
};Diagnostic)]
352#[diag("at least one trait is required for an object type", code = E0224)]
353pub(crate) struct TraitObjectDeclaredWithNoTraits {
354 #[primary_span]
355 pub span: Span,
356 #[label("this alias does not contain a trait")]
357 pub trait_alias_span: Option<Span>,
358}
359
360#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AmbiguousLifetimeBound {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AmbiguousLifetimeBound { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous lifetime bound, explicit lifetime bound required")));
diag.code(E0227);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
361#[diag("ambiguous lifetime bound, explicit lifetime bound required", code = E0227)]
362pub(crate) struct AmbiguousLifetimeBound {
363 #[primary_span]
364 pub span: Span,
365}
366
367#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AssocItemConstraintsNotAllowedHere {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AssocItemConstraintsNotAllowedHere {
span: __binding_0, fn_trait_expansion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated item constraints are not allowed here")));
diag.code(E0229);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated item constraint not allowed here")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
368#[diag("associated item constraints are not allowed here", code = E0229)]
369pub(crate) struct AssocItemConstraintsNotAllowedHere {
370 #[primary_span]
371 #[label("associated item constraint not allowed here")]
372 pub span: Span,
373
374 #[subdiagnostic]
375 pub fn_trait_expansion: Option<ParenthesizedFnTraitExpansion>,
376}
377
378#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
ParamInTyOfAssocConstBinding<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ParamInTyOfAssocConstBinding {
span: __binding_0,
assoc_const: __binding_1,
param_name: __binding_2,
param_def_kind: __binding_3,
param_category: __binding_4,
param_defined_here_label: __binding_5,
ty_note: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type of the associated constant `{$assoc_const}` must not depend on {$param_category ->\n [self] `Self`\n [synthetic] `impl Trait`\n *[normal] generic parameters\n }")));
;
diag.arg("assoc_const", __binding_1);
diag.arg("param_name", __binding_2);
diag.arg("param_def_kind", __binding_3);
diag.arg("param_category", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("its type must not depend on {$param_category ->\n [self] `Self`\n [synthetic] `impl Trait`\n *[normal] the {$param_def_kind} `{$param_name}`\n }")));
if let Some(__binding_5) = __binding_5 {
diag.span_label(__binding_5,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$param_category ->\n [synthetic] the `impl Trait` is specified here\n *[normal] the {$param_def_kind} `{$param_name}` is defined here\n }")));
}
if let Some(__binding_6) = __binding_6 {
diag.subdiagnostic(__binding_6);
}
diag
}
}
}
}
};Diagnostic)]
379#[diag(
380 "the type of the associated constant `{$assoc_const}` must not depend on {$param_category ->
381 [self] `Self`
382 [synthetic] `impl Trait`
383 *[normal] generic parameters
384 }"
385)]
386pub(crate) struct ParamInTyOfAssocConstBinding<'tcx> {
387 #[primary_span]
388 #[label(
389 "its type must not depend on {$param_category ->
390 [self] `Self`
391 [synthetic] `impl Trait`
392 *[normal] the {$param_def_kind} `{$param_name}`
393 }"
394 )]
395 pub span: Span,
396 pub assoc_const: Ident,
397 pub param_name: Symbol,
398 pub param_def_kind: &'static str,
399 pub param_category: &'static str,
400 #[label(
401 "{$param_category ->
402 [synthetic] the `impl Trait` is specified here
403 *[normal] the {$param_def_kind} `{$param_name}` is defined here
404 }"
405 )]
406 pub param_defined_here_label: Option<Span>,
407 #[subdiagnostic]
408 pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
409}
410
411#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for
TyOfAssocConstBindingNote<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
TyOfAssocConstBindingNote {
assoc_const: __binding_0, ty: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("assoc_const".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$assoc_const}` has type `{$ty}`")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
::core::clone::TrivialClone for TyOfAssocConstBindingNote<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
TyOfAssocConstBindingNote<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
*self
}
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::Copy for
TyOfAssocConstBindingNote<'tcx> {
}Copy)]
412#[note("`{$assoc_const}` has type `{$ty}`")]
413pub(crate) struct TyOfAssocConstBindingNote<'tcx> {
414 pub assoc_const: Ident,
415 pub ty: Ty<'tcx>,
416}
417
418#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
EscapingBoundVarInTyOfAssocConstBinding<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EscapingBoundVarInTyOfAssocConstBinding {
span: __binding_0,
assoc_const: __binding_1,
var_name: __binding_2,
var_def_kind: __binding_3,
var_defined_here_label: __binding_4,
ty_note: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type of the associated constant `{$assoc_const}` cannot capture late-bound generic parameters")));
;
diag.arg("assoc_const", __binding_1);
diag.arg("var_name", __binding_2);
diag.arg("var_def_kind", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("its type cannot capture the late-bound {$var_def_kind} `{$var_name}`")));
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the late-bound {$var_def_kind} `{$var_name}` is defined here")));
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag
}
}
}
}
};Diagnostic)]
419#[diag(
420 "the type of the associated constant `{$assoc_const}` cannot capture late-bound generic parameters"
421)]
422pub(crate) struct EscapingBoundVarInTyOfAssocConstBinding<'tcx> {
423 #[primary_span]
424 #[label("its type cannot capture the late-bound {$var_def_kind} `{$var_name}`")]
425 pub span: Span,
426 pub assoc_const: Ident,
427 pub var_name: Symbol,
428 pub var_def_kind: &'static str,
429 #[label("the late-bound {$var_def_kind} `{$var_name}` is defined here")]
430 pub var_defined_here_label: Span,
431 #[subdiagnostic]
432 pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
433}
434
435#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenthesizedFnTraitExpansion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ParenthesizedFnTraitExpansion {
span: __binding_0, expanded_type: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("expanded_type".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parenthesized trait syntax expands to `{$expanded_type}`")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
436#[help("parenthesized trait syntax expands to `{$expanded_type}`")]
437pub(crate) struct ParenthesizedFnTraitExpansion {
438 #[primary_span]
439 pub span: Span,
440
441 pub expanded_type: String,
442}
443
444#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ValueOfAssociatedStructAlreadySpecified {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ValueOfAssociatedStructAlreadySpecified {
span: __binding_0,
prev_span: __binding_1,
item_name: __binding_2,
def_path: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the value of the associated type `{$item_name}` in trait `{$def_path}` is already specified")));
diag.code(E0719);
;
diag.arg("item_name", __binding_2);
diag.arg("def_path", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("re-bound here")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$item_name}` bound here first")));
diag
}
}
}
}
};Diagnostic)]
445#[diag("the value of the associated type `{$item_name}` in trait `{$def_path}` is already specified", code = E0719)]
446pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
447 #[primary_span]
448 #[label("re-bound here")]
449 pub span: Span,
450 #[label("`{$item_name}` bound here first")]
451 pub prev_span: Span,
452 pub item_name: Ident,
453 pub def_path: String,
454}
455
456#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnconstrainedOpaqueType {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnconstrainedOpaqueType {
span: __binding_0, name: __binding_1, what: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unconstrained opaque type")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` must be used in combination with a concrete type within the same {$what}")));
;
diag.arg("name", __binding_1);
diag.arg("what", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
457#[diag("unconstrained opaque type")]
458#[note("`{$name}` must be used in combination with a concrete type within the same {$what}")]
459pub(crate) struct UnconstrainedOpaqueType {
460 #[primary_span]
461 pub span: Span,
462 pub name: Ident,
463 pub what: &'static str,
464}
465
466pub(crate) struct MissingGenericParams {
467 pub span: Span,
468 pub def_span: Span,
469 pub span_snippet: Option<String>,
470 pub missing_generic_params: Vec<(Symbol, ty::GenericParamDefKind)>,
471 pub empty_generic_args: bool,
472}
473
474impl<'a> Diagnostic<'a> for MissingGenericParams {
476 #[track_caller]
477 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> {
478 let mut err = Diag::new(
479 dcx,
480 level,
481 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$descr} {$parameterCount ->\n [one] parameter\n *[other] parameters\n } {$parameters} must be explicitly specified"))msg!(
482 "the {$descr} {$parameterCount ->
483 [one] parameter
484 *[other] parameters
485 } {$parameters} must be explicitly specified"
486 ),
487 );
488 err.span(self.span);
489 err.code(E0393);
490 err.span_label(
491 self.def_span,
492 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr} {$parameterCount ->\n [one] parameter\n *[other] parameters\n } {$parameters} must be specified for this"))msg!(
493 "{$descr} {$parameterCount ->
494 [one] parameter
495 *[other] parameters
496 } {$parameters} must be specified for this"
497 ),
498 );
499
500 enum Descr {
501 Generic,
502 Type,
503 Const,
504 }
505
506 let mut descr = None;
507 for (_, kind) in &self.missing_generic_params {
508 descr = match (&descr, kind) {
509 (None, ty::GenericParamDefKind::Type { .. }) => Some(Descr::Type),
510 (None, ty::GenericParamDefKind::Const { .. }) => Some(Descr::Const),
511 (Some(Descr::Type), ty::GenericParamDefKind::Const { .. })
512 | (Some(Descr::Const), ty::GenericParamDefKind::Type { .. }) => {
513 Some(Descr::Generic)
514 }
515 _ => continue,
516 }
517 }
518
519 err.arg(
520 "descr",
521 match descr.unwrap() {
522 Descr::Generic => "generic",
523 Descr::Type => "type",
524 Descr::Const => "const",
525 },
526 );
527 err.arg("parameterCount", self.missing_generic_params.len());
528 err.arg(
529 "parameters",
530 listify(&self.missing_generic_params, |(n, _)| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", n))
})format!("`{n}`")).unwrap(),
531 );
532
533 let mut suggested = false;
534 if let Some(snippet) = self.span_snippet
537 && self.empty_generic_args
538 {
539 if snippet.ends_with('>') {
540 } else {
544 err.span_suggestion_verbose(
547 self.span.shrink_to_hi(),
548 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly specify the {$descr} {$parameterCount ->\n [one] parameter\n *[other] parameters\n }"))msg!(
549 "explicitly specify the {$descr} {$parameterCount ->
550 [one] parameter
551 *[other] parameters
552 }"
553 ),
554 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>",
self.missing_generic_params.iter().map(|(n, _)|
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("/* {0} */", n))
})).collect::<Vec<_>>().join(", ")))
})format!(
555 "<{}>",
556 self.missing_generic_params
557 .iter()
558 .map(|(n, _)| format!("/* {n} */"))
559 .collect::<Vec<_>>()
560 .join(", ")
561 ),
562 Applicability::HasPlaceholders,
563 );
564 suggested = true;
565 }
566 }
567 if !suggested {
568 err.span_label(
569 self.span,
570 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing {$parameterCount ->\n [one] reference\n *[other] references\n } to {$parameters}"))msg!(
571 "missing {$parameterCount ->
572 [one] reference
573 *[other] references
574 } to {$parameters}"
575 ),
576 );
577 }
578
579 err.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("because the parameter {$parameterCount ->\n [one] default references\n *[other] defaults reference\n } `Self`, the {$parameterCount ->\n [one] parameter\n *[other] parameters\n } must be specified on the trait object type"))msg!(
580 "because the parameter {$parameterCount ->
581 [one] default references
582 *[other] defaults reference
583 } `Self`, the {$parameterCount ->
584 [one] parameter
585 *[other] parameters
586 } must be specified on the trait object type"
587 ));
588 err
589 }
590}
591
592#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ManualImplementation
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ManualImplementation {
span: __binding_0, trait_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("manual implementations of `{$trait_name}` are experimental")));
diag.code(E0183);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(unboxed_closures)]` to the crate attributes to enable")));
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("manual implementations of `{$trait_name}` are experimental")));
diag
}
}
}
}
};Diagnostic)]
593#[diag("manual implementations of `{$trait_name}` are experimental", code = E0183)]
594#[help("add `#![feature(unboxed_closures)]` to the crate attributes to enable")]
595pub(crate) struct ManualImplementation {
596 #[primary_span]
597 #[label("manual implementations of `{$trait_name}` are experimental")]
598 pub span: Span,
599 pub trait_name: String,
600}
601
602#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
GenericArgsOnOverriddenImpl {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
GenericArgsOnOverriddenImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not resolve generic parameters on overridden impl")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
603#[diag("could not resolve generic parameters on overridden impl")]
604pub(crate) struct GenericArgsOnOverriddenImpl {
605 #[primary_span]
606 pub span: Span,
607}
608
609#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstImplForNonConstTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstImplForNonConstTrait {
trait_ref_span: __binding_0,
trait_name: __binding_1,
suggestion: __binding_2,
suggestion_pre: __binding_3,
marking: __binding_4,
adding: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const `impl` for trait `{$trait_name}` which is not `const`")));
let __code_8 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
})].into_iter();
;
diag.arg("trait_name", __binding_1);
diag.arg("suggestion_pre", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this trait is not `const`")));
if let Some(__binding_2) = __binding_2 {
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations")),
__code_8, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("marking a trait with `const` ensures all default method bodies are `const`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("adding a non-const method body in the future would be a breaking change")));
diag
}
}
}
}
};Diagnostic)]
610#[diag("const `impl` for trait `{$trait_name}` which is not `const`")]
611pub(crate) struct ConstImplForNonConstTrait {
612 #[primary_span]
613 #[label("this trait is not `const`")]
614 pub trait_ref_span: Span,
615 pub trait_name: String,
616 #[suggestion(
617 "{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations",
618 applicability = "machine-applicable",
619 code = "const ",
620 style = "verbose"
621 )]
622 pub suggestion: Option<Span>,
623 pub suggestion_pre: &'static str,
624 #[note("marking a trait with `const` ensures all default method bodies are `const`")]
625 pub marking: (),
626 #[note("adding a non-const method body in the future would be a breaking change")]
627 pub adding: (),
628}
629
630#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstBoundForNonConstTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstBoundForNonConstTrait {
span: __binding_0,
modifier: __binding_1,
def_span: __binding_2,
suggestion: __binding_3,
suggestion_pre: __binding_4,
trait_name: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$modifier}` can only be applied to `const` traits")));
let __code_9 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
})].into_iter();
;
diag.arg("modifier", __binding_1);
diag.arg("suggestion_pre", __binding_4);
diag.arg("trait_name", __binding_5);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't be applied to `{$trait_name}`")));
if let Some(__binding_2) = __binding_2 {
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$trait_name}` can't be used with `{$modifier}` because it isn't `const`")));
}
if let Some(__binding_3) = __binding_3 {
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations")),
__code_9, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
631#[diag("`{$modifier}` can only be applied to `const` traits")]
632pub(crate) struct ConstBoundForNonConstTrait {
633 #[primary_span]
634 #[label("can't be applied to `{$trait_name}`")]
635 pub span: Span,
636 pub modifier: &'static str,
637 #[note("`{$trait_name}` can't be used with `{$modifier}` because it isn't `const`")]
638 pub def_span: Option<Span>,
639 #[suggestion(
640 "{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations",
641 applicability = "machine-applicable",
642 code = "const ",
643 style = "verbose"
644 )]
645 pub suggestion: Option<Span>,
646 pub suggestion_pre: &'static str,
647 pub trait_name: String,
648}
649
650#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for SelfInImplSelf {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SelfInImplSelf { span: __binding_0, note: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Self` is not valid in the self type of an impl block")));
;
diag.span(__binding_0);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace `Self` with a different type")));
diag
}
}
}
}
};Diagnostic)]
651#[diag("`Self` is not valid in the self type of an impl block")]
652pub(crate) struct SelfInImplSelf {
653 #[primary_span]
654 pub span: MultiSpan,
655 #[note("replace `Self` with a different type")]
656 pub note: (),
657}
658
659#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for LinkageType {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LinkageType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid type for variable with `#[linkage]` attribute")));
diag.code(E0791);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
660#[diag("invalid type for variable with `#[linkage]` attribute", code = E0791)]
661pub(crate) struct LinkageType {
662 #[primary_span]
663 pub span: Span,
664}
665
666#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
AutoDerefReachedRecursionLimit<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AutoDerefReachedRecursionLimit {
span: __binding_0,
ty: __binding_1,
suggested_limit: __binding_2,
crate_name: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reached the recursion limit while auto-dereferencing `{$ty}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)")));
diag.code(E0055);
;
diag.arg("ty", __binding_1);
diag.arg("suggested_limit", __binding_2);
diag.arg("crate_name", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("deref recursion limit reached")));
diag
}
}
}
}
};Diagnostic)]
667#[help(
668 "consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
669)]
670#[diag("reached the recursion limit while auto-dereferencing `{$ty}`", code = E0055)]
671pub(crate) struct AutoDerefReachedRecursionLimit<'a> {
672 #[primary_span]
673 #[label("deref recursion limit reached")]
674 pub span: Span,
675 pub ty: Ty<'a>,
676 pub suggested_limit: Limit,
677 pub crate_name: Symbol,
678}
679
680#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for WhereClauseOnMain {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
WhereClauseOnMain {
span: __binding_0, generics_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to have a `where` clause")));
diag.code(E0646);
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` cannot have a `where` clause")));
}
diag
}
}
}
}
};Diagnostic)]
681#[diag("`main` function is not allowed to have a `where` clause", code = E0646)]
682pub(crate) struct WhereClauseOnMain {
683 #[primary_span]
684 pub span: Span,
685 #[label("`main` cannot have a `where` clause")]
686 pub generics_span: Option<Span>,
687}
688
689#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TrackCallerOnMain {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TrackCallerOnMain {
span: __binding_0, annotated: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to be `#[track_caller]`")));
let __code_10 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this annotation")),
__code_10, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to be `#[track_caller]`")));
diag
}
}
}
}
};Diagnostic)]
690#[diag("`main` function is not allowed to be `#[track_caller]`")]
691pub(crate) struct TrackCallerOnMain {
692 #[primary_span]
693 #[suggestion("remove this annotation", applicability = "maybe-incorrect", code = "")]
694 pub span: Span,
695 #[label("`main` function is not allowed to be `#[track_caller]`")]
696 pub annotated: Span,
697}
698
699#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TargetFeatureOnMain
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TargetFeatureOnMain { main: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to have `#[target_feature]`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to have `#[target_feature]`")));
diag
}
}
}
}
};Diagnostic)]
700#[diag("`main` function is not allowed to have `#[target_feature]`")]
701pub(crate) struct TargetFeatureOnMain {
702 #[primary_span]
703 #[label("`main` function is not allowed to have `#[target_feature]`")]
704 pub main: Span,
705}
706
707#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MainFunctionReturnTypeGeneric {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MainFunctionReturnTypeGeneric { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function return type is not allowed to have generic parameters")));
diag.code(E0131);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
708#[diag("`main` function return type is not allowed to have generic parameters", code = E0131)]
709pub(crate) struct MainFunctionReturnTypeGeneric {
710 #[primary_span]
711 pub span: Span,
712}
713
714#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MainFunctionAsync {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MainFunctionAsync {
span: __binding_0, asyncness: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to be `async`")));
diag.code(E0752);
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to be `async`")));
}
diag
}
}
}
}
};Diagnostic)]
715#[diag("`main` function is not allowed to be `async`", code = E0752)]
716pub(crate) struct MainFunctionAsync {
717 #[primary_span]
718 pub span: Span,
719 #[label("`main` function is not allowed to be `async`")]
720 pub asyncness: Option<Span>,
721}
722
723#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MainFunctionGenericParameters {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MainFunctionGenericParameters {
span: __binding_0, label_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function is not allowed to have generic parameters")));
diag.code(E0131);
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` cannot have generic parameters")));
}
diag
}
}
}
}
};Diagnostic)]
724#[diag("`main` function is not allowed to have generic parameters", code = E0131)]
725pub(crate) struct MainFunctionGenericParameters {
726 #[primary_span]
727 pub span: Span,
728 #[label("`main` cannot have generic parameters")]
729 pub label_span: Option<Span>,
730}
731
732#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
VariadicFunctionCompatibleConvention<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
VariadicFunctionCompatibleConvention {
span: __binding_0, convention: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("C-variadic functions with the {$convention} calling convention are not supported")));
diag.code(E0045);
;
diag.arg("convention", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("C-variadic function must have a compatible calling convention")));
diag
}
}
}
}
};Diagnostic)]
733#[diag("C-variadic functions with the {$convention} calling convention are not supported", code = E0045)]
734pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
735 #[primary_span]
736 #[label("C-variadic function must have a compatible calling convention")]
737 pub span: Span,
738 pub convention: &'a str,
739}
740
741#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotCaptureLateBound {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotCaptureLateBound::Type {
use_span: __binding_0,
def_span: __binding_1,
what: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot capture late-bound type parameter in {$what}")));
;
diag.arg("what", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parameter defined here")));
diag
}
CannotCaptureLateBound::Const {
use_span: __binding_0,
def_span: __binding_1,
what: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot capture late-bound const parameter in {$what}")));
;
diag.arg("what", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parameter defined here")));
diag
}
CannotCaptureLateBound::Lifetime {
use_span: __binding_0,
def_span: __binding_1,
what: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot capture late-bound lifetime in {$what}")));
;
diag.arg("what", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime defined here")));
diag
}
}
}
}
};Diagnostic)]
742pub(crate) enum CannotCaptureLateBound {
743 #[diag("cannot capture late-bound type parameter in {$what}")]
744 Type {
745 #[primary_span]
746 use_span: Span,
747 #[label("parameter defined here")]
748 def_span: Span,
749 what: &'static str,
750 },
751 #[diag("cannot capture late-bound const parameter in {$what}")]
752 Const {
753 #[primary_span]
754 use_span: Span,
755 #[label("parameter defined here")]
756 def_span: Span,
757 what: &'static str,
758 },
759 #[diag("cannot capture late-bound lifetime in {$what}")]
760 Lifetime {
761 #[primary_span]
762 use_span: Span,
763 #[label("lifetime defined here")]
764 def_span: Span,
765 what: &'static str,
766 },
767}
768
769#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for TypeOf<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TypeOf { span: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$ty}")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
770#[diag("{$ty}")]
771pub(crate) struct TypeOf<'tcx> {
772 #[primary_span]
773 pub span: Span,
774 pub ty: Ty<'tcx>,
775}
776
777#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InvalidUnionField {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InvalidUnionField {
field_span: __binding_0,
sugg: __binding_1,
note: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union")));
diag.code(E0740);
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`")));
diag
}
}
}
}
};Diagnostic)]
778#[diag("field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union", code = E0740)]
779pub(crate) struct InvalidUnionField {
780 #[primary_span]
781 pub field_span: Span,
782 #[subdiagnostic]
783 pub sugg: InvalidUnionFieldSuggestion,
784 #[note(
785 "union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`"
786 )]
787 pub note: (),
788}
789
790#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
ReturnTypeNotationOnNonRpitit<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReturnTypeNotationOnNonRpitit {
span: __binding_0,
ty: __binding_1,
fn_span: __binding_2,
note: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type notation used on function that is not `async` and does not return `impl Trait`")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this function must be `async` or return `impl Trait`")));
}
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function returns `{$ty}`, which is not compatible with associated type return bounds")));
diag
}
}
}
}
};Diagnostic)]
791#[diag(
792 "return type notation used on function that is not `async` and does not return `impl Trait`"
793)]
794pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
795 #[primary_span]
796 pub span: Span,
797 pub ty: Ty<'tcx>,
798 #[label("this function must be `async` or return `impl Trait`")]
799 pub fn_span: Option<Span>,
800 #[note("function returns `{$ty}`, which is not compatible with associated type return bounds")]
801 pub note: (),
802}
803
804#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidUnionFieldSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
InvalidUnionFieldSuggestion {
lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_11 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("std::mem::ManuallyDrop<"))
});
let __code_12 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(">"))
});
suggestions.push((__binding_0, __code_11));
suggestions.push((__binding_1, __code_12));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the field type in `ManuallyDrop<...>`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
805#[multipart_suggestion(
806 "wrap the field type in `ManuallyDrop<...>`",
807 applicability = "machine-applicable"
808)]
809pub(crate) struct InvalidUnionFieldSuggestion {
810 #[suggestion_part(code = "std::mem::ManuallyDrop<")]
811 pub lo: Span,
812 #[suggestion_part(code = ">")]
813 pub hi: Span,
814}
815
816#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ReturnTypeNotationEqualityBound {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReturnTypeNotationEqualityBound { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type notation is not allowed to use type equality")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
817#[diag("return type notation is not allowed to use type equality")]
818pub(crate) struct ReturnTypeNotationEqualityBound {
819 #[primary_span]
820 pub span: Span,
821}
822
823#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PlaceholderNotAllowedItemSignatures {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PlaceholderNotAllowedItemSignatures {
spans: __binding_0, kind: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the placeholder `_` is not allowed within types on item signatures for {$kind}")));
diag.code(E0121);
;
diag.arg("kind", __binding_1);
diag.span(__binding_0.clone());
for __binding_0 in __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not allowed in type signatures")));
}
diag
}
}
}
}
};Diagnostic)]
824#[diag("the placeholder `_` is not allowed within types on item signatures for {$kind}", code = E0121)]
825pub(crate) struct PlaceholderNotAllowedItemSignatures {
826 #[primary_span]
827 #[label("not allowed in type signatures")]
828 pub spans: Vec<Span>,
829 pub kind: String,
830}
831
832#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AssociatedItemTraitUninferredGenericParams {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AssociatedItemTraitUninferredGenericParams {
span: __binding_0,
inferred_sugg: __binding_1,
bound: __binding_2,
mpart_sugg: __binding_3,
what: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use the {$what} of a trait with uninferred generic parameters")));
let __code_13 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.code(E0212);
;
diag.arg("what", __binding_4);
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a fully qualified path with inferred lifetimes")),
__code_13, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
833#[diag("cannot use the {$what} of a trait with uninferred generic parameters", code = E0212)]
834pub(crate) struct AssociatedItemTraitUninferredGenericParams {
835 #[primary_span]
836 pub span: Span,
837 #[suggestion(
838 "use a fully qualified path with inferred lifetimes",
839 style = "verbose",
840 applicability = "maybe-incorrect",
841 code = "{bound}"
842 )]
843 pub inferred_sugg: Option<Span>,
844 pub bound: String,
845 #[subdiagnostic]
846 pub mpart_sugg: Option<AssociatedItemTraitUninferredGenericParamsMultipartSuggestion>,
847 pub what: &'static str,
848}
849
850#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
fspan: __binding_0,
first: __binding_1,
sspan: __binding_2,
second: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_14 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_15 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_14));
suggestions.push((__binding_2, __code_15));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a fully qualified path with explicit lifetimes")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
851#[multipart_suggestion(
852 "use a fully qualified path with explicit lifetimes",
853 applicability = "maybe-incorrect"
854)]
855pub(crate) struct AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
856 #[suggestion_part(code = "{first}")]
857 pub fspan: Span,
858 pub first: String,
859 #[suggestion_part(code = "{second}")]
860 pub sspan: Span,
861 pub second: String,
862}
863
864#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
EnumDiscriminantOverflowed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EnumDiscriminantOverflowed {
span: __binding_0,
discr: __binding_1,
item_name: __binding_2,
wrapped_discr: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enum discriminant overflowed")));
diag.code(E0370);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly set `{$item_name} = {$wrapped_discr}` if that is desired outcome")));
;
diag.arg("discr", __binding_1);
diag.arg("item_name", __binding_2);
diag.arg("wrapped_discr", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overflowed on value after {$discr}")));
diag
}
}
}
}
};Diagnostic)]
865#[diag("enum discriminant overflowed", code = E0370)]
866#[note("explicitly set `{$item_name} = {$wrapped_discr}` if that is desired outcome")]
867pub(crate) struct EnumDiscriminantOverflowed {
868 #[primary_span]
869 #[label("overflowed on value after {$discr}")]
870 pub span: Span,
871 pub discr: String,
872 pub item_name: Ident,
873 pub wrapped_discr: String,
874}
875
876#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
SIMDFFIHighlyExperimental {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SIMDFFIHighlyExperimental {
span: __binding_0, snip: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of SIMD type{$snip} in FFI is highly experimental and may result in invalid code")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(simd_ffi)]` to the crate attributes to enable")));
;
diag.arg("snip", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
877#[diag("use of SIMD type{$snip} in FFI is highly experimental and may result in invalid code")]
878#[help("add `#![feature(simd_ffi)]` to the crate attributes to enable")]
879pub(crate) struct SIMDFFIHighlyExperimental {
880 #[primary_span]
881 pub span: Span,
882 pub snip: String,
883}
884
885#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ImplNotMarkedDefault
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ImplNotMarkedDefault::Ok {
span: __binding_0, ok_label: __binding_1, ident: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`")));
diag.code(E0520);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to specialize, `{$ident}` in the parent `impl` must be marked `default`")));
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot specialize default item `{$ident}`")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parent `impl` is here")));
diag
}
ImplNotMarkedDefault::Err {
span: __binding_0, cname: __binding_1, ident: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`")));
diag.code(E0520);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parent implementation is in crate `{$cname}`")));
;
diag.arg("cname", __binding_1);
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
886pub(crate) enum ImplNotMarkedDefault {
887 #[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
888 #[note("to specialize, `{$ident}` in the parent `impl` must be marked `default`")]
889 Ok {
890 #[primary_span]
891 #[label("cannot specialize default item `{$ident}`")]
892 span: Span,
893 #[label("parent `impl` is here")]
894 ok_label: Span,
895 ident: Ident,
896 },
897 #[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
898 #[note("parent implementation is in crate `{$cname}`")]
899 Err {
900 #[primary_span]
901 span: Span,
902 cname: Symbol,
903 ident: Ident,
904 },
905}
906
907#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UselessImplItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UselessImplItem => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this item cannot be used as its where bounds are not satisfied for the `Self` type")));
;
diag
}
}
}
}
};Diagnostic)]
908#[diag("this item cannot be used as its where bounds are not satisfied for the `Self` type")]
909pub(crate) struct UselessImplItem;
910
911#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
OverridingFinalTraitFunction {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OverridingFinalTraitFunction {
impl_span: __binding_0,
trait_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot override `{$ident}` because it already has a `final` definition in the trait")));
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is marked final here")));
diag
}
}
}
}
};Diagnostic)]
912#[diag("cannot override `{$ident}` because it already has a `final` definition in the trait")]
913pub(crate) struct OverridingFinalTraitFunction {
914 #[primary_span]
915 pub impl_span: Span,
916 #[note("`{$ident}` is marked final here")]
917 pub trait_span: Span,
918 pub ident: Ident,
919}
920
921#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MissingTraitItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MissingTraitItem {
span: __binding_0,
missing_trait_item_label: __binding_1,
missing_trait_item: __binding_2,
missing_trait_item_none: __binding_3,
missing_trait_item_unstable: __binding_4,
missing_items_msg: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not all trait items implemented, missing: `{$missing_items_msg}`")));
diag.code(E0046);
;
diag.arg("missing_items_msg", __binding_5);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing `{$missing_items_msg}` in implementation")));
for __binding_1 in __binding_1 {
diag.subdiagnostic(__binding_1);
}
for __binding_2 in __binding_2 {
diag.subdiagnostic(__binding_2);
}
for __binding_3 in __binding_3 {
diag.subdiagnostic(__binding_3);
}
for __binding_4 in __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag
}
}
}
}
};Diagnostic)]
922#[diag("not all trait items implemented, missing: `{$missing_items_msg}`", code = E0046)]
923pub(crate) struct MissingTraitItem {
924 #[primary_span]
925 #[label("missing `{$missing_items_msg}` in implementation")]
926 pub span: Span,
927 #[subdiagnostic]
928 pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
929 #[subdiagnostic]
930 pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
931 #[subdiagnostic]
932 pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
933 #[subdiagnostic]
934 pub missing_trait_item_unstable: Vec<MissingTraitItemSuggestionUnstable>,
935 pub missing_items_msg: String,
936}
937
938#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingTraitItemLabel {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MissingTraitItemLabel { span: __binding_0, item: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("item".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$item}` from trait")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
939#[label("`{$item}` from trait")]
940pub(crate) struct MissingTraitItemLabel {
941 #[primary_span]
942 pub span: Span,
943 pub item: Symbol,
944}
945
946#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingTraitItemSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MissingTraitItemSuggestion {
span: __binding_0, code: __binding_1, snippet: __binding_2 }
=> {
let __code_16 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implement the missing item: `{$snippet}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_16, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
}
}
}
};Subdiagnostic)]
947#[suggestion(
948 "implement the missing item: `{$snippet}`",
949 style = "tool-only",
950 applicability = "has-placeholders",
951 code = "{code}"
952)]
953pub(crate) struct MissingTraitItemSuggestion {
954 #[primary_span]
955 pub span: Span,
956 pub code: String,
957 pub snippet: String,
958}
959
960#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
MissingTraitItemSuggestionUnstable {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MissingTraitItemSuggestionUnstable {
span: __binding_0,
code: __binding_1,
snippet: __binding_2,
feature: __binding_3 } => {
let __code_17 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("feature".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implement the missing item: `{$snippet}` (unstable, requires feature `{$feature}`)")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_17, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::HideCodeAlways);
}
}
}
}
};Subdiagnostic)]
961#[suggestion(
962 "implement the missing item: `{$snippet}` (unstable, requires feature `{$feature}`)",
963 style = "hidden",
964 applicability = "has-placeholders",
965 code = "{code}"
966)]
967pub(crate) struct MissingTraitItemSuggestionUnstable {
968 #[primary_span]
969 pub span: Span,
970 pub code: String,
971 pub snippet: String,
972 pub feature: Symbol,
973}
974
975#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingTraitItemSuggestionNone {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MissingTraitItemSuggestionNone {
span: __binding_0, code: __binding_1, snippet: __binding_2 }
=> {
let __code_18 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implement the missing item: `{$snippet}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_18, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::HideCodeAlways);
}
}
}
}
};Subdiagnostic)]
976#[suggestion(
977 "implement the missing item: `{$snippet}`",
978 style = "hidden",
979 applicability = "has-placeholders",
980 code = "{code}"
981)]
982pub(crate) struct MissingTraitItemSuggestionNone {
983 #[primary_span]
984 pub span: Span,
985 pub code: String,
986 pub snippet: String,
987}
988
989#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MissingOneOfTraitItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MissingOneOfTraitItem {
span: __binding_0,
note: __binding_1,
missing_trait_item_label: __binding_2,
missing_trait_item: __binding_3,
missing_trait_item_none: __binding_4,
missing_trait_item_unstable: __binding_5,
missing_items_msg: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not all trait items implemented, missing one of: `{$missing_items_msg}`")));
diag.code(E0046);
;
diag.arg("missing_items_msg", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing one of `{$missing_items_msg}` in implementation")));
if let Some(__binding_1) = __binding_1 {
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required because of this annotation")));
}
for __binding_2 in __binding_2 {
diag.subdiagnostic(__binding_2);
}
for __binding_3 in __binding_3 {
diag.subdiagnostic(__binding_3);
}
for __binding_4 in __binding_4 {
diag.subdiagnostic(__binding_4);
}
for __binding_5 in __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag
}
}
}
}
};Diagnostic)]
990#[diag("not all trait items implemented, missing one of: `{$missing_items_msg}`", code = E0046)]
991pub(crate) struct MissingOneOfTraitItem {
992 #[primary_span]
993 #[label("missing one of `{$missing_items_msg}` in implementation")]
994 pub span: Span,
995 #[note("required because of this annotation")]
996 pub note: Option<Span>,
997 #[subdiagnostic]
998 pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
999 #[subdiagnostic]
1000 pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
1001 #[subdiagnostic]
1002 pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
1003 #[subdiagnostic]
1004 pub missing_trait_item_unstable: Vec<MissingTraitItemSuggestionUnstable>,
1005 pub missing_items_msg: String,
1006}
1007
1008#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MissingTraitItemUnstable {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MissingTraitItemUnstable {
span: __binding_0,
some_note: __binding_1,
none_note: __binding_2,
missing_item_name: __binding_3,
feature: __binding_4,
reason: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not all trait items implemented, missing: `{$missing_item_name}`")));
diag.code(E0046);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("default implementation of `{$missing_item_name}` is unstable")));
;
diag.arg("missing_item_name", __binding_3);
diag.arg("feature", __binding_4);
diag.arg("reason", __binding_5);
diag.span(__binding_0);
if __binding_1 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unstable library feature `{$feature}`: {$reason}")));
}
if __binding_2 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unstable library feature `{$feature}`")));
}
diag
}
}
}
}
};Diagnostic)]
1009#[diag("not all trait items implemented, missing: `{$missing_item_name}`", code = E0046)]
1010#[note("default implementation of `{$missing_item_name}` is unstable")]
1011pub(crate) struct MissingTraitItemUnstable {
1012 #[primary_span]
1013 pub span: Span,
1014 #[note("use of unstable library feature `{$feature}`: {$reason}")]
1015 pub some_note: bool,
1016 #[note("use of unstable library feature `{$feature}`")]
1017 pub none_note: bool,
1018 pub missing_item_name: Ident,
1019 pub feature: Symbol,
1020 pub reason: String,
1021}
1022
1023#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
TransparentEnumVariant {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TransparentEnumVariant {
span: __binding_0,
spans: __binding_1,
many: __binding_2,
number: __binding_3,
path: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("transparent enum needs exactly one variant, but has {$number}")));
diag.code(E0731);
;
diag.arg("number", __binding_3);
diag.arg("path", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("needs exactly one variant, but has {$number}")));
for __binding_1 in __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variant here")));
}
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("too many variants in `{$path}`")));
}
diag
}
}
}
}
};Diagnostic)]
1024#[diag("transparent enum needs exactly one variant, but has {$number}", code = E0731)]
1025pub(crate) struct TransparentEnumVariant {
1026 #[primary_span]
1027 #[label("needs exactly one variant, but has {$number}")]
1028 pub span: Span,
1029 #[label("variant here")]
1030 pub spans: Vec<Span>,
1031 #[label("too many variants in `{$path}`")]
1032 pub many: Option<Span>,
1033 pub number: usize,
1034 pub path: String,
1035}
1036
1037#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TooLargeStatic {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TooLargeStatic { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern static is too large for the target architecture")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1038#[diag("extern static is too large for the target architecture")]
1039pub(crate) struct TooLargeStatic {
1040 #[primary_span]
1041 pub span: Span,
1042}
1043
1044#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for SpecializationTrait
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SpecializationTrait { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `rustc_specialization_trait` traits is unstable")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(min_specialization)]` to the crate attributes to enable")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1045#[diag("implementing `rustc_specialization_trait` traits is unstable")]
1046#[help("add `#![feature(min_specialization)]` to the crate attributes to enable")]
1047pub(crate) struct SpecializationTrait {
1048 #[primary_span]
1049 pub span: Span,
1050}
1051
1052#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ImplOfRestrictedTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ImplOfRestrictedTrait {
impl_span: __binding_0,
restriction_span: __binding_1,
restriction_path: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait cannot be implemented outside `{$restriction_path}`")));
;
diag.arg("restriction_path", __binding_2);
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait restricted here")));
diag
}
}
}
}
};Diagnostic)]
1053#[diag("trait cannot be implemented outside `{$restriction_path}`")]
1054pub(crate) struct ImplOfRestrictedTrait {
1055 #[primary_span]
1056 pub impl_span: Span,
1057 #[note("trait restricted here")]
1058 pub restriction_span: Span,
1059 pub restriction_path: String,
1060}
1061
1062#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ClosureImplicitHrtb
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ClosureImplicitHrtb {
spans: __binding_0, for_sp: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implicit types in closure signatures are forbidden when `for<...>` is present")));
;
diag.span(__binding_0.clone());
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`for<...>` is here")));
diag
}
}
}
}
};Diagnostic)]
1063#[diag("implicit types in closure signatures are forbidden when `for<...>` is present")]
1064pub(crate) struct ClosureImplicitHrtb {
1065 #[primary_span]
1066 pub spans: Vec<Span>,
1067 #[label("`for<...>` is here")]
1068 pub for_sp: Span,
1069}
1070
1071#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for EmptySpecialization
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EmptySpecialization {
span: __binding_0, base_impl_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specialization impl does not specialize any associated items")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl is a specialization of this impl")));
diag
}
}
}
}
};Diagnostic)]
1072#[diag("specialization impl does not specialize any associated items")]
1073pub(crate) struct EmptySpecialization {
1074 #[primary_span]
1075 pub span: Span,
1076 #[note("impl is a specialization of this impl")]
1077 pub base_impl_span: Span,
1078}
1079
1080#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for StaticSpecialize {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
StaticSpecialize { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot specialize on `'static` lifetime")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1081#[diag("cannot specialize on `'static` lifetime")]
1082pub(crate) struct StaticSpecialize {
1083 #[primary_span]
1084 pub span: Span,
1085}
1086
1087#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NegativeDropImplPolarity {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NegativeDropImplPolarity { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("negative `Drop` impls are not supported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1088#[diag("negative `Drop` impls are not supported")]
1089pub(crate) struct NegativeDropImplPolarity {
1090 #[primary_span]
1091 pub span: Span,
1092}
1093
1094#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ReturnTypeNotationIllegalParam {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReturnTypeNotationIllegalParam::Type {
span: __binding_0, param_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type notation is not allowed for functions that have type parameters")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter declared here")));
diag
}
ReturnTypeNotationIllegalParam::Const {
span: __binding_0, param_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type notation is not allowed for functions that have const parameters")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameter declared here")));
diag
}
}
}
}
};Diagnostic)]
1095pub(crate) enum ReturnTypeNotationIllegalParam {
1096 #[diag("return type notation is not allowed for functions that have type parameters")]
1097 Type {
1098 #[primary_span]
1099 span: Span,
1100 #[label("type parameter declared here")]
1101 param_span: Span,
1102 },
1103 #[diag("return type notation is not allowed for functions that have const parameters")]
1104 Const {
1105 #[primary_span]
1106 span: Span,
1107 #[label("const parameter declared here")]
1108 param_span: Span,
1109 },
1110}
1111
1112#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for LateBoundInApit {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LateBoundInApit::Type {
span: __binding_0, param_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl Trait` can only mention type parameters from an fn or impl")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter declared here")));
diag
}
LateBoundInApit::Const {
span: __binding_0, param_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl Trait` can only mention const parameters from an fn or impl")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameter declared here")));
diag
}
LateBoundInApit::Lifetime {
span: __binding_0, param_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl Trait` can only mention lifetimes from an fn or impl")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime declared here")));
diag
}
}
}
}
};Diagnostic)]
1113pub(crate) enum LateBoundInApit {
1114 #[diag("`impl Trait` can only mention type parameters from an fn or impl")]
1115 Type {
1116 #[primary_span]
1117 span: Span,
1118 #[label("type parameter declared here")]
1119 param_span: Span,
1120 },
1121 #[diag("`impl Trait` can only mention const parameters from an fn or impl")]
1122 Const {
1123 #[primary_span]
1124 span: Span,
1125 #[label("const parameter declared here")]
1126 param_span: Span,
1127 },
1128 #[diag("`impl Trait` can only mention lifetimes from an fn or impl")]
1129 Lifetime {
1130 #[primary_span]
1131 span: Span,
1132 #[label("lifetime declared here")]
1133 param_span: Span,
1134 },
1135}
1136
1137#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnusedAssociatedTypeBounds {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedAssociatedTypeBounds { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary associated type bound for dyn-incompatible associated type")));
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized`")));
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this bound")),
__code_19, rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1138#[diag("unnecessary associated type bound for dyn-incompatible associated type")]
1139#[note(
1140 "this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized`"
1141)]
1142pub(crate) struct UnusedAssociatedTypeBounds {
1143 #[suggestion("remove this bound", code = "")]
1144 pub span: Span,
1145}
1146
1147#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ReturnPositionImplTraitInTraitRefined {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReturnPositionImplTraitInTraitRefined {
impl_return_span: __binding_0,
trait_return_span: __binding_1,
unmatched_bound: __binding_2,
pre: __binding_3,
post: __binding_4,
return_ty: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl trait in impl method signature does not match trait method signature")));
let __code_20 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}{2}{0}", __binding_4,
__binding_3, __binding_5))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information")));
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace the return type so that it matches the trait")),
__code_20, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type from trait method defined here")));
}
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this bound is stronger than that defined on the trait")));
}
diag
}
}
}
}
};Diagnostic)]
1148#[diag("impl trait in impl method signature does not match trait method signature")]
1149#[note(
1150 "add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1151)]
1152#[note(
1153 "we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1154)]
1155pub(crate) struct ReturnPositionImplTraitInTraitRefined {
1156 #[suggestion(
1157 "replace the return type so that it matches the trait",
1158 applicability = "maybe-incorrect",
1159 code = "{pre}{return_ty}{post}"
1160 )]
1161 pub impl_return_span: Span,
1162 #[label("return type from trait method defined here")]
1163 pub trait_return_span: Option<Span>,
1164 #[label("this bound is stronger than that defined on the trait")]
1165 pub unmatched_bound: Option<Span>,
1166
1167 pub pre: &'static str,
1168 pub post: &'static str,
1169 pub return_ty: String,
1170}
1171
1172#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ReturnPositionImplTraitInTraitRefinedLifetimes {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReturnPositionImplTraitInTraitRefinedLifetimes {
suggestion_span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl trait in impl method captures fewer lifetimes than in trait")));
let __code_21 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information")));
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("modify the `use<..>` bound to capture the same lifetimes that the trait does")),
__code_21, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1173#[diag("impl trait in impl method captures fewer lifetimes than in trait")]
1174#[note(
1175 "add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1176)]
1177#[note(
1178 "we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1179)]
1180pub(crate) struct ReturnPositionImplTraitInTraitRefinedLifetimes {
1181 #[suggestion(
1182 "modify the `use<..>` bound to capture the same lifetimes that the trait does",
1183 applicability = "maybe-incorrect",
1184 code = "{suggestion}"
1185 )]
1186 pub suggestion_span: Span,
1187 pub suggestion: String,
1188}
1189
1190#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InherentTyOutside {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InherentTyOutside { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define inherent `impl` for a type outside of the crate where the type is defined")));
diag.code(E0390);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving this inherent impl into the crate defining the type if possible")));
;
diag.span(__binding_0);
diag.span_help(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items")));
diag
}
}
}
}
};Diagnostic)]
1191#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1192#[help("consider moving this inherent impl into the crate defining the type if possible")]
1193pub(crate) struct InherentTyOutside {
1194 #[primary_span]
1195 #[help(
1196 "alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items"
1197 )]
1198 pub span: Span,
1199}
1200
1201#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for DispatchFromDynRepr
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DispatchFromDynRepr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`")));
diag.code(E0378);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1202#[diag("structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`", code = E0378)]
1203pub(crate) struct DispatchFromDynRepr {
1204 #[primary_span]
1205 pub span: Span,
1206}
1207
1208#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoercePointeeNotStruct {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoercePointeeNotStruct {
span: __binding_0, kind: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`derive(CoercePointee)` is only applicable to `struct`, instead of `{$kind}`")));
diag.code(E0802);
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1209#[diag("`derive(CoercePointee)` is only applicable to `struct`, instead of `{$kind}`", code = E0802)]
1210pub(crate) struct CoercePointeeNotStruct {
1211 #[primary_span]
1212 pub span: Span,
1213 pub kind: String,
1214}
1215
1216#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoercePointeeNotConcreteType {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoercePointeeNotConcreteType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`derive(CoercePointee)` is only applicable to `struct`")));
diag.code(E0802);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1217#[diag("`derive(CoercePointee)` is only applicable to `struct`", code = E0802)]
1218pub(crate) struct CoercePointeeNotConcreteType {
1219 #[primary_span]
1220 pub span: Span,
1221}
1222
1223#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoercePointeeNoUserValidityAssertion {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoercePointeeNoUserValidityAssertion { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("asserting applicability of `derive(CoercePointee)` on a target data is forbidden")));
diag.code(E0802);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1224#[diag("asserting applicability of `derive(CoercePointee)` on a target data is forbidden", code = E0802)]
1225pub(crate) struct CoercePointeeNoUserValidityAssertion {
1226 #[primary_span]
1227 pub span: Span,
1228}
1229
1230#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoercePointeeNotTransparent {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoercePointeeNotTransparent { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`derive(CoercePointee)` is only applicable to `struct` with `repr(transparent)` layout")));
diag.code(E0802);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1231#[diag("`derive(CoercePointee)` is only applicable to `struct` with `repr(transparent)` layout", code = E0802)]
1232pub(crate) struct CoercePointeeNotTransparent {
1233 #[primary_span]
1234 pub span: Span,
1235}
1236
1237#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CoercePointeeNoField
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoercePointeeNoField { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`CoercePointee` can only be derived on `struct`s with at least one field")));
diag.code(E0802);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1238#[diag("`CoercePointee` can only be derived on `struct`s with at least one field", code = E0802)]
1239pub(crate) struct CoercePointeeNoField {
1240 #[primary_span]
1241 pub span: Span,
1242}
1243
1244#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
InherentTyOutsideRelevant {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InherentTyOutsideRelevant {
span: __binding_0, help_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define inherent `impl` for a type outside of the crate where the type is defined")));
diag.code(E0390);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving this inherent impl into the crate defining the type if possible")));
;
diag.span(__binding_0);
diag.span_help(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")));
diag
}
}
}
}
};Diagnostic)]
1245#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1246#[help("consider moving this inherent impl into the crate defining the type if possible")]
1247pub(crate) struct InherentTyOutsideRelevant {
1248 #[primary_span]
1249 pub span: Span,
1250 #[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1251 pub help_span: Span,
1252}
1253
1254#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InherentTyOutsideNew
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InherentTyOutsideNew { span: __binding_0, note: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define inherent `impl` for a type outside of the crate where the type is defined")));
diag.code(E0116);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl for type defined outside of crate")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1255#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0116)]
1256#[help(
1257 "consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it"
1258)]
1259#[note(
1260 "for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>"
1261)]
1262pub(crate) struct InherentTyOutsideNew {
1263 #[primary_span]
1264 #[label("impl for type defined outside of crate")]
1265 pub span: Span,
1266 #[subdiagnostic]
1267 pub note: Option<InherentTyOutsideNewAliasNote>,
1268}
1269
1270#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InherentTyOutsideNewAliasNote {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
InherentTyOutsideNewAliasNote {
span: __binding_0,
ty_name: __binding_1,
alias_ty_name: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("alias_ty_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty_name}` does not define a new type, only an alias of `{$alias_ty_name}` defined here")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1271#[note("`{$ty_name}` does not define a new type, only an alias of `{$alias_ty_name}` defined here")]
1272pub(crate) struct InherentTyOutsideNewAliasNote {
1273 #[primary_span]
1274 pub span: Span,
1275 pub ty_name: String,
1276 pub alias_ty_name: String,
1277}
1278
1279#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
InherentTyOutsidePrimitive {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InherentTyOutsidePrimitive {
span: __binding_0, help_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define inherent `impl` for primitive types outside of `core`")));
diag.code(E0390);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving this inherent impl into `core` if possible")));
;
diag.span(__binding_0);
diag.span_help(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")));
diag
}
}
}
}
};Diagnostic)]
1280#[diag("cannot define inherent `impl` for primitive types outside of `core`", code = E0390)]
1281#[help("consider moving this inherent impl into `core` if possible")]
1282pub(crate) struct InherentTyOutsidePrimitive {
1283 #[primary_span]
1284 pub span: Span,
1285 #[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1286 pub help_span: Span,
1287}
1288
1289#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
InherentPrimitiveTy<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InherentPrimitiveTy { span: __binding_0, note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define inherent `impl` for primitive types")));
diag.code(E0390);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using an extension trait instead")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1290#[diag("cannot define inherent `impl` for primitive types", code = E0390)]
1291#[help("consider using an extension trait instead")]
1292pub(crate) struct InherentPrimitiveTy<'a> {
1293 #[primary_span]
1294 pub span: Span,
1295 #[subdiagnostic]
1296 pub note: Option<InherentPrimitiveTyNote<'a>>,
1297}
1298
1299#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for InherentPrimitiveTyNote<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
InherentPrimitiveTyNote { subty: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("subty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you could also try moving the reference to uses of `{$subty}` (such as `self`) within the implementation")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
1300#[note(
1301 "you could also try moving the reference to uses of `{$subty}` (such as `self`) within the implementation"
1302)]
1303pub(crate) struct InherentPrimitiveTyNote<'a> {
1304 pub subty: Ty<'a>,
1305}
1306
1307#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InherentDyn {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InherentDyn { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define inherent `impl` for a dyn auto trait")));
diag.code(E0785);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("define and implement a new trait or type instead")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl requires at least one non-auto trait")));
diag
}
}
}
}
};Diagnostic)]
1308#[diag("cannot define inherent `impl` for a dyn auto trait", code = E0785)]
1309#[note("define and implement a new trait or type instead")]
1310pub(crate) struct InherentDyn {
1311 #[primary_span]
1312 #[label("impl requires at least one non-auto trait")]
1313 pub span: Span,
1314}
1315
1316#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InherentNominal {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InherentNominal { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no nominal type found for inherent implementation")));
diag.code(E0118);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("either implement a trait on it or create a newtype to wrap it instead")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl requires a nominal type")));
diag
}
}
}
}
};Diagnostic)]
1317#[diag("no nominal type found for inherent implementation", code = E0118)]
1318#[note("either implement a trait on it or create a newtype to wrap it instead")]
1319pub(crate) struct InherentNominal {
1320 #[primary_span]
1321 #[label("impl requires a nominal type")]
1322 pub span: Span,
1323}
1324
1325#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
DispatchFromDynZST<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DispatchFromDynZST {
span: __binding_0, name: __binding_1, ty: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else")));
diag.code(E0378);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extra field `{$name}` of type `{$ty}` is not allowed")));
;
diag.arg("name", __binding_1);
diag.arg("ty", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1326#[diag("the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else", code = E0378)]
1327#[note("extra field `{$name}` of type `{$ty}` is not allowed")]
1328pub(crate) struct DispatchFromDynZST<'a> {
1329 #[primary_span]
1330 pub span: Span,
1331 pub name: Ident,
1332 pub ty: Ty<'a>,
1333}
1334
1335#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CoerceNoField {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceNoField {
span: __binding_0,
trait_name: __binding_1,
note: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires a field to be coerced")));
diag.code(E0374);
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
if __binding_2 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a single field to be coerced, none found")));
}
diag
}
}
}
}
};Diagnostic)]
1336#[diag("implementing `{$trait_name}` requires a field to be coerced", code = E0374)]
1337pub(crate) struct CoerceNoField {
1338 #[primary_span]
1339 pub span: Span,
1340 pub trait_name: &'static str,
1341 #[note("expected a single field to be coerced, none found")]
1342 pub note: bool,
1343}
1344
1345#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CoerceMulti {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceMulti {
trait_name: __binding_0,
span: __binding_1,
number: __binding_2,
fields: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` does not allow multiple fields to be coerced")));
diag.code(E0375);
;
diag.arg("trait_name", __binding_0);
diag.span(__binding_1);
diag.span_note(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `{$trait_name}` may only be implemented when a single field is being coerced")));
diag
}
}
}
}
};Diagnostic)]
1346#[diag("implementing `{$trait_name}` does not allow multiple fields to be coerced", code = E0375)]
1347pub(crate) struct CoerceMulti {
1348 pub trait_name: &'static str,
1349 #[primary_span]
1350 pub span: Span,
1351 pub number: usize,
1352 #[note(
1353 "the trait `{$trait_name}` may only be implemented when a single field is being coerced"
1354 )]
1355 pub fields: MultiSpan,
1356}
1357
1358#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ReborrowNoLifetimes
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReborrowNoLifetimes {
span: __binding_0, trait_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires at least one lifetime argument in the reborrowed type")));
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1359#[diag(
1360 "implementing `{$trait_name}` requires at least one lifetime argument in the reborrowed type"
1361)]
1362pub(crate) struct ReborrowNoLifetimes {
1363 #[primary_span]
1364 pub span: Span,
1365 pub trait_name: &'static str,
1366}
1367
1368#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
CoerceSharedFieldMismatch<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedFieldMismatch {
span: __binding_0,
source_span: __binding_1,
impl_span: __binding_2,
source_name: __binding_3,
source_ty: __binding_4,
target_name: __binding_5,
target_ty: __binding_6,
trait_name: __binding_7 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires corresponding fields to match, be reborrowable with `CoerceShared`, or coerce a mutable reference field to a shared reference field")));
;
diag.arg("source_name", __binding_3);
diag.arg("source_ty", __binding_4);
diag.arg("target_name", __binding_5);
diag.arg("target_ty", __binding_6);
diag.arg("trait_name", __binding_7);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("target field `{$target_name}` has type `{$target_ty}`")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("source field `{$source_name}` has type `{$source_ty}`")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required by this `CoerceShared` implementation")));
diag
}
}
}
}
};Diagnostic)]
1369#[diag(
1370 "implementing `{$trait_name}` requires corresponding fields to match, \
1371 be reborrowable with `CoerceShared`, or coerce a mutable reference field \
1372 to a shared reference field"
1373)]
1374pub(crate) struct CoerceSharedFieldMismatch<'tcx> {
1375 #[primary_span]
1376 #[label("target field `{$target_name}` has type `{$target_ty}`")]
1377 pub span: Span,
1378 #[label("source field `{$source_name}` has type `{$source_ty}`")]
1379 pub source_span: Span,
1380 #[label("required by this `CoerceShared` implementation")]
1381 pub impl_span: Span,
1382 pub source_name: Symbol,
1383 pub source_ty: Ty<'tcx>,
1384 pub target_name: Symbol,
1385 pub target_ty: Ty<'tcx>,
1386 pub trait_name: &'static str,
1387}
1388
1389#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoerceSharedMissingField {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedMissingField {
span: __binding_0,
source_ty_span: __binding_1,
trait_name: __binding_2,
source_ty_name: __binding_3,
field_name: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires every target field to have a corresponding source field")));
;
diag.arg("trait_name", __binding_2);
diag.arg("source_ty_name", __binding_3);
diag.arg("field_name", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("target field `{$field_name}` has no corresponding source field")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("source type `{$source_ty_name}` does not contain field `{$field_name}`")));
diag
}
}
}
}
};Diagnostic)]
1390#[diag(
1391 "implementing `{$trait_name}` requires every target field to have a corresponding source field"
1392)]
1393pub(crate) struct CoerceSharedMissingField {
1394 #[primary_span]
1395 #[label("target field `{$field_name}` has no corresponding source field")]
1396 pub span: Span,
1397 #[label("source type `{$source_ty_name}` does not contain field `{$field_name}`")]
1398 pub source_ty_span: Span,
1399 pub trait_name: &'static str,
1400 pub source_ty_name: Symbol,
1401 pub field_name: Symbol,
1402}
1403
1404#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
CoerceSharedOmittedSourceFieldNotCopyOrReborrow<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedOmittedSourceFieldNotCopyOrReborrow {
span: __binding_0,
impl_span: __binding_1,
trait_name: __binding_2,
field_name: __binding_3,
field_ty: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires source fields omitted from the target to be `Copy` or `Reborrow`")));
;
diag.arg("trait_name", __binding_2);
diag.arg("field_name", __binding_3);
diag.arg("field_ty", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("source field `{$field_name}` has type `{$field_ty}`")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required by this `CoerceShared` implementation")));
diag
}
}
}
}
};Diagnostic)]
1405#[diag(
1406 "implementing `{$trait_name}` requires source fields omitted from the target to be `Copy` or \
1407 `Reborrow`"
1408)]
1409pub(crate) struct CoerceSharedOmittedSourceFieldNotCopyOrReborrow<'tcx> {
1410 #[primary_span]
1411 #[label("source field `{$field_name}` has type `{$field_ty}`")]
1412 pub span: Span,
1413 #[label("required by this `CoerceShared` implementation")]
1414 pub impl_span: Span,
1415 pub trait_name: &'static str,
1416 pub field_name: Symbol,
1417 pub field_ty: Ty<'tcx>,
1418}
1419
1420#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoerceSharedFieldStyleMismatch {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedFieldStyleMismatch {
span: __binding_0, trait_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires source and target structs to use the same field style")));
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1421#[diag(
1422 "implementing `{$trait_name}` requires source and target structs to use the same field style"
1423)]
1424pub(crate) struct CoerceSharedFieldStyleMismatch {
1425 #[primary_span]
1426 pub span: Span,
1427 pub trait_name: &'static str,
1428}
1429
1430#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoerceSharedInaccessibleField {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedInaccessibleField {
span: __binding_0,
type_span: __binding_1,
trait_name: __binding_2,
role: __binding_3,
type_name: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires all {$role} type fields to be accessible from the impl")));
;
diag.arg("trait_name", __binding_2);
diag.arg("role", __binding_3);
diag.arg("type_name", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$role} type `{$type_name}` has inaccessible reborrow data fields")));
diag
}
}
}
}
};Diagnostic)]
1431#[diag(
1432 "implementing `{$trait_name}` requires all {$role} type fields to be accessible from the impl"
1433)]
1434pub(crate) struct CoerceSharedInaccessibleField {
1435 #[primary_span]
1436 pub span: Span,
1437 #[label("{$role} type `{$type_name}` has inaccessible reborrow data fields")]
1438 pub type_span: Span,
1439 pub trait_name: &'static str,
1440 pub role: &'static str,
1441 pub type_name: Symbol,
1442}
1443
1444#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoerceSharedMultipleNonZstFields {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedMultipleNonZstFields {
span: __binding_0,
source_ty_span: __binding_1,
target_ty_span: __binding_2,
trait_name: __binding_3,
source_count: __binding_4,
target_count: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` currently requires source and target to have at most one non-ZST reborrow data field")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a temporary restriction until `CoerceShared` lowering supports non-trivially memcpy-compatible field layouts")));
;
diag.arg("trait_name", __binding_3);
diag.arg("source_count", __binding_4);
diag.arg("target_count", __binding_5);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in this `CoerceShared` implementation")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("source type has {$source_count} non-ZST reborrow data fields")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("target type has {$target_count} non-ZST reborrow data fields")));
diag
}
}
}
}
};Diagnostic)]
1445#[diag(
1446 "implementing `{$trait_name}` currently requires source and target to have at most one \
1447 non-ZST reborrow data field"
1448)]
1449#[note(
1450 "this is a temporary restriction until `CoerceShared` lowering supports non-trivially \
1451 memcpy-compatible field layouts"
1452)]
1453pub(crate) struct CoerceSharedMultipleNonZstFields {
1454 #[primary_span]
1455 #[label("in this `CoerceShared` implementation")]
1456 pub span: Span,
1457 #[label("source type has {$source_count} non-ZST reborrow data fields")]
1458 pub source_ty_span: Span,
1459 #[label("target type has {$target_count} non-ZST reborrow data fields")]
1460 pub target_ty_span: Span,
1461 pub trait_name: &'static str,
1462 pub source_count: usize,
1463 pub target_count: usize,
1464}
1465
1466#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoerceUnsizedNonStruct {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceUnsizedNonStruct {
span: __binding_0, trait_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `{$trait_name}` may only be implemented for a coercion between structures")));
diag.code(E0377);
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1467#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1468pub(crate) struct CoerceUnsizedNonStruct {
1469 #[primary_span]
1470 pub span: Span,
1471 pub trait_name: &'static str,
1472}
1473
1474#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CoerceSamePatKind {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSamePatKind {
span: __binding_0,
trait_name: __binding_1,
pat_a: __binding_2,
pat_b: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only pattern types with the same pattern can be coerced between each other")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1475#[diag("only pattern types with the same pattern can be coerced between each other")]
1476pub(crate) struct CoerceSamePatKind {
1477 #[primary_span]
1478 pub span: Span,
1479 pub trait_name: &'static str,
1480 pub pat_a: String,
1481 pub pat_b: String,
1482}
1483
1484#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CoerceSameStruct {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSameStruct {
span: __binding_0,
trait_name: __binding_1,
note: __binding_2,
source_path: __binding_3,
target_path: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `{$trait_name}` may only be implemented for a coercion between structures")));
diag.code(E0377);
;
diag.arg("trait_name", __binding_1);
diag.arg("source_path", __binding_3);
diag.arg("target_path", __binding_4);
diag.span(__binding_0);
if __binding_2 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected coercion between the same definition; expected `{$source_path}`, found `{$target_path}`")));
}
diag
}
}
}
}
};Diagnostic)]
1485#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1486pub(crate) struct CoerceSameStruct {
1487 #[primary_span]
1488 pub span: Span,
1489 pub trait_name: &'static str,
1490 #[note(
1491 "expected coercion between the same definition; expected `{$source_path}`, found `{$target_path}`"
1492 )]
1493 pub note: bool,
1494 pub source_path: String,
1495 pub target_path: String,
1496}
1497
1498#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
CoerceFieldValidity<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceFieldValidity {
span: __binding_0,
ty: __binding_1,
trait_name: __binding_2,
field_span: __binding_3,
field_ty: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for `{$ty}` to have a valid implementation of `{$trait_name}`, it must be possible to coerce the field of type `{$field_ty}`")));
;
diag.arg("ty", __binding_1);
diag.arg("trait_name", __binding_2);
diag.arg("field_ty", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$field_ty}` must be a pointer, reference, or smart pointer that is allowed to be unsized")));
diag
}
}
}
}
};Diagnostic)]
1499#[diag(
1500 "for `{$ty}` to have a valid implementation of `{$trait_name}`, it must be possible to coerce the field of type `{$field_ty}`"
1501)]
1502pub(crate) struct CoerceFieldValidity<'tcx> {
1503 #[primary_span]
1504 pub span: Span,
1505 pub ty: Ty<'tcx>,
1506 pub trait_name: &'static str,
1507 #[label(
1508 "`{$field_ty}` must be a pointer, reference, or smart pointer that is allowed to be unsized"
1509 )]
1510 pub field_span: Span,
1511 pub field_ty: Ty<'tcx>,
1512}
1513
1514#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TraitCannotImplForTy
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TraitCannotImplForTy {
span: __binding_0,
trait_name: __binding_1,
label_spans: __binding_2,
notes: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the trait `{$trait_name}` cannot be implemented for this type")));
diag.code(E0204);
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
for __binding_2 in __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this field does not implement `{$trait_name}`")));
}
for __binding_3 in __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
1515#[diag("the trait `{$trait_name}` cannot be implemented for this type", code = E0204)]
1516pub(crate) struct TraitCannotImplForTy {
1517 #[primary_span]
1518 pub span: Span,
1519 pub trait_name: String,
1520 #[label("this field does not implement `{$trait_name}`")]
1521 pub label_spans: Vec<Span>,
1522 #[subdiagnostic]
1523 pub notes: Vec<ImplForTyRequires>,
1524}
1525
1526#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImplForTyRequires {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ImplForTyRequires {
span: __binding_0,
error_predicate: __binding_1,
trait_name: __binding_2,
ty: __binding_3 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("error_predicate".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("trait_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1527#[note("the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`")]
1528pub(crate) struct ImplForTyRequires {
1529 #[primary_span]
1530 pub span: MultiSpan,
1531 pub error_predicate: String,
1532 pub trait_name: String,
1533 pub ty: String,
1534}
1535
1536#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
TraitsWithDefaultImpl<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TraitsWithDefaultImpl {
span: __binding_0,
traits: __binding_1,
problematic_kind: __binding_2,
self_ty: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`")));
diag.code(E0321);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds")));
;
diag.arg("traits", __binding_1);
diag.arg("problematic_kind", __binding_2);
diag.arg("self_ty", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1537#[diag("traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`", code = E0321)]
1538#[note(
1539 "a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds"
1540)]
1541pub(crate) struct TraitsWithDefaultImpl<'a> {
1542 #[primary_span]
1543 pub span: Span,
1544 pub traits: String,
1545 pub problematic_kind: &'a str,
1546 pub self_ty: Ty<'a>,
1547}
1548
1549#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
CrossCrateTraits<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CrossCrateTraits {
span: __binding_0, traits: __binding_1, self_ty: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`")));
diag.code(E0321);
;
diag.arg("traits", __binding_1);
diag.arg("self_ty", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't implement cross-crate trait with a default impl for non-struct/enum type")));
diag
}
}
}
}
};Diagnostic)]
1550#[diag("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`", code = E0321)]
1551pub(crate) struct CrossCrateTraits<'a> {
1552 #[primary_span]
1553 #[label("can't implement cross-crate trait with a default impl for non-struct/enum type")]
1554 pub span: Span,
1555 pub traits: String,
1556 pub self_ty: Ty<'a>,
1557}
1558
1559#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CrossCrateTraitsDefined {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CrossCrateTraitsDefined {
span: __binding_0, traits: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type defined in the current crate")));
diag.code(E0321);
;
diag.arg("traits", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't implement cross-crate trait for type in another crate")));
diag
}
}
}
}
};Diagnostic)]
1560#[diag("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type defined in the current crate", code = E0321)]
1561pub(crate) struct CrossCrateTraitsDefined {
1562 #[primary_span]
1563 #[label("can't implement cross-crate trait for type in another crate")]
1564 pub span: Span,
1565 pub traits: String,
1566}
1567
1568#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
NoVariantNamed<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoVariantNamed {
span: __binding_0, ident: __binding_1, ty: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no variant named `{$ident}` found for enum `{$ty}`")));
diag.code(E0599);
;
diag.arg("ident", __binding_1);
diag.arg("ty", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1569#[diag("no variant named `{$ident}` found for enum `{$ty}`", code = E0599)]
1570pub struct NoVariantNamed<'tcx> {
1571 #[primary_span]
1572 pub span: Span,
1573 pub ident: Ident,
1574 pub ty: Ty<'tcx>,
1575}
1576
1577#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
NoFieldOnType<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoFieldOnType {
span: __binding_0, ty: __binding_1, field: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no field `{$field}` on type `{$ty}`")));
diag.code(E0609);
;
diag.arg("ty", __binding_1);
diag.arg("field", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1578#[diag("no field `{$field}` on type `{$ty}`", code = E0609)]
1579pub struct NoFieldOnType<'tcx> {
1580 #[primary_span]
1581 pub span: Span,
1582 pub ty: Ty<'tcx>,
1583 pub field: Ident,
1584}
1585
1586#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for OnlyCurrentTraits {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OnlyCurrentTraits::Outside {
span: __binding_0, note: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only traits defined in the current crate can be implemented for types defined outside of the crate")));
diag.code(E0117);
;
diag.span(__binding_0);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl doesn't have any local type before any uncovered type parameters")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("define and implement a trait or new type instead")));
diag
}
OnlyCurrentTraits::Primitive {
span: __binding_0, note: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only traits defined in the current crate can be implemented for primitive types")));
diag.code(E0117);
;
diag.span(__binding_0);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl doesn't have any local type before any uncovered type parameters")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("define and implement a trait or new type instead")));
diag
}
OnlyCurrentTraits::Arbitrary {
span: __binding_0, note: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only traits defined in the current crate can be implemented for arbitrary types")));
diag.code(E0117);
;
diag.span(__binding_0);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl doesn't have any local type before any uncovered type parameters")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("define and implement a trait or new type instead")));
diag
}
}
}
}
};Diagnostic)]
1587pub(crate) enum OnlyCurrentTraits {
1588 #[diag("only traits defined in the current crate can be implemented for types defined outside of the crate", code = E0117)]
1589 Outside {
1590 #[primary_span]
1591 span: Span,
1592 #[note("impl doesn't have any local type before any uncovered type parameters")]
1593 #[note(
1594 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1595 )]
1596 #[note("define and implement a trait or new type instead")]
1597 note: (),
1598 },
1599 #[diag("only traits defined in the current crate can be implemented for primitive types", code = E0117)]
1600 Primitive {
1601 #[primary_span]
1602 span: Span,
1603 #[note("impl doesn't have any local type before any uncovered type parameters")]
1604 #[note(
1605 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1606 )]
1607 #[note("define and implement a trait or new type instead")]
1608 note: (),
1609 },
1610 #[diag("only traits defined in the current crate can be implemented for arbitrary types", code = E0117)]
1611 Arbitrary {
1612 #[primary_span]
1613 span: Span,
1614 #[note("impl doesn't have any local type before any uncovered type parameters")]
1615 #[note(
1616 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1617 )]
1618 #[note("define and implement a trait or new type instead")]
1619 note: (),
1620 },
1621}
1622
1623#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OnlyCurrentTraitsOpaque {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OnlyCurrentTraitsOpaque { 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("type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1624#[label(
1625 "type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate"
1626)]
1627pub(crate) struct OnlyCurrentTraitsOpaque {
1628 #[primary_span]
1629 pub span: Span,
1630}
1631#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OnlyCurrentTraitsForeign {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OnlyCurrentTraitsForeign { 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 is not defined in the current crate because this is a foreign trait")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1632#[label("this is not defined in the current crate because this is a foreign trait")]
1633pub(crate) struct OnlyCurrentTraitsForeign {
1634 #[primary_span]
1635 pub span: Span,
1636}
1637
1638#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OnlyCurrentTraitsName<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OnlyCurrentTraitsName { span: __binding_0, name: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is not defined in the current crate because {$name} are always foreign")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1639#[label("this is not defined in the current crate because {$name} are always foreign")]
1640pub(crate) struct OnlyCurrentTraitsName<'a> {
1641 #[primary_span]
1642 pub span: Span,
1643 pub name: &'a str,
1644}
1645
1646#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OnlyCurrentTraitsPointer<'a>
{
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OnlyCurrentTraitsPointer {
span: __binding_0, pointer: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("pointer".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$pointer}` is not defined in the current crate because raw pointers are always foreign")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1647#[label("`{$pointer}` is not defined in the current crate because raw pointers are always foreign")]
1648pub(crate) struct OnlyCurrentTraitsPointer<'a> {
1649 #[primary_span]
1650 pub span: Span,
1651 pub pointer: Ty<'a>,
1652}
1653
1654#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OnlyCurrentTraitsTy<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OnlyCurrentTraitsTy { span: __binding_0, ty: __binding_1 }
=> {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` is not defined in the current crate")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1655#[label("`{$ty}` is not defined in the current crate")]
1656pub(crate) struct OnlyCurrentTraitsTy<'a> {
1657 #[primary_span]
1658 pub span: Span,
1659 pub ty: Ty<'a>,
1660}
1661
1662#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OnlyCurrentTraitsAdt {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OnlyCurrentTraitsAdt { span: __binding_0, name: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` is not defined in the current crate")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1663#[label("`{$name}` is not defined in the current crate")]
1664pub(crate) struct OnlyCurrentTraitsAdt {
1665 #[primary_span]
1666 pub span: Span,
1667 pub name: String,
1668}
1669
1670#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
OnlyCurrentTraitsPointerSugg<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OnlyCurrentTraitsPointerSugg {
wrapper_span: __binding_0,
struct_span: __binding_1,
mut_key: __binding_2,
ptr_ty: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_22 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("WrapperType"))
});
let __code_23 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("struct WrapperType(*{0}{1});\n\n",
__binding_2, __binding_3))
});
suggestions.push((__binding_0, __code_22));
suggestions.push((__binding_1, __code_23));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider introducing a new wrapper type")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1671#[multipart_suggestion(
1672 "consider introducing a new wrapper type",
1673 applicability = "maybe-incorrect"
1674)]
1675pub(crate) struct OnlyCurrentTraitsPointerSugg<'a> {
1676 #[suggestion_part(code = "WrapperType")]
1677 pub wrapper_span: Span,
1678 #[suggestion_part(code = "struct WrapperType(*{mut_key}{ptr_ty});\n\n")]
1679 pub(crate) struct_span: Span,
1680 pub mut_key: &'a str,
1681 pub ptr_ty: Ty<'a>,
1682}
1683
1684#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DelegationInheritanceFailed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DelegationInheritanceFailed {
span: __binding_0,
kind: __binding_1,
callee_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to inherit delegation {$kind}")));
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("callee defined here")));
diag
}
}
}
}
};Diagnostic)]
1685#[diag("failed to inherit delegation {$kind}")]
1686pub(crate) struct DelegationInheritanceFailed {
1687 #[primary_span]
1688 pub span: Span,
1689 pub kind: &'static str,
1690 #[label("callee defined here")]
1691 pub callee_span: Span,
1692}
1693
1694#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
UnsupportedDelegation<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnsupportedDelegation {
span: __binding_0,
descr: __binding_1,
callee_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr}")));
;
diag.arg("descr", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("callee defined here")));
diag
}
}
}
}
};Diagnostic)]
1695#[diag("{$descr}")]
1696pub(crate) struct UnsupportedDelegation<'a> {
1697 #[primary_span]
1698 pub span: Span,
1699 pub descr: &'a str,
1700 #[label("callee defined here")]
1701 pub callee_span: Span,
1702}
1703
1704#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ElidedLifetimesAreNotAllowedInDelegations {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ElidedLifetimesAreNotAllowedInDelegations {
span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inferred lifetimes are not allowed in delegations as we need to inherit signature")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1705#[diag("inferred lifetimes are not allowed in delegations as we need to inherit signature")]
1706pub(crate) struct ElidedLifetimesAreNotAllowedInDelegations {
1707 #[primary_span]
1708 pub span: Span,
1709}
1710
1711#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MethodShouldReturnFuture {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MethodShouldReturnFuture {
span: __binding_0,
method_name: __binding_1,
trait_item_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("method should be `async` or return a future, but it is synchronous")));
;
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this method is `async` so it expects a future to be returned")));
}
diag
}
}
}
}
};Diagnostic)]
1712#[diag("method should be `async` or return a future, but it is synchronous")]
1713pub(crate) struct MethodShouldReturnFuture {
1714 #[primary_span]
1715 pub span: Span,
1716 pub method_name: Ident,
1717 #[note("this method is `async` so it expects a future to be returned")]
1718 pub trait_item_span: Option<Span>,
1719}
1720
1721#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnusedGenericParameter {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedGenericParameter {
span: __binding_0,
param_name: __binding_1,
param_def_kind: __binding_2,
usage_spans: __binding_3,
help: __binding_4,
const_param_help: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$param_def_kind} `{$param_name}` is never used")));
;
diag.arg("param_name", __binding_1);
diag.arg("param_def_kind", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$param_def_kind}")));
for __binding_3 in __binding_3 {
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$param_name}` is named here, but is not used in the type that wraps it")));
}
diag.subdiagnostic(__binding_4);
if __binding_5 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you intended `{$param_name}` to be a const parameter, use `const {$param_name}: /* Type */` instead")));
}
diag
}
}
}
}
};Diagnostic)]
1722#[diag("{$param_def_kind} `{$param_name}` is never used")]
1723pub(crate) struct UnusedGenericParameter {
1724 #[primary_span]
1725 #[label("unused {$param_def_kind}")]
1726 pub span: Span,
1727 pub param_name: Ident,
1728 pub param_def_kind: &'static str,
1729 #[label("`{$param_name}` is named here, but is not used in the type that wraps it")]
1730 pub usage_spans: Vec<Span>,
1731 #[subdiagnostic]
1732 pub help: UnusedGenericParameterHelp,
1733 #[help(
1734 "if you intended `{$param_name}` to be a const parameter, use `const {$param_name}: /* Type */` instead"
1735 )]
1736 pub const_param_help: bool,
1737}
1738
1739#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RecursiveGenericParameter {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RecursiveGenericParameter {
spans: __binding_0,
param_span: __binding_1,
param_name: __binding_2,
param_def_kind: __binding_3,
help: __binding_4,
note: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$param_def_kind} `{$param_name}` is only used recursively")));
;
diag.arg("param_name", __binding_2);
diag.arg("param_def_kind", __binding_3);
diag.span(__binding_0.clone());
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$param_def_kind} must be used non-recursively in the definition")));
diag.subdiagnostic(__binding_4);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("all type parameters must be used in a non-recursive way in order to constrain their variance")));
diag
}
}
}
}
};Diagnostic)]
1740#[diag("{$param_def_kind} `{$param_name}` is only used recursively")]
1741pub(crate) struct RecursiveGenericParameter {
1742 #[primary_span]
1743 pub spans: Vec<Span>,
1744 #[label("{$param_def_kind} must be used non-recursively in the definition")]
1745 pub param_span: Span,
1746 pub param_name: Ident,
1747 pub param_def_kind: &'static str,
1748 #[subdiagnostic]
1749 pub help: UnusedGenericParameterHelp,
1750 #[note(
1751 "all type parameters must be used in a non-recursive way in order to constrain their variance"
1752 )]
1753 pub note: (),
1754}
1755
1756#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedGenericParameterHelp {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnusedGenericParameterHelp::Adt {
param_name: __binding_0, phantom_data: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("param_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("phantom_data".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing `{$param_name}`, referring to it in a field, or using a marker such as `{$phantom_data}`")),
&sub_args);
diag.help(__message);
}
UnusedGenericParameterHelp::AdtNoPhantomData {
param_name: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("param_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing `{$param_name}` or referring to it in a field")),
&sub_args);
diag.help(__message);
}
UnusedGenericParameterHelp::TyAlias {
param_name: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("param_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing `{$param_name}` or referring to it in the body of the type alias")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
1757pub(crate) enum UnusedGenericParameterHelp {
1758 #[help(
1759 "consider removing `{$param_name}`, referring to it in a field, or using a marker such as `{$phantom_data}`"
1760 )]
1761 Adt { param_name: Ident, phantom_data: String },
1762 #[help("consider removing `{$param_name}` or referring to it in a field")]
1763 AdtNoPhantomData { param_name: Ident },
1764 #[help("consider removing `{$param_name}` or referring to it in the body of the type alias")]
1765 TyAlias { param_name: Ident },
1766}
1767
1768#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnconstrainedGenericParameter {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnconstrainedGenericParameter {
span: __binding_0,
param_name: __binding_1,
param_def_kind: __binding_2,
const_param_note: __binding_3,
const_param_note2: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$param_def_kind} `{$param_name}` is not constrained by the impl trait, self type, or predicates")));
;
diag.arg("param_name", __binding_1);
diag.arg("param_def_kind", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unconstrained {$param_def_kind}")));
if __binding_3 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expressions using a const parameter must map each value to a distinct output value")));
}
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("proving the result of expressions other than the parameter are unique is not supported")));
}
diag
}
}
}
}
};Diagnostic)]
1769#[diag(
1770 "the {$param_def_kind} `{$param_name}` is not constrained by the impl trait, self type, or predicates"
1771)]
1772pub(crate) struct UnconstrainedGenericParameter {
1773 #[primary_span]
1774 #[label("unconstrained {$param_def_kind}")]
1775 pub span: Span,
1776 pub param_name: Ident,
1777 pub param_def_kind: &'static str,
1778 #[note("expressions using a const parameter must map each value to a distinct output value")]
1779 pub const_param_note: bool,
1780 #[note(
1781 "proving the result of expressions other than the parameter are unique is not supported"
1782 )]
1783 pub const_param_note2: bool,
1784}
1785
1786#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
OpaqueCapturesHigherRankedLifetime {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OpaqueCapturesHigherRankedLifetime {
span: __binding_0,
label: __binding_1,
decl_span: __binding_2,
bad_place: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl Trait` cannot capture {$bad_place}")));
diag.code(E0657);
;
diag.arg("bad_place", __binding_3);
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl Trait` implicitly captures all lifetimes in scope")));
}
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime declared here")));
diag
}
}
}
}
};Diagnostic)]
1787#[diag("`impl Trait` cannot capture {$bad_place}", code = E0657)]
1788pub(crate) struct OpaqueCapturesHigherRankedLifetime {
1789 #[primary_span]
1790 pub span: MultiSpan,
1791 #[label("`impl Trait` implicitly captures all lifetimes in scope")]
1792 pub label: Option<Span>,
1793 #[note("lifetime declared here")]
1794 pub decl_span: MultiSpan,
1795 pub bad_place: &'static str,
1796}
1797
1798#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidReceiverTyHint {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
InvalidReceiverTyHint::Weak => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Weak` does not implement `Receiver` because it has methods that may shadow the referent; consider wrapping your `Weak` in a newtype wrapper for which you implement `Receiver`")),
&sub_args);
diag.note(__message);
}
InvalidReceiverTyHint::NonNull => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`NonNull` does not implement `Receiver` because it has methods that may shadow the referent; consider wrapping your `NonNull` in a newtype wrapper for which you implement `Receiver`")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
1799pub(crate) enum InvalidReceiverTyHint {
1800 #[note(
1801 "`Weak` does not implement `Receiver` because it has methods that may shadow the referent; consider wrapping your `Weak` in a newtype wrapper for which you implement `Receiver`"
1802 )]
1803 Weak,
1804 #[note(
1805 "`NonNull` does not implement `Receiver` because it has methods that may shadow the referent; consider wrapping your `NonNull` in a newtype wrapper for which you implement `Receiver`"
1806 )]
1807 NonNull,
1808}
1809
1810#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InvalidReceiverTyNoArbitrarySelfTypes {
span: __binding_0, receiver_ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `self` parameter type: `{$receiver_ty}`")));
diag.code(E0307);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type of `self` must be `Self` or a type that dereferences to it")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)")));
;
diag.arg("receiver_ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1811#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1812#[note("type of `self` must be `Self` or a type that dereferences to it")]
1813#[help(
1814 "consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)"
1815)]
1816pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
1817 #[primary_span]
1818 pub span: Span,
1819 pub receiver_ty: Ty<'tcx>,
1820}
1821
1822#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
InvalidReceiverTy<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InvalidReceiverTy {
span: __binding_0,
receiver_ty: __binding_1,
hint: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `self` parameter type: `{$receiver_ty}`")));
diag.code(E0307);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type of `self` must be `Self` or some type implementing `Receiver`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`")));
;
diag.arg("receiver_ty", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
1823#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1824#[note("type of `self` must be `Self` or some type implementing `Receiver`")]
1825#[help(
1826 "consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`"
1827)]
1828pub(crate) struct InvalidReceiverTy<'tcx> {
1829 #[primary_span]
1830 pub span: Span,
1831 pub receiver_ty: Ty<'tcx>,
1832 #[subdiagnostic]
1833 pub hint: Option<InvalidReceiverTyHint>,
1834}
1835
1836#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
InvalidGenericReceiverTy<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InvalidGenericReceiverTy {
span: __binding_0, receiver_ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid generic `self` parameter type: `{$receiver_ty}`")));
diag.code(E0801);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type of `self` must not be a method generic parameter type")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a concrete type such as `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)")));
;
diag.arg("receiver_ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1837#[diag("invalid generic `self` parameter type: `{$receiver_ty}`", code = E0801)]
1838#[note("type of `self` must not be a method generic parameter type")]
1839#[help(
1840 "use a concrete type such as `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)"
1841)]
1842pub(crate) struct InvalidGenericReceiverTy<'tcx> {
1843 #[primary_span]
1844 pub span: Span,
1845 pub receiver_ty: Ty<'tcx>,
1846}
1847
1848#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CmseInputsStackSpill
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CmseInputsStackSpill { spans: __binding_0, abi: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("arguments for `{$abi}` function too large to pass via registers")));
diag.code(E0798);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit argument registers")));
;
diag.arg("abi", __binding_1);
diag.span(__binding_0.clone());
for __binding_0 in __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("does not fit in the available registers")));
}
diag
}
}
}
}
};Diagnostic)]
1849#[diag("arguments for `{$abi}` function too large to pass via registers", code = E0798)]
1850#[note(
1851 "functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit argument registers"
1852)]
1853pub(crate) struct CmseInputsStackSpill {
1854 #[primary_span]
1855 #[label("does not fit in the available registers")]
1856 pub spans: Vec<Span>,
1857 pub abi: ExternAbi,
1858}
1859
1860#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CmseOutputStackSpill
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CmseOutputStackSpill { span: __binding_0, abi: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return value of `{$abi}` function too large to pass via registers")));
diag.code(E0798);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the `{$abi}` ABI must pass their result via the available return registers")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size")));
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this type doesn't fit in the available registers")));
diag
}
}
}
}
};Diagnostic)]
1861#[diag("return value of `{$abi}` function too large to pass via registers", code = E0798)]
1862#[note("functions with the `{$abi}` ABI must pass their result via the available return registers")]
1863#[note(
1864 "the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size"
1865)]
1866pub(crate) struct CmseOutputStackSpill {
1867 #[primary_span]
1868 #[label("this type doesn't fit in the available registers")]
1869 pub span: Span,
1870 pub abi: ExternAbi,
1871}
1872
1873#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CmseGeneric {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CmseGeneric { span: __binding_0, abi: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generics are not allowed in `extern {$abi}` signatures")));
diag.code(E0798);
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1874#[diag("generics are not allowed in `extern {$abi}` signatures", code = E0798)]
1875pub(crate) struct CmseGeneric {
1876 #[primary_span]
1877 pub span: Span,
1878 pub abi: ExternAbi,
1879}
1880
1881#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CmseImplTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CmseImplTrait { span: __binding_0, abi: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl Trait` is not allowed in `extern {$abi}` signatures")));
diag.code(E0798);
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1882#[diag("`impl Trait` is not allowed in `extern {$abi}` signatures", code = E0798)]
1883pub(crate) struct CmseImplTrait {
1884 #[primary_span]
1885 pub span: Span,
1886 pub abi: ExternAbi,
1887}
1888
1889#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
BadReturnTypeNotation {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BadReturnTypeNotation {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type notation not allowed in this position yet")));
let __code_24 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("(..)"))
})].into_iter();
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("furthermore, argument types not allowed with return type notation")),
__code_24, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
1890#[diag("return type notation not allowed in this position yet")]
1891pub(crate) struct BadReturnTypeNotation {
1892 #[primary_span]
1893 pub span: Span,
1894 #[suggestion(
1895 "furthermore, argument types not allowed with return type notation",
1896 applicability = "maybe-incorrect",
1897 code = "(..)",
1898 style = "verbose"
1899 )]
1900 pub suggestion: Option<Span>,
1901}
1902
1903#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
SupertraitItemShadowing {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SupertraitItemShadowing {
item: __binding_0,
subtrait: __binding_1,
shadowee: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")));
;
diag.arg("item", __binding_0);
diag.arg("subtrait", __binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1904#[diag("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")]
1905pub(crate) struct SupertraitItemShadowing {
1906 pub item: Symbol,
1907 pub subtrait: Symbol,
1908 #[subdiagnostic]
1909 pub shadowee: SupertraitItemShadowee,
1910}
1911
1912#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SupertraitItemShadowee {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SupertraitItemShadowee::Labeled {
span: __binding_0, supertrait: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("supertrait".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item from `{$supertrait}` is shadowed by a subtrait item")),
&sub_args);
diag.span_note(__binding_0, __message);
}
SupertraitItemShadowee::Several {
spans: __binding_0, traits: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("traits".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items from several supertraits are shadowed: {$traits}")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1913pub(crate) enum SupertraitItemShadowee {
1914 #[note("item from `{$supertrait}` is shadowed by a subtrait item")]
1915 Labeled {
1916 #[primary_span]
1917 span: Span,
1918 supertrait: Symbol,
1919 },
1920 #[note("items from several supertraits are shadowed: {$traits}")]
1921 Several {
1922 #[primary_span]
1923 spans: MultiSpan,
1924 traits: DiagSymbolList,
1925 },
1926}
1927
1928#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DynTraitAssocItemBindingMentionsSelf {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DynTraitAssocItemBindingMentionsSelf {
span: __binding_0, kind: __binding_1, binding: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind} binding in trait object type mentions `Self`")));
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("contains a mention of `Self`")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this binding mentions `Self`")));
diag
}
}
}
}
};Diagnostic)]
1929#[diag("{$kind} binding in trait object type mentions `Self`")]
1930pub(crate) struct DynTraitAssocItemBindingMentionsSelf {
1931 #[primary_span]
1932 #[label("contains a mention of `Self`")]
1933 pub span: Span,
1934 pub kind: &'static str,
1935 #[label("this binding mentions `Self`")]
1936 pub binding: Span,
1937}
1938
1939#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AsyncDropWithoutSyncDrop {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AsyncDropWithoutSyncDrop { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`AsyncDrop` impl without `Drop` impl")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type implementing `AsyncDrop` trait must also implement `Drop` trait to be used in sync context and unwinds")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1940#[diag("`AsyncDrop` impl without `Drop` impl")]
1941#[help(
1942 "type implementing `AsyncDrop` trait must also implement `Drop` trait to be used in sync context and unwinds"
1943)]
1944pub(crate) struct AsyncDropWithoutSyncDrop {
1945 #[primary_span]
1946 pub span: Span,
1947}
1948
1949#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
LifetimesOrBoundsMismatchOnEii {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LifetimesOrBoundsMismatchOnEii {
span: __binding_0,
generics_span: __binding_1,
where_span: __binding_2,
bounds_span: __binding_3,
ident: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters or bounds of `{$ident}` do not match the declaration")));
;
diag.arg("ident", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes do not match")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetimes in impl do not match this signature")));
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `where` clause might not match the one in the trait")));
}
for __binding_3 in __binding_3 {
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this bound might be missing in the impl")));
}
diag
}
}
}
}
};Diagnostic)]
1950#[diag("lifetime parameters or bounds of `{$ident}` do not match the declaration")]
1951pub(crate) struct LifetimesOrBoundsMismatchOnEii {
1952 #[primary_span]
1953 #[label("lifetimes do not match")]
1954 pub span: Span,
1955 #[label("lifetimes in impl do not match this signature")]
1956 pub generics_span: Span,
1957 #[label("this `where` clause might not match the one in the trait")]
1958 pub where_span: Option<Span>,
1959 #[label("this bound might be missing in the impl")]
1960 pub bounds_span: Vec<Span>,
1961 pub ident: Symbol,
1962}
1963
1964#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for EiiWithGenerics {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EiiWithGenerics {
span: __binding_0,
attr: __binding_1,
eii_name: __binding_2,
impl_name: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$impl_name}` cannot have generic parameters other than lifetimes")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$eii_name}]` marks the implementation of an \"externally implementable item\"")));
;
diag.arg("eii_name", __binding_2);
diag.arg("impl_name", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required by this attribute")));
diag
}
}
}
}
};Diagnostic)]
1965#[diag("`{$impl_name}` cannot have generic parameters other than lifetimes")]
1966#[help("`#[{$eii_name}]` marks the implementation of an \"externally implementable item\"")]
1967pub(crate) struct EiiWithGenerics {
1968 #[primary_span]
1969 pub span: Span,
1970 #[label("required by this attribute")]
1971 pub attr: Span,
1972 pub eii_name: Symbol,
1973 pub impl_name: Symbol,
1974}
1975
1976#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ImplUnpinForPinProjectedType {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ImplUnpinForPinProjectedType {
span: __binding_0,
adt_span: __binding_1,
adt_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit impls for the `Unpin` trait are not permitted for structurally pinned types")));
;
diag.arg("adt_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl of `Unpin` not allowed")));
diag.span_help(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$adt_name}` is structurally pinned because it is marked as `#[pin_v2]`")));
diag
}
}
}
}
};Diagnostic)]
1977#[diag("explicit impls for the `Unpin` trait are not permitted for structurally pinned types")]
1978pub(crate) struct ImplUnpinForPinProjectedType {
1979 #[primary_span]
1980 #[label("impl of `Unpin` not allowed")]
1981 pub span: Span,
1982 #[help("`{$adt_name}` is structurally pinned because it is marked as `#[pin_v2]`")]
1983 pub adt_span: Span,
1984 pub adt_name: Symbol,
1985}
1986
1987#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for EiiDefkindMismatch {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EiiDefkindMismatch {
span: __binding_0,
eii_name: __binding_1,
expected_kind: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$eii_name}]` must be used on a {$expected_kind}")));
;
diag.arg("eii_name", __binding_1);
diag.arg("expected_kind", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1988#[diag("`#[{$eii_name}]` must be used on a {$expected_kind}")]
1989pub(crate) struct EiiDefkindMismatch {
1990 #[primary_span]
1991 pub span: Span,
1992 pub eii_name: Symbol,
1993 pub expected_kind: &'static str,
1994}
1995
1996#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
EiiDefkindMismatchStaticMutability {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EiiDefkindMismatchStaticMutability {
span: __binding_0, eii_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutability does not match with the definition of`#[{$eii_name}]`")));
;
diag.arg("eii_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1997#[diag("mutability does not match with the definition of`#[{$eii_name}]`")]
1998pub(crate) struct EiiDefkindMismatchStaticMutability {
1999 #[primary_span]
2000 pub span: Span,
2001 pub eii_name: Symbol,
2002}
2003
2004#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
EiiDefkindMismatchStaticSafety {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EiiDefkindMismatchStaticSafety {
span: __binding_0, eii_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("safety does not match with the definition of`#[{$eii_name}]`")));
;
diag.arg("eii_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2005#[diag("safety does not match with the definition of`#[{$eii_name}]`")]
2006pub(crate) struct EiiDefkindMismatchStaticSafety {
2007 #[primary_span]
2008 pub span: Span,
2009 pub eii_name: Symbol,
2010}
2011
2012#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConflictImplDropAndPinDrop {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConflictImplDropAndPinDrop {
span: __binding_0,
drop_span: __binding_1,
pin_drop_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("conflicting implementations of `Drop::drop` and `Drop::pin_drop`")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`drop(&mut self)` implemented here")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`pin_drop(&pin mut self)` implemented here")));
diag
}
}
}
}
};Diagnostic)]
2013#[diag("conflicting implementations of `Drop::drop` and `Drop::pin_drop`")]
2014pub(crate) struct ConflictImplDropAndPinDrop {
2015 #[primary_span]
2016 pub span: Span,
2017 #[label("`drop(&mut self)` implemented here")]
2018 pub drop_span: Span,
2019 #[label("`pin_drop(&pin mut self)` implemented here")]
2020 pub pin_drop_span: Span,
2021}
2022
2023#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for PinV2WithoutPinDrop
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PinV2WithoutPinDrop {
span: __binding_0,
pin_v2_span: __binding_1,
adt_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$adt_name}` must implement `pin_drop`")));
let __code_25 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("fn pin_drop(&pin mut self)"))
})].into_iter();
let __code_26 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("structurally pinned types must keep `Pin`'s safety contract")));
;
diag.arg("adt_name", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implement `pin_drop` instead")),
__code_25, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
if let Some(__binding_1) = __binding_1 {
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$adt_name}` is marked `#[pin_v2]` here")));
}
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `#[pin_v2]` attribute if it is not intended for structurally pinning")),
__code_26, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
2024#[diag("`{$adt_name}` must implement `pin_drop`")]
2025#[help("structurally pinned types must keep `Pin`'s safety contract")]
2026pub(crate) struct PinV2WithoutPinDrop {
2027 #[primary_span]
2028 #[suggestion(
2029 "implement `pin_drop` instead",
2030 code = "fn pin_drop(&pin mut self)",
2031 applicability = "maybe-incorrect"
2032 )]
2033 pub span: Span,
2034 #[note("`{$adt_name}` is marked `#[pin_v2]` here")]
2035 #[suggestion(
2036 "remove the `#[pin_v2]` attribute if it is not intended for structurally pinning",
2037 code = "",
2038 applicability = "maybe-incorrect"
2039 )]
2040 pub pin_v2_span: Option<Span>,
2041 pub adt_name: Symbol,
2042}
2043
2044#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for PinV2OnPacked {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PinV2OnPacked {
span: __binding_0,
pin_v2_span: __binding_1,
adt_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[pin_v2]` types may not have `#[repr(packed)]`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fields of a `#[repr(packed)]` type can be under-aligned, so a structurally pinned field may be moved to a properly aligned location, which `Pin` does not allow")));
;
diag.arg("adt_name", __binding_2);
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$adt_name}` is marked `#[pin_v2]` here")));
}
diag
}
}
}
}
};Diagnostic)]
2045#[diag("`#[pin_v2]` types may not have `#[repr(packed)]`")]
2046#[note(
2047 "fields of a `#[repr(packed)]` type can be under-aligned, so a structurally pinned field may be moved to a properly aligned location, which `Pin` does not allow"
2048)]
2049pub(crate) struct PinV2OnPacked {
2050 #[primary_span]
2051 pub span: Span,
2052 #[note("`{$adt_name}` is marked `#[pin_v2]` here")]
2053 pub pin_v2_span: Option<Span>,
2054 pub adt_name: Symbol,
2055}
2056
2057pub(crate) struct UncoveredTyParam<'tcx> {
2058 pub(crate) param: Ident,
2059 pub(crate) local_ty: Option<Ty<'tcx>>,
2060}
2061
2062impl Diagnostic<'_> for UncoveredTyParam<'_> {
2063 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
2064 let Self { param, local_ty } = self;
2065
2066 let mut diag = Diag::new(dcx, level, "")
2067 .with_span(param.span)
2068 .with_span_label(param.span, "uncovered type parameter");
2069 if diag.is_error() {
2070 diag.code(E0210);
2071 }
2072
2073 let note = "\
2074 implementing a foreign trait is only possible if \
2075 at least one of the types for which it is implemented is local";
2076
2077 if let Some(local_ty) = local_ty {
2078 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("type parameter `{0}` must be covered by another type when it appears before the first local type (`{1}`)",
param, local_ty))
})format!(
2079 "type parameter `{param}` must be covered by another type when \
2080 it appears before the first local type (`{local_ty}`)"
2081 ));
2082
2083 diag.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0},\nand no uncovered type parameters appear before that first local type",
note))
})format!(
2084 "{note},\nand no uncovered type parameters appear before that first local type"
2085 ));
2086 diag.note(
2087 "in this case, 'before' refers to the following order: \
2088 `impl<..> ForeignTrait<T1, ..., Tn> for T0`,\n\
2089 where `T0` is the first and `Tn` is the last",
2090 );
2091 } else {
2092 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("type parameter `{0}` must be used as an argument to some local type (e.g., `MyStruct<{0}>`)",
param))
})format!(
2093 "type parameter `{param}` must be used as an argument to \
2094 some local type (e.g., `MyStruct<{param}>`)"
2095 ));
2096
2097 diag.note(note);
2098 diag.note(
2099 "only traits defined in the current crate can be implemented for a type parameter",
2100 );
2101 }
2102
2103 diag
2104 }
2105}
2106
2107#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ViewedFieldIsAlreadyPartOfTheView {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ViewedFieldIsAlreadyPartOfTheView {
span: __binding_0,
name: __binding_1,
previous_field_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$name}` is already part of the view")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$name}` is declared as viewed here")));
diag
}
}
}
}
};Diagnostic)]
2108#[diag("field `{$name}` is already part of the view")]
2109pub(crate) struct ViewedFieldIsAlreadyPartOfTheView {
2110 #[primary_span]
2111 pub span: Span,
2112 pub name: Symbol,
2113 #[label("field `{$name}` is declared as viewed here")]
2114 pub previous_field_span: Span,
2115}
2116
2117#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
OnlyStructsCanBeViewedNonAdt<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OnlyStructsCanBeViewedNonAdt {
span: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only structs can be viewed")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type `{$ty}` cannot be viewed")));
diag
}
}
}
}
};Diagnostic)]
2118#[diag("only structs can be viewed")]
2119pub(crate) struct OnlyStructsCanBeViewedNonAdt<'tcx> {
2120 #[primary_span]
2121 #[label("type `{$ty}` cannot be viewed")]
2122 pub span: Span,
2123 pub ty: Ty<'tcx>,
2124}
2125
2126#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
OnlyStructsCanBeViewedAdt<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OnlyStructsCanBeViewedAdt {
span: __binding_0,
ty: __binding_1,
article: __binding_2,
kind: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only structs can be viewed")));
;
diag.arg("ty", __binding_1);
diag.arg("article", __binding_2);
diag.arg("kind", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` is {$article} {$kind}, it cannot be viewed")));
diag
}
}
}
}
};Diagnostic)]
2127#[diag("only structs can be viewed")]
2128pub(crate) struct OnlyStructsCanBeViewedAdt<'tcx> {
2129 #[primary_span]
2130 #[label("`{$ty}` is {$article} {$kind}, it cannot be viewed")]
2131 pub span: Span,
2132 pub ty: Ty<'tcx>,
2133 pub article: &'static str,
2134 pub kind: &'static str,
2135}
2136
2137#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
ParamInTyOfConstParam<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ParamInTyOfConstParam { span: __binding_0, ty: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type of const parameters must not depend on other generic parameters")));
diag.code(E0770);
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type `{$ty}` must not depend on other generic parameter")));
diag
}
}
}
}
};Diagnostic)]
2138#[diag("the type of const parameters must not depend on other generic parameters", code = E0770)]
2139pub(crate) struct ParamInTyOfConstParam<'tcx> {
2140 #[primary_span]
2141 #[label("the type `{$ty}` must not depend on other generic parameter")]
2142 pub(crate) span: Span,
2143 pub(crate) ty: Ty<'tcx>,
2144}
2145
2146#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnevaluatedDefaultFieldValue {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnevaluatedDefaultFieldValue {
field: __binding_0,
ty: __binding_1,
struct_start: __binding_2,
padding: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$field}` has a default value that is only checked when a value of `{$ty}` is constructed")));
let __code_27 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}#[expect(unevaluated_default_field_value)]\n",
__binding_3))
})].into_iter();
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("structs and enums with type and const parameters only evaluate their default field values during construction, not eagerly when declared")));
;
diag.arg("field", __binding_0);
diag.arg("ty", __binding_1);
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if this behavior is acceptable, allow the lint and preferably write a test relying on the default value")),
__code_27, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2147#[diag(
2148 "field `{$field}` has a default value that is only checked when a value of `{$ty}` is \
2149 constructed"
2150)]
2151#[help(
2152 "structs and enums with type and const parameters only evaluate their default field values \
2153 during construction, not eagerly when declared"
2154)]
2155pub(crate) struct UnevaluatedDefaultFieldValue {
2156 pub(crate) field: Symbol,
2157 pub(crate) ty: String,
2158 #[suggestion(
2159 "if this behavior is acceptable, allow the lint and preferably write a test relying on the default value",
2160 code = "{padding}#[expect(unevaluated_default_field_value)]\n",
2161 applicability = "maybe-incorrect"
2162 )]
2163 pub(crate) struct_start: Span,
2164 pub(crate) padding: String,
2165}