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: Span,
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]
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
CoerceSharedNotSingleLifetimeParam {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedNotSingleLifetimeParam {
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 that a single lifetime parameter is passed between source and target")));
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1359#[diag(
1360 "implementing `{$trait_name}` requires that a single lifetime parameter is passed between source and target"
1361)]
1362pub(crate) struct CoerceSharedNotSingleLifetimeParam {
1363 #[primary_span]
1364 pub span: Span,
1365 pub trait_name: &'static str,
1366}
1367
1368#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CoerceSharedMulti {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedMulti {
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 exactly one lifetime argument in the reborrowed type")));
;
diag.arg("trait_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1369#[diag(
1370 "implementing `{$trait_name}` requires exactly one lifetime argument in the reborrowed type"
1371)]
1372pub(crate) struct CoerceSharedMulti {
1373 #[primary_span]
1374 pub span: Span,
1375 pub trait_name: &'static str,
1376}
1377
1378#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CoerceSharedLifetimeMismatch {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CoerceSharedLifetimeMismatch {
span: __binding_0,
source_lifetime_span: __binding_1,
target_lifetime_span: __binding_2,
trait_name: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `{$trait_name}` requires source and target to use the same reborrow lifetime argument")));
;
diag.arg("trait_name", __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("source reborrow lifetime")));
}
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("target reborrow lifetime")));
}
diag
}
}
}
}
};Diagnostic)]
1379#[diag(
1380 "implementing `{$trait_name}` requires source and target to use the same reborrow lifetime \
1381 argument"
1382)]
1383pub(crate) struct CoerceSharedLifetimeMismatch {
1384 #[primary_span]
1385 pub span: Span,
1386 #[label("source reborrow lifetime")]
1387 pub source_lifetime_span: Option<Span>,
1388 #[label("target reborrow lifetime")]
1389 pub target_lifetime_span: Option<Span>,
1390 pub trait_name: &'static str,
1391}
1392
1393#[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)]
1394#[diag(
1395 "implementing `{$trait_name}` requires corresponding fields to match, \
1396 be reborrowable with `CoerceShared`, or coerce a mutable reference field \
1397 to a shared reference field"
1398)]
1399pub(crate) struct CoerceSharedFieldMismatch<'tcx> {
1400 #[primary_span]
1401 #[label("target field `{$target_name}` has type `{$target_ty}`")]
1402 pub span: Span,
1403 #[label("source field `{$source_name}` has type `{$source_ty}`")]
1404 pub source_span: Span,
1405 #[label("required by this `CoerceShared` implementation")]
1406 pub impl_span: Span,
1407 pub source_name: Symbol,
1408 pub source_ty: Ty<'tcx>,
1409 pub target_name: Symbol,
1410 pub target_ty: Ty<'tcx>,
1411 pub trait_name: &'static str,
1412}
1413
1414#[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)]
1415#[diag(
1416 "implementing `{$trait_name}` requires every target field to have a corresponding source field"
1417)]
1418pub(crate) struct CoerceSharedMissingField {
1419 #[primary_span]
1420 #[label("target field `{$field_name}` has no corresponding source field")]
1421 pub span: Span,
1422 #[label("source type `{$source_ty_name}` does not contain field `{$field_name}`")]
1423 pub source_ty_span: Span,
1424 pub trait_name: &'static str,
1425 pub source_ty_name: Symbol,
1426 pub field_name: Symbol,
1427}
1428
1429#[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)]
1430#[diag(
1431 "implementing `{$trait_name}` requires source fields omitted from the target to be `Copy` or \
1432 `Reborrow`"
1433)]
1434pub(crate) struct CoerceSharedOmittedSourceFieldNotCopyOrReborrow<'tcx> {
1435 #[primary_span]
1436 #[label("source field `{$field_name}` has type `{$field_ty}`")]
1437 pub span: Span,
1438 #[label("required by this `CoerceShared` implementation")]
1439 pub impl_span: Span,
1440 pub trait_name: &'static str,
1441 pub field_name: Symbol,
1442 pub field_ty: Ty<'tcx>,
1443}
1444
1445#[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)]
1446#[diag(
1447 "implementing `{$trait_name}` requires source and target structs to use the same field style"
1448)]
1449pub(crate) struct CoerceSharedFieldStyleMismatch {
1450 #[primary_span]
1451 pub span: Span,
1452 pub trait_name: &'static str,
1453}
1454
1455#[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)]
1456#[diag(
1457 "implementing `{$trait_name}` requires all {$role} type fields to be accessible from the impl"
1458)]
1459pub(crate) struct CoerceSharedInaccessibleField {
1460 #[primary_span]
1461 pub span: Span,
1462 #[label("{$role} type `{$type_name}` has inaccessible reborrow data fields")]
1463 pub type_span: Span,
1464 pub trait_name: &'static str,
1465 pub role: &'static str,
1466 pub type_name: Symbol,
1467}
1468
1469#[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)]
1470#[diag(
1471 "implementing `{$trait_name}` currently requires source and target to have at most one \
1472 non-ZST reborrow data field"
1473)]
1474#[note(
1475 "this is a temporary restriction until `CoerceShared` lowering supports non-trivially \
1476 memcpy-compatible field layouts"
1477)]
1478pub(crate) struct CoerceSharedMultipleNonZstFields {
1479 #[primary_span]
1480 #[label("in this `CoerceShared` implementation")]
1481 pub span: Span,
1482 #[label("source type has {$source_count} non-ZST reborrow data fields")]
1483 pub source_ty_span: Span,
1484 #[label("target type has {$target_count} non-ZST reborrow data fields")]
1485 pub target_ty_span: Span,
1486 pub trait_name: &'static str,
1487 pub source_count: usize,
1488 pub target_count: usize,
1489}
1490
1491#[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)]
1492#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1493pub(crate) struct CoerceUnsizedNonStruct {
1494 #[primary_span]
1495 pub span: Span,
1496 pub trait_name: &'static str,
1497}
1498
1499#[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)]
1500#[diag("only pattern types with the same pattern can be coerced between each other")]
1501pub(crate) struct CoerceSamePatKind {
1502 #[primary_span]
1503 pub span: Span,
1504 pub trait_name: &'static str,
1505 pub pat_a: String,
1506 pub pat_b: String,
1507}
1508
1509#[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)]
1510#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1511pub(crate) struct CoerceSameStruct {
1512 #[primary_span]
1513 pub span: Span,
1514 pub trait_name: &'static str,
1515 #[note(
1516 "expected coercion between the same definition; expected `{$source_path}`, found `{$target_path}`"
1517 )]
1518 pub note: bool,
1519 pub source_path: String,
1520 pub target_path: String,
1521}
1522
1523#[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)]
1524#[diag(
1525 "for `{$ty}` to have a valid implementation of `{$trait_name}`, it must be possible to coerce the field of type `{$field_ty}`"
1526)]
1527pub(crate) struct CoerceFieldValidity<'tcx> {
1528 #[primary_span]
1529 pub span: Span,
1530 pub ty: Ty<'tcx>,
1531 pub trait_name: &'static str,
1532 #[label(
1533 "`{$field_ty}` must be a pointer, reference, or smart pointer that is allowed to be unsized"
1534 )]
1535 pub field_span: Span,
1536 pub field_ty: Ty<'tcx>,
1537}
1538
1539#[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)]
1540#[diag("the trait `{$trait_name}` cannot be implemented for this type", code = E0204)]
1541pub(crate) struct TraitCannotImplForTy {
1542 #[primary_span]
1543 pub span: Span,
1544 pub trait_name: String,
1545 #[label("this field does not implement `{$trait_name}`")]
1546 pub label_spans: Vec<Span>,
1547 #[subdiagnostic]
1548 pub notes: Vec<ImplForTyRequires>,
1549}
1550
1551#[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)]
1552#[note("the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`")]
1553pub(crate) struct ImplForTyRequires {
1554 #[primary_span]
1555 pub span: MultiSpan,
1556 pub error_predicate: String,
1557 pub trait_name: String,
1558 pub ty: String,
1559}
1560
1561#[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)]
1562#[diag("traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`", code = E0321)]
1563#[note(
1564 "a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds"
1565)]
1566pub(crate) struct TraitsWithDefaultImpl<'a> {
1567 #[primary_span]
1568 pub span: Span,
1569 pub traits: String,
1570 pub problematic_kind: &'a str,
1571 pub self_ty: Ty<'a>,
1572}
1573
1574#[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)]
1575#[diag("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`", code = E0321)]
1576pub(crate) struct CrossCrateTraits<'a> {
1577 #[primary_span]
1578 #[label("can't implement cross-crate trait with a default impl for non-struct/enum type")]
1579 pub span: Span,
1580 pub traits: String,
1581 pub self_ty: Ty<'a>,
1582}
1583
1584#[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)]
1585#[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)]
1586pub(crate) struct CrossCrateTraitsDefined {
1587 #[primary_span]
1588 #[label("can't implement cross-crate trait for type in another crate")]
1589 pub span: Span,
1590 pub traits: String,
1591}
1592
1593#[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)]
1594#[diag("no variant named `{$ident}` found for enum `{$ty}`", code = E0599)]
1595pub struct NoVariantNamed<'tcx> {
1596 #[primary_span]
1597 pub span: Span,
1598 pub ident: Ident,
1599 pub ty: Ty<'tcx>,
1600}
1601
1602#[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)]
1603#[diag("no field `{$field}` on type `{$ty}`", code = E0609)]
1604pub struct NoFieldOnType<'tcx> {
1605 #[primary_span]
1606 pub span: Span,
1607 pub ty: Ty<'tcx>,
1608 pub field: Ident,
1609}
1610
1611#[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)]
1612pub(crate) enum OnlyCurrentTraits {
1613 #[diag("only traits defined in the current crate can be implemented for types defined outside of the crate", code = E0117)]
1614 Outside {
1615 #[primary_span]
1616 span: Span,
1617 #[note("impl doesn't have any local type before any uncovered type parameters")]
1618 #[note(
1619 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1620 )]
1621 #[note("define and implement a trait or new type instead")]
1622 note: (),
1623 },
1624 #[diag("only traits defined in the current crate can be implemented for primitive types", code = E0117)]
1625 Primitive {
1626 #[primary_span]
1627 span: Span,
1628 #[note("impl doesn't have any local type before any uncovered type parameters")]
1629 #[note(
1630 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1631 )]
1632 #[note("define and implement a trait or new type instead")]
1633 note: (),
1634 },
1635 #[diag("only traits defined in the current crate can be implemented for arbitrary types", code = E0117)]
1636 Arbitrary {
1637 #[primary_span]
1638 span: Span,
1639 #[note("impl doesn't have any local type before any uncovered type parameters")]
1640 #[note(
1641 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1642 )]
1643 #[note("define and implement a trait or new type instead")]
1644 note: (),
1645 },
1646}
1647
1648#[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)]
1649#[label(
1650 "type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate"
1651)]
1652pub(crate) struct OnlyCurrentTraitsOpaque {
1653 #[primary_span]
1654 pub span: Span,
1655}
1656#[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)]
1657#[label("this is not defined in the current crate because this is a foreign trait")]
1658pub(crate) struct OnlyCurrentTraitsForeign {
1659 #[primary_span]
1660 pub span: Span,
1661}
1662
1663#[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)]
1664#[label("this is not defined in the current crate because {$name} are always foreign")]
1665pub(crate) struct OnlyCurrentTraitsName<'a> {
1666 #[primary_span]
1667 pub span: Span,
1668 pub name: &'a str,
1669}
1670
1671#[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)]
1672#[label("`{$pointer}` is not defined in the current crate because raw pointers are always foreign")]
1673pub(crate) struct OnlyCurrentTraitsPointer<'a> {
1674 #[primary_span]
1675 pub span: Span,
1676 pub pointer: Ty<'a>,
1677}
1678
1679#[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)]
1680#[label("`{$ty}` is not defined in the current crate")]
1681pub(crate) struct OnlyCurrentTraitsTy<'a> {
1682 #[primary_span]
1683 pub span: Span,
1684 pub ty: Ty<'a>,
1685}
1686
1687#[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)]
1688#[label("`{$name}` is not defined in the current crate")]
1689pub(crate) struct OnlyCurrentTraitsAdt {
1690 #[primary_span]
1691 pub span: Span,
1692 pub name: String,
1693}
1694
1695#[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)]
1696#[multipart_suggestion(
1697 "consider introducing a new wrapper type",
1698 applicability = "maybe-incorrect"
1699)]
1700pub(crate) struct OnlyCurrentTraitsPointerSugg<'a> {
1701 #[suggestion_part(code = "WrapperType")]
1702 pub wrapper_span: Span,
1703 #[suggestion_part(code = "struct WrapperType(*{mut_key}{ptr_ty});\n\n")]
1704 pub(crate) struct_span: Span,
1705 pub mut_key: &'a str,
1706 pub ptr_ty: Ty<'a>,
1707}
1708
1709#[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)]
1710#[diag("{$descr}")]
1711pub(crate) struct UnsupportedDelegation<'a> {
1712 #[primary_span]
1713 pub span: Span,
1714 pub descr: &'a str,
1715 #[label("callee defined here")]
1716 pub callee_span: Span,
1717}
1718
1719#[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)]
1720#[diag("inferred lifetimes are not allowed in delegations as we need to inherit signature")]
1721pub(crate) struct ElidedLifetimesAreNotAllowedInDelegations {
1722 #[primary_span]
1723 pub span: Span,
1724}
1725
1726#[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)]
1727#[diag("method should be `async` or return a future, but it is synchronous")]
1728pub(crate) struct MethodShouldReturnFuture {
1729 #[primary_span]
1730 pub span: Span,
1731 pub method_name: Ident,
1732 #[note("this method is `async` so it expects a future to be returned")]
1733 pub trait_item_span: Option<Span>,
1734}
1735
1736#[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 likely unused in the containing type")));
}
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)]
1737#[diag("{$param_def_kind} `{$param_name}` is never used")]
1738pub(crate) struct UnusedGenericParameter {
1739 #[primary_span]
1740 #[label("unused {$param_def_kind}")]
1741 pub span: Span,
1742 pub param_name: Ident,
1743 pub param_def_kind: &'static str,
1744 #[label("`{$param_name}` is named here, but is likely unused in the containing type")]
1745 pub usage_spans: Vec<Span>,
1746 #[subdiagnostic]
1747 pub help: UnusedGenericParameterHelp,
1748 #[help(
1749 "if you intended `{$param_name}` to be a const parameter, use `const {$param_name}: /* Type */` instead"
1750 )]
1751 pub const_param_help: bool,
1752}
1753
1754#[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)]
1755#[diag("{$param_def_kind} `{$param_name}` is only used recursively")]
1756pub(crate) struct RecursiveGenericParameter {
1757 #[primary_span]
1758 pub spans: Vec<Span>,
1759 #[label("{$param_def_kind} must be used non-recursively in the definition")]
1760 pub param_span: Span,
1761 pub param_name: Ident,
1762 pub param_def_kind: &'static str,
1763 #[subdiagnostic]
1764 pub help: UnusedGenericParameterHelp,
1765 #[note(
1766 "all type parameters must be used in a non-recursive way in order to constrain their variance"
1767 )]
1768 pub note: (),
1769}
1770
1771#[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)]
1772pub(crate) enum UnusedGenericParameterHelp {
1773 #[help(
1774 "consider removing `{$param_name}`, referring to it in a field, or using a marker such as `{$phantom_data}`"
1775 )]
1776 Adt { param_name: Ident, phantom_data: String },
1777 #[help("consider removing `{$param_name}` or referring to it in a field")]
1778 AdtNoPhantomData { param_name: Ident },
1779 #[help("consider removing `{$param_name}` or referring to it in the body of the type alias")]
1780 TyAlias { param_name: Ident },
1781}
1782
1783#[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)]
1784#[diag(
1785 "the {$param_def_kind} `{$param_name}` is not constrained by the impl trait, self type, or predicates"
1786)]
1787pub(crate) struct UnconstrainedGenericParameter {
1788 #[primary_span]
1789 #[label("unconstrained {$param_def_kind}")]
1790 pub span: Span,
1791 pub param_name: Ident,
1792 pub param_def_kind: &'static str,
1793 #[note("expressions using a const parameter must map each value to a distinct output value")]
1794 pub const_param_note: bool,
1795 #[note(
1796 "proving the result of expressions other than the parameter are unique is not supported"
1797 )]
1798 pub const_param_note2: bool,
1799}
1800
1801#[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)]
1802#[diag("`impl Trait` cannot capture {$bad_place}", code = E0657)]
1803pub(crate) struct OpaqueCapturesHigherRankedLifetime {
1804 #[primary_span]
1805 pub span: MultiSpan,
1806 #[label("`impl Trait` implicitly captures all lifetimes in scope")]
1807 pub label: Option<Span>,
1808 #[note("lifetime declared here")]
1809 pub decl_span: MultiSpan,
1810 pub bad_place: &'static str,
1811}
1812
1813#[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)]
1814pub(crate) enum InvalidReceiverTyHint {
1815 #[note(
1816 "`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`"
1817 )]
1818 Weak,
1819 #[note(
1820 "`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`"
1821 )]
1822 NonNull,
1823}
1824
1825#[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)]
1826#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1827#[note("type of `self` must be `Self` or a type that dereferences to it")]
1828#[help(
1829 "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`)"
1830)]
1831pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
1832 #[primary_span]
1833 pub span: Span,
1834 pub receiver_ty: Ty<'tcx>,
1835}
1836
1837#[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)]
1838#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1839#[note("type of `self` must be `Self` or some type implementing `Receiver`")]
1840#[help(
1841 "consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`"
1842)]
1843pub(crate) struct InvalidReceiverTy<'tcx> {
1844 #[primary_span]
1845 pub span: Span,
1846 pub receiver_ty: Ty<'tcx>,
1847 #[subdiagnostic]
1848 pub hint: Option<InvalidReceiverTyHint>,
1849}
1850
1851#[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)]
1852#[diag("invalid generic `self` parameter type: `{$receiver_ty}`", code = E0801)]
1853#[note("type of `self` must not be a method generic parameter type")]
1854#[help(
1855 "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`)"
1856)]
1857pub(crate) struct InvalidGenericReceiverTy<'tcx> {
1858 #[primary_span]
1859 pub span: Span,
1860 pub receiver_ty: Ty<'tcx>,
1861}
1862
1863#[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)]
1864#[diag("arguments for `{$abi}` function too large to pass via registers", code = E0798)]
1865#[note(
1866 "functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit argument registers"
1867)]
1868pub(crate) struct CmseInputsStackSpill {
1869 #[primary_span]
1870 #[label("does not fit in the available registers")]
1871 pub spans: Vec<Span>,
1872 pub abi: ExternAbi,
1873}
1874
1875#[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)]
1876#[diag("return value of `{$abi}` function too large to pass via registers", code = E0798)]
1877#[note("functions with the `{$abi}` ABI must pass their result via the available return registers")]
1878#[note(
1879 "the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size"
1880)]
1881pub(crate) struct CmseOutputStackSpill {
1882 #[primary_span]
1883 #[label("this type doesn't fit in the available registers")]
1884 pub span: Span,
1885 pub abi: ExternAbi,
1886}
1887
1888#[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)]
1889#[diag("generics are not allowed in `extern {$abi}` signatures", code = E0798)]
1890pub(crate) struct CmseGeneric {
1891 #[primary_span]
1892 pub span: Span,
1893 pub abi: ExternAbi,
1894}
1895
1896#[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)]
1897#[diag("`impl Trait` is not allowed in `extern {$abi}` signatures", code = E0798)]
1898pub(crate) struct CmseImplTrait {
1899 #[primary_span]
1900 pub span: Span,
1901 pub abi: ExternAbi,
1902}
1903
1904#[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)]
1905#[diag("return type notation not allowed in this position yet")]
1906pub(crate) struct BadReturnTypeNotation {
1907 #[primary_span]
1908 pub span: Span,
1909 #[suggestion(
1910 "furthermore, argument types not allowed with return type notation",
1911 applicability = "maybe-incorrect",
1912 code = "(..)",
1913 style = "verbose"
1914 )]
1915 pub suggestion: Option<Span>,
1916}
1917
1918#[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)]
1919#[diag("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")]
1920pub(crate) struct SupertraitItemShadowing {
1921 pub item: Symbol,
1922 pub subtrait: Symbol,
1923 #[subdiagnostic]
1924 pub shadowee: SupertraitItemShadowee,
1925}
1926
1927#[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)]
1928pub(crate) enum SupertraitItemShadowee {
1929 #[note("item from `{$supertrait}` is shadowed by a subtrait item")]
1930 Labeled {
1931 #[primary_span]
1932 span: Span,
1933 supertrait: Symbol,
1934 },
1935 #[note("items from several supertraits are shadowed: {$traits}")]
1936 Several {
1937 #[primary_span]
1938 spans: MultiSpan,
1939 traits: DiagSymbolList,
1940 },
1941}
1942
1943#[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)]
1944#[diag("{$kind} binding in trait object type mentions `Self`")]
1945pub(crate) struct DynTraitAssocItemBindingMentionsSelf {
1946 #[primary_span]
1947 #[label("contains a mention of `Self`")]
1948 pub span: Span,
1949 pub kind: &'static str,
1950 #[label("this binding mentions `Self`")]
1951 pub binding: Span,
1952}
1953
1954#[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)]
1955#[diag("`AsyncDrop` impl without `Drop` impl")]
1956#[help(
1957 "type implementing `AsyncDrop` trait must also implement `Drop` trait to be used in sync context and unwinds"
1958)]
1959pub(crate) struct AsyncDropWithoutSyncDrop {
1960 #[primary_span]
1961 pub span: Span,
1962}
1963
1964#[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)]
1965#[diag("lifetime parameters or bounds of `{$ident}` do not match the declaration")]
1966pub(crate) struct LifetimesOrBoundsMismatchOnEii {
1967 #[primary_span]
1968 #[label("lifetimes do not match")]
1969 pub span: Span,
1970 #[label("lifetimes in impl do not match this signature")]
1971 pub generics_span: Span,
1972 #[label("this `where` clause might not match the one in the trait")]
1973 pub where_span: Option<Span>,
1974 #[label("this bound might be missing in the impl")]
1975 pub bounds_span: Vec<Span>,
1976 pub ident: Symbol,
1977}
1978
1979#[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)]
1980#[diag("`{$impl_name}` cannot have generic parameters other than lifetimes")]
1981#[help("`#[{$eii_name}]` marks the implementation of an \"externally implementable item\"")]
1982pub(crate) struct EiiWithGenerics {
1983 #[primary_span]
1984 pub span: Span,
1985 #[label("required by this attribute")]
1986 pub attr: Span,
1987 pub eii_name: Symbol,
1988 pub impl_name: Symbol,
1989}
1990
1991#[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)]
1992#[diag("explicit impls for the `Unpin` trait are not permitted for structurally pinned types")]
1993pub(crate) struct ImplUnpinForPinProjectedType {
1994 #[primary_span]
1995 #[label("impl of `Unpin` not allowed")]
1996 pub span: Span,
1997 #[help("`{$adt_name}` is structurally pinned because it is marked as `#[pin_v2]`")]
1998 pub adt_span: Span,
1999 pub adt_name: Symbol,
2000}
2001
2002#[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)]
2003#[diag("`#[{$eii_name}]` must be used on a {$expected_kind}")]
2004pub(crate) struct EiiDefkindMismatch {
2005 #[primary_span]
2006 pub span: Span,
2007 pub eii_name: Symbol,
2008 pub expected_kind: &'static str,
2009}
2010
2011#[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)]
2012#[diag("mutability does not match with the definition of`#[{$eii_name}]`")]
2013pub(crate) struct EiiDefkindMismatchStaticMutability {
2014 #[primary_span]
2015 pub span: Span,
2016 pub eii_name: Symbol,
2017}
2018
2019#[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)]
2020#[diag("safety does not match with the definition of`#[{$eii_name}]`")]
2021pub(crate) struct EiiDefkindMismatchStaticSafety {
2022 #[primary_span]
2023 pub span: Span,
2024 pub eii_name: Symbol,
2025}
2026
2027#[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)]
2028#[diag("conflicting implementations of `Drop::drop` and `Drop::pin_drop`")]
2029pub(crate) struct ConflictImplDropAndPinDrop {
2030 #[primary_span]
2031 pub span: Span,
2032 #[label("`drop(&mut self)` implemented here")]
2033 pub drop_span: Span,
2034 #[label("`pin_drop(&pin mut self)` implemented here")]
2035 pub pin_drop_span: Span,
2036}
2037
2038#[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)]
2039#[diag("`{$adt_name}` must implement `pin_drop`")]
2040#[help("structurally pinned types must keep `Pin`'s safety contract")]
2041pub(crate) struct PinV2WithoutPinDrop {
2042 #[primary_span]
2043 #[suggestion(
2044 "implement `pin_drop` instead",
2045 code = "fn pin_drop(&pin mut self)",
2046 applicability = "maybe-incorrect"
2047 )]
2048 pub span: Span,
2049 #[note("`{$adt_name}` is marked `#[pin_v2]` here")]
2050 #[suggestion(
2051 "remove the `#[pin_v2]` attribute if it is not intended for structurally pinning",
2052 code = "",
2053 applicability = "maybe-incorrect"
2054 )]
2055 pub pin_v2_span: Option<Span>,
2056 pub adt_name: Symbol,
2057}
2058
2059#[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)]
2060#[diag("`#[pin_v2]` types may not have `#[repr(packed)]`")]
2061#[note(
2062 "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"
2063)]
2064pub(crate) struct PinV2OnPacked {
2065 #[primary_span]
2066 pub span: Span,
2067 #[note("`{$adt_name}` is marked `#[pin_v2]` here")]
2068 pub pin_v2_span: Option<Span>,
2069 pub adt_name: Symbol,
2070}
2071
2072pub(crate) struct UncoveredTyParam<'tcx> {
2073 pub(crate) param: Ident,
2074 pub(crate) local_ty: Option<Ty<'tcx>>,
2075}
2076
2077impl Diagnostic<'_> for UncoveredTyParam<'_> {
2078 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
2079 let Self { param, local_ty } = self;
2080
2081 let mut diag = Diag::new(dcx, level, "")
2082 .with_span(param.span)
2083 .with_span_label(param.span, "uncovered type parameter");
2084 if diag.is_error() {
2085 diag.code(E0210);
2086 }
2087
2088 let note = "\
2089 implementing a foreign trait is only possible if \
2090 at least one of the types for which it is implemented is local";
2091
2092 if let Some(local_ty) = local_ty {
2093 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!(
2094 "type parameter `{param}` must be covered by another type when \
2095 it appears before the first local type (`{local_ty}`)"
2096 ));
2097
2098 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!(
2099 "{note},\nand no uncovered type parameters appear before that first local type"
2100 ));
2101 diag.note(
2102 "in this case, 'before' refers to the following order: \
2103 `impl<..> ForeignTrait<T1, ..., Tn> for T0`,\n\
2104 where `T0` is the first and `Tn` is the last",
2105 );
2106 } else {
2107 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!(
2108 "type parameter `{param}` must be used as an argument to \
2109 some local type (e.g., `MyStruct<{param}>`)"
2110 ));
2111
2112 diag.note(note);
2113 diag.note(
2114 "only traits defined in the current crate can be implemented for a type parameter",
2115 );
2116 }
2117
2118 diag
2119 }
2120}
2121
2122#[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)]
2123#[diag("field `{$name}` is already part of the view")]
2124pub(crate) struct ViewedFieldIsAlreadyPartOfTheView {
2125 #[primary_span]
2126 pub span: Span,
2127 pub name: Symbol,
2128 #[label("field `{$name}` is declared as viewed here")]
2129 pub previous_field_span: Span,
2130}
2131
2132#[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)]
2133#[diag("only structs can be viewed")]
2134pub(crate) struct OnlyStructsCanBeViewedNonAdt<'tcx> {
2135 #[primary_span]
2136 #[label("type `{$ty}` cannot be viewed")]
2137 pub span: Span,
2138 pub ty: Ty<'tcx>,
2139}
2140
2141#[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)]
2142#[diag("only structs can be viewed")]
2143pub(crate) struct OnlyStructsCanBeViewedAdt<'tcx> {
2144 #[primary_span]
2145 #[label("`{$ty}` is {$article} {$kind}, it cannot be viewed")]
2146 pub span: Span,
2147 pub ty: Ty<'tcx>,
2148 pub article: &'static str,
2149 pub kind: &'static str,
2150}
2151
2152#[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)]
2153#[diag("the type of const parameters must not depend on other generic parameters", code = E0770)]
2154pub(crate) struct ParamInTyOfConstParam<'tcx> {
2155 #[primary_span]
2156 #[label("the type `{$ty}` must not depend on other generic parameter")]
2157 pub(crate) span: Span,
2158 pub(crate) ty: Ty<'tcx>,
2159}