1//! Errors emitted by `rustc_hir_analysis`.
23use rustc_abi::ExternAbi;
4use rustc_errors::codes::*;
5use rustc_errors::{
6Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
7MultiSpan, inline_fluent, listify,
8};
9use rustc_hir::limit::Limit;
10use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
11use rustc_middle::ty::{self, Ty};
12use rustc_span::{Ident, Span, Symbol};
13pub(crate) mod wrong_number_of_generic_args;
1415mod precise_captures;
16pub(crate) use precise_captures::*;
1718#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
AmbiguousAssocItem<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
19#[diag("ambiguous associated {$assoc_kind} `{$assoc_ident}` in bounds of `{$qself}`")]
20pub(crate) struct AmbiguousAssocItem<'a> {
21#[primary_span]
22 #[label("ambiguous associated {$assoc_kind} `{$assoc_ident}`")]
23pub span: Span,
24pub assoc_kind: &'static str,
25pub assoc_ident: Ident,
26pub qself: &'a str,
27}
2829#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssocKindMismatch where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AssocKindMismatch {
span: __binding_0,
expected: __binding_1,
got: __binding_2,
expected_because_label: __binding_3,
assoc_kind: __binding_4,
def_span: __binding_5,
bound_on_assoc_const_label: __binding_6,
wrap_in_braces_sugg: __binding_7 } => {
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_1);
diag.arg("got", __binding_2);
diag.arg("assoc_kind", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected {$got}")));
if let Some(__binding_3) = __binding_3 {
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a {$expected} because of this associated {$expected}")));
}
diag.span_note(__binding_5,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the associated {$assoc_kind} is defined here")));
if let Some(__binding_6) = __binding_6 {
diag.span_label(__binding_6,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds are not allowed on associated constants")));
}
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
diag
}
}
}
}
};Diagnostic)]
30#[diag("expected {$expected}, found {$got}")]
31pub(crate) struct AssocKindMismatch {
32#[primary_span]
33 #[label("unexpected {$got}")]
34pub span: Span,
35pub expected: &'static str,
36pub got: &'static str,
37#[label("expected a {$expected} because of this associated {$expected}")]
38pub expected_because_label: Option<Span>,
39pub assoc_kind: &'static str,
40#[note("the associated {$assoc_kind} is defined here")]
41pub def_span: Span,
42#[label("bounds are not allowed on associated constants")]
43pub bound_on_assoc_const_label: Option<Span>,
44#[subdiagnostic]
45pub wrap_in_braces_sugg: Option<AssocKindMismatchWrapInBracesSugg>,
46}
4748#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AssocKindMismatchWrapInBracesSugg
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding braces here")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
49#[multipart_suggestion("consider adding braces here", applicability = "maybe-incorrect")]
50pub(crate) struct AssocKindMismatchWrapInBracesSugg {
51#[suggestion_part(code = "{{ ")]
52pub lo: Span,
53#[suggestion_part(code = " }}")]
54pub hi: Span,
55}
5657#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssocItemIsPrivate where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
58#[diag("{$kind} `{$name}` is private", code = E0624)]
59pub(crate) struct AssocItemIsPrivate {
60#[primary_span]
61 #[label("private {$kind}")]
62pub span: Span,
63pub kind: &'static str,
64pub name: Ident,
65#[label("the {$kind} is defined here")]
66pub defined_here_label: Span,
67}
6869#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
AssocItemNotFound<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
70#[diag("associated {$assoc_kind} `{$assoc_ident}` not found for `{$qself}`", code = E0220)]
71pub(crate) struct AssocItemNotFound<'a> {
72#[primary_span]
73pub span: Span,
74pub assoc_ident: Ident,
75pub assoc_kind: &'static str,
76pub qself: &'a str,
77#[subdiagnostic]
78pub label: Option<AssocItemNotFoundLabel<'a>>,
79#[subdiagnostic]
80pub sugg: Option<AssocItemNotFoundSugg<'a>>,
81#[label("due to this macro variable")]
82pub within_macro_span: Option<Span>,
83}
8485#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for AssocItemNotFoundLabel<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AssocItemNotFoundLabel::NotFound { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated {$assoc_kind} `{$assoc_ident}` not found")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
AssocItemNotFoundLabel::FoundInOtherTrait {
span: __binding_0,
assoc_kind: __binding_1,
trait_name: __binding_2,
suggested_name: __binding_3,
identically_named: __binding_4 } => {
diag.store_args();
diag.arg("assoc_kind", __binding_1);
diag.arg("trait_name", __binding_2);
diag.arg("suggested_name", __binding_3);
diag.arg("identically_named", __binding_4);
let __message =
diag.eagerly_translate(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}`")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
86pub(crate) enum AssocItemNotFoundLabel<'a> {
87#[label("associated {$assoc_kind} `{$assoc_ident}` not found")]
88NotFound {
89#[primary_span]
90span: Span,
91 },
92#[label(
93"there is {$identically_named ->
94 [true] an
95 *[false] a similarly named
96 } associated {$assoc_kind} `{$suggested_name}` in the trait `{$trait_name}`"
97)]
98FoundInOtherTrait {
99#[primary_span]
100span: Span,
101 assoc_kind: &'static str,
102 trait_name: &'a str,
103 suggested_name: Symbol,
104 identically_named: bool,
105 },
106}
107108#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for AssocItemNotFoundSugg<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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();
diag.store_args();
diag.arg("assoc_kind", __binding_1);
diag.arg("suggested_name", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated {$assoc_kind} with a similar name")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
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();
diag.store_args();
diag.arg("trait_name", __binding_1);
diag.arg("assoc_kind", __binding_2);
diag.arg("suggested_name", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("change the associated {$assoc_kind} name to use `{$suggested_name}` from `{$trait_name}`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_3, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
AssocItemNotFoundSugg::SimilarInOtherTraitQPath {
lo: __binding_0,
mi: __binding_1,
hi: __binding_2,
trait_ref: __binding_3,
suggested_name: __binding_4,
identically_named: __binding_5,
applicability: __binding_6 } => {
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));
}
diag.store_args();
diag.arg("trait_ref", __binding_3);
diag.arg("suggested_name", __binding_4);
diag.arg("identically_named", __binding_5);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider fully qualifying{$identically_named ->\n [true] {\"\"}\n *[false] {\" \"}and renaming\n } the associated {$assoc_kind}")));
diag.multipart_suggestion_with_style(__message, suggestions,
__binding_6, rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
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();
diag.store_args();
diag.arg("qself", __binding_1);
diag.arg("assoc_kind", __binding_2);
diag.arg("suggested_name", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$qself}` has the following associated {$assoc_kind}")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_7, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
109110pub(crate) enum AssocItemNotFoundSugg<'a> {
111#[suggestion(
112"there is an associated {$assoc_kind} with a similar name",
113 code = "{suggested_name}",
114 applicability = "maybe-incorrect"
115)]
116Similar {
117#[primary_span]
118span: Span,
119 assoc_kind: &'static str,
120 suggested_name: Symbol,
121 },
122#[suggestion(
123"change the associated {$assoc_kind} name to use `{$suggested_name}` from `{$trait_name}`",
124 code = "{suggested_name}",
125 style = "verbose",
126 applicability = "maybe-incorrect"
127)]
128SimilarInOtherTrait {
129#[primary_span]
130span: Span,
131 trait_name: &'a str,
132 assoc_kind: &'static str,
133 suggested_name: Symbol,
134 },
135#[multipart_suggestion(
136"consider fully qualifying{$identically_named ->
137 [true] {\"\"}
138 *[false] {\" \"}and renaming
139 } the associated {$assoc_kind}",
140 style = "verbose"
141)]
142SimilarInOtherTraitQPath {
143#[suggestion_part(code = "<")]
144lo: Span,
145#[suggestion_part(code = " as {trait_ref}>")]
146mi: Span,
147#[suggestion_part(code = "{suggested_name}")]
148hi: Option<Span>,
149 trait_ref: String,
150 suggested_name: Symbol,
151 identically_named: bool,
152#[applicability]
153applicability: Applicability,
154 },
155#[suggestion(
156"`{$qself}` has the following associated {$assoc_kind}",
157 code = "{suggested_name}",
158 applicability = "maybe-incorrect"
159)]
160Other {
161#[primary_span]
162span: Span,
163 qself: &'a str,
164 assoc_kind: &'static str,
165 suggested_name: Symbol,
166 },
167}
168169#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
WrongNumberOfGenericArgumentsToIntrinsic<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
170#[diag("intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}", code = E0094)]
171pub(crate) struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
172#[primary_span]
173 #[label(
174"expected {$expected} {$descr} {$expected ->
175 [one] parameter
176 *[other] parameters
177 }"
178)]
179pub span: Span,
180pub found: usize,
181pub expected: usize,
182pub descr: &'a str,
183}
184185#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnrecognizedIntrinsicFunction where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
186#[diag("unrecognized intrinsic function: `{$name}`", code = E0093)]
187#[help("if you're adding an intrinsic, be sure to update `check_intrinsic_type`")]
188pub(crate) struct UnrecognizedIntrinsicFunction {
189#[primary_span]
190 #[label("unrecognized intrinsic")]
191pub span: Span,
192pub name: Symbol,
193}
194195#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimesOrBoundsMismatchOnTrait where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
196#[diag("lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration", code = E0195)]
197pub(crate) struct LifetimesOrBoundsMismatchOnTrait {
198#[primary_span]
199 #[label("lifetimes do not match {$item_kind} in trait")]
200pub span: Span,
201#[label("lifetimes in impl do not match this {$item_kind} in trait")]
202pub generics_span: Span,
203#[label("this `where` clause might not match the one in the trait")]
204pub where_span: Option<Span>,
205#[label("this bound might be missing in the impl")]
206pub bounds_span: Vec<Span>,
207pub item_kind: &'static str,
208pub ident: Ident,
209}
210211#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DropImplOnWrongItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
212#[diag("the `{$trait_}` trait may only be implemented for local structs, enums, and unions", code = E0120)]
213pub(crate) struct DropImplOnWrongItem {
214#[primary_span]
215 #[label("must be a struct, enum, or union in the current crate")]
216pub span: Span,
217pub trait_: Symbol,
218}
219220#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FieldAlreadyDeclared where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
221pub(crate) enum FieldAlreadyDeclared {
222#[diag("field `{$field_name}` is already declared", code = E0124)]
223NotNested {
224 field_name: Ident,
225#[primary_span]
226 #[label("field already declared")]
227span: Span,
228#[label("`{$field_name}` first declared here")]
229prev_span: Span,
230 },
231#[diag("field `{$field_name}` is already declared")]
232CurrentNested {
233 field_name: Ident,
234#[primary_span]
235 #[label("field `{$field_name}` declared in this unnamed field")]
236span: Span,
237#[note("field `{$field_name}` declared here")]
238nested_field_span: Span,
239#[subdiagnostic]
240help: FieldAlreadyDeclaredNestedHelp,
241#[label("`{$field_name}` first declared here")]
242prev_span: Span,
243 },
244#[diag("field `{$field_name}` is already declared")]
245PreviousNested {
246 field_name: Ident,
247#[primary_span]
248 #[label("field already declared")]
249span: Span,
250#[label("`{$field_name}` first declared here in this unnamed field")]
251prev_span: Span,
252#[note("field `{$field_name}` first declared here")]
253prev_nested_field_span: Span,
254#[subdiagnostic]
255prev_help: FieldAlreadyDeclaredNestedHelp,
256 },
257#[diag("field `{$field_name}` is already declared")]
258BothNested {
259 field_name: Ident,
260#[primary_span]
261 #[label("field `{$field_name}` declared in this unnamed field")]
262span: Span,
263#[note("field `{$field_name}` declared here")]
264nested_field_span: Span,
265#[subdiagnostic]
266help: FieldAlreadyDeclaredNestedHelp,
267#[label("`{$field_name}` first declared here in this unnamed field")]
268prev_span: Span,
269#[note("field `{$field_name}` first declared here")]
270prev_nested_field_span: Span,
271#[subdiagnostic]
272prev_help: FieldAlreadyDeclaredNestedHelp,
273 },
274}
275276#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FieldAlreadyDeclaredNestedHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FieldAlreadyDeclaredNestedHelp { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fields from the type of this unnamed field are considered fields of the outer type")));
diag.span_help(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
277#[help("fields from the type of this unnamed field are considered fields of the outer type")]
278pub(crate) struct FieldAlreadyDeclaredNestedHelp {
279#[primary_span]
280pub span: Span,
281}
282283#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CopyImplOnTypeWithDtor where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CopyImplOnTypeWithDtor {
span: __binding_0, impl_: __binding_1 } => {
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; the type has a destructor")));
diag.code(E0184);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Copy` not allowed on types with destructors")));
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("destructor declared here")));
diag
}
}
}
}
};Diagnostic)]
284#[diag("the trait `Copy` cannot be implemented for this type; the type has a destructor", code = E0184)]
285pub(crate) struct CopyImplOnTypeWithDtor {
286#[primary_span]
287 #[label("`Copy` not allowed on types with destructors")]
288pub span: Span,
289#[note("destructor declared here")]
290pub impl_: Span,
291}
292293#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CopyImplOnNonAdt where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
294#[diag("the trait `Copy` cannot be implemented for this type", code = E0206)]
295pub(crate) struct CopyImplOnNonAdt {
296#[primary_span]
297 #[label("type is not a structure or enumeration")]
298pub span: Span,
299}
300301#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstParamTyImplOnUnsized where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
302#[diag("the trait `ConstParamTy` may not be implemented for this type")]
303pub(crate) struct ConstParamTyImplOnUnsized {
304#[primary_span]
305 #[label("type is not `Sized`")]
306pub span: Span,
307}
308309#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstParamTyImplOnNonAdt where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
310#[diag("the trait `ConstParamTy` may not be implemented for this type")]
311pub(crate) struct ConstParamTyImplOnNonAdt {
312#[primary_span]
313 #[label("type is not a structure or enumeration")]
314pub span: Span,
315}
316317#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitObjectDeclaredWithNoTraits where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
318#[diag("at least one trait is required for an object type", code = E0224)]
319pub(crate) struct TraitObjectDeclaredWithNoTraits {
320#[primary_span]
321pub span: Span,
322#[label("this alias does not contain a trait")]
323pub trait_alias_span: Option<Span>,
324}
325326#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AmbiguousLifetimeBound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
327#[diag("ambiguous lifetime bound, explicit lifetime bound required", code = E0227)]
328pub(crate) struct AmbiguousLifetimeBound {
329#[primary_span]
330pub span: Span,
331}
332333#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssocItemConstraintsNotAllowedHere where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
334#[diag("associated item constraints are not allowed here", code = E0229)]
335pub(crate) struct AssocItemConstraintsNotAllowedHere {
336#[primary_span]
337 #[label("associated item constraint not allowed here")]
338pub span: Span,
339340#[subdiagnostic]
341pub fn_trait_expansion: Option<ParenthesizedFnTraitExpansion>,
342}
343344#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
ParamInTyOfAssocConstBinding<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
345#[diag(
346"the type of the associated constant `{$assoc_const}` must not depend on {$param_category ->
347 [self] `Self`
348 [synthetic] `impl Trait`
349 *[normal] generic parameters
350 }"
351)]
352pub(crate) struct ParamInTyOfAssocConstBinding<'tcx> {
353#[primary_span]
354 #[label(
355"its type must not depend on {$param_category ->
356 [self] `Self`
357 [synthetic] `impl Trait`
358 *[normal] the {$param_def_kind} `{$param_name}`
359 }"
360)]
361pub span: Span,
362pub assoc_const: Ident,
363pub param_name: Symbol,
364pub param_def_kind: &'static str,
365pub param_category: &'static str,
366#[label(
367"{$param_category ->
368 [synthetic] the `impl Trait` is specified here
369 *[normal] the {$param_def_kind} `{$param_name}` is defined here
370 }"
371)]
372pub param_defined_here_label: Option<Span>,
373#[subdiagnostic]
374pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
375}
376377#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for
TyOfAssocConstBindingNote<'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TyOfAssocConstBindingNote {
assoc_const: __binding_0, ty: __binding_1 } => {
diag.store_args();
diag.arg("assoc_const", __binding_0);
diag.arg("ty", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$assoc_const}` has type `{$ty}`")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for TyOfAssocConstBindingNote<'tcx> {
#[inline]
fn clone(&self) -> TyOfAssocConstBindingNote<'tcx> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for TyOfAssocConstBindingNote<'tcx> { }Copy)]
378#[note("`{$assoc_const}` has type `{$ty}`")]
379pub(crate) struct TyOfAssocConstBindingNote<'tcx> {
380pub assoc_const: Ident,
381pub ty: Ty<'tcx>,
382}
383384#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
EscapingBoundVarInTyOfAssocConstBinding<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
385#[diag(
386"the type of the associated constant `{$assoc_const}` cannot capture late-bound generic parameters"
387)]
388pub(crate) struct EscapingBoundVarInTyOfAssocConstBinding<'tcx> {
389#[primary_span]
390 #[label("its type cannot capture the late-bound {$var_def_kind} `{$var_name}`")]
391pub span: Span,
392pub assoc_const: Ident,
393pub var_name: Symbol,
394pub var_def_kind: &'static str,
395#[label("the late-bound {$var_def_kind} `{$var_name}` is defined here")]
396pub var_defined_here_label: Span,
397#[subdiagnostic]
398pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
399}
400401#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParenthesizedFnTraitExpansion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParenthesizedFnTraitExpansion {
span: __binding_0, expanded_type: __binding_1 } => {
diag.store_args();
diag.arg("expanded_type", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parenthesized trait syntax expands to `{$expanded_type}`")));
diag.span_help(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
402#[help("parenthesized trait syntax expands to `{$expanded_type}`")]
403pub(crate) struct ParenthesizedFnTraitExpansion {
404#[primary_span]
405pub span: Span,
406407pub expanded_type: String,
408}
409410#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ValueOfAssociatedStructAlreadySpecified where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
411#[diag("the value of the associated type `{$item_name}` in trait `{$def_path}` is already specified", code = E0719)]
412pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
413#[primary_span]
414 #[label("re-bound here")]
415pub span: Span,
416#[label("`{$item_name}` bound here first")]
417pub prev_span: Span,
418pub item_name: Ident,
419pub def_path: String,
420}
421422#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnconstrainedOpaqueType where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
423#[diag("unconstrained opaque type")]
424#[note("`{$name}` must be used in combination with a concrete type within the same {$what}")]
425pub(crate) struct UnconstrainedOpaqueType {
426#[primary_span]
427pub span: Span,
428pub name: Ident,
429pub what: &'static str,
430}
431432pub(crate) struct MissingGenericParams {
433pub span: Span,
434pub def_span: Span,
435pub span_snippet: Option<String>,
436pub missing_generic_params: Vec<(Symbol, ty::GenericParamDefKind)>,
437pub empty_generic_args: bool,
438}
439440// FIXME: This doesn't need to be a manual impl!
441impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MissingGenericParams {
442#[track_caller]
443fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
444let mut err = Diag::new(
445dcx,
446level,
447rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$descr} {$parameterCount ->
[one] parameter
*[other] parameters
} {$parameters} must be explicitly specified"))inline_fluent!(
448"the {$descr} {$parameterCount ->
449 [one] parameter
450 *[other] parameters
451 } {$parameters} must be explicitly specified"
452),
453 );
454err.span(self.span);
455err.code(E0393);
456err.span_label(
457self.def_span,
458rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr} {$parameterCount ->
[one] parameter
*[other] parameters
} {$parameters} must be specified for this"))inline_fluent!(
459"{$descr} {$parameterCount ->
460 [one] parameter
461 *[other] parameters
462 } {$parameters} must be specified for this"
463),
464 );
465466enum Descr {
467 Generic,
468 Type,
469 Const,
470 }
471472let mut descr = None;
473for (_, kind) in &self.missing_generic_params {
474 descr = match (&descr, kind) {
475 (None, ty::GenericParamDefKind::Type { .. }) => Some(Descr::Type),
476 (None, ty::GenericParamDefKind::Const { .. }) => Some(Descr::Const),
477 (Some(Descr::Type), ty::GenericParamDefKind::Const { .. })
478 | (Some(Descr::Const), ty::GenericParamDefKind::Type { .. }) => {
479Some(Descr::Generic)
480 }
481_ => continue,
482 }
483 }
484485err.arg(
486"descr",
487match descr.unwrap() {
488 Descr::Generic => "generic",
489 Descr::Type => "type",
490 Descr::Const => "const",
491 },
492 );
493err.arg("parameterCount", self.missing_generic_params.len());
494err.arg(
495"parameters",
496listify(&self.missing_generic_params, |(n, _)| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", n))
})format!("`{n}`")).unwrap(),
497 );
498499let mut suggested = false;
500// Don't suggest setting the generic params if there are some already: The order is
501 // tricky to get right and the user will already know what the syntax is.
502if let Some(snippet) = self.span_snippet
503 && self.empty_generic_args
504 {
505if snippet.ends_with('>') {
506// The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion
507 // we would have to preserve the right order. For now, as clearly the user is
508 // aware of the syntax, we do nothing.
509} else {
510// The user wrote `Trait`, so we don't have a type we can suggest, but at
511 // least we can clue them to the correct syntax `Trait</* Term */>`.
512err.span_suggestion_verbose(
513self.span.shrink_to_hi(),
514rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly specify the {$descr} {$parameterCount ->
[one] parameter
*[other] parameters
}"))inline_fluent!(
515"explicitly specify the {$descr} {$parameterCount ->
516 [one] parameter
517 *[other] parameters
518 }"
519),
520::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!(
521"<{}>",
522self.missing_generic_params
523 .iter()
524 .map(|(n, _)| format!("/* {n} */"))
525 .collect::<Vec<_>>()
526 .join(", ")
527 ),
528 Applicability::HasPlaceholders,
529 );
530suggested = true;
531 }
532 }
533if !suggested {
534err.span_label(
535self.span,
536rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing {$parameterCount ->
[one] reference
*[other] references
} to {$parameters}"))inline_fluent!(
537"missing {$parameterCount ->
538 [one] reference
539 *[other] references
540 } to {$parameters}"
541),
542 );
543 }
544545err.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("because the parameter {$parameterCount ->
[one] default references
*[other] defaults reference
} `Self`, the {$parameterCount ->
[one] parameter
*[other] parameters
} must be specified on the trait object type"))inline_fluent!(
546"because the parameter {$parameterCount ->
547 [one] default references
548 *[other] defaults reference
549 } `Self`, the {$parameterCount ->
550 [one] parameter
551 *[other] parameters
552 } must be specified on the trait object type"
553));
554err555 }
556}
557558#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ManualImplementation where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
559#[diag("manual implementations of `{$trait_name}` are experimental", code = E0183)]
560#[help("add `#![feature(unboxed_closures)]` to the crate attributes to enable")]
561pub(crate) struct ManualImplementation {
562#[primary_span]
563 #[label("manual implementations of `{$trait_name}` are experimental")]
564pub span: Span,
565pub trait_name: String,
566}
567568#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericArgsOnOverriddenImpl where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
569#[diag("could not resolve generic parameters on overridden impl")]
570pub(crate) struct GenericArgsOnOverriddenImpl {
571#[primary_span]
572pub span: Span,
573}
574575#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstImplForNonConstTrait where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
576#[diag("const `impl` for trait `{$trait_name}` which is not `const`")]
577pub(crate) struct ConstImplForNonConstTrait {
578#[primary_span]
579 #[label("this trait is not `const`")]
580pub trait_ref_span: Span,
581pub trait_name: String,
582#[suggestion(
583"{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations",
584 applicability = "machine-applicable",
585 code = "const ",
586 style = "verbose"
587)]
588pub suggestion: Option<Span>,
589pub suggestion_pre: &'static str,
590#[note("marking a trait with `const` ensures all default method bodies are `const`")]
591pub marking: (),
592#[note("adding a non-const method body in the future would be a breaking change")]
593pub adding: (),
594}
595596#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstBoundForNonConstTrait where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
597#[diag("`{$modifier}` can only be applied to `const` traits")]
598pub(crate) struct ConstBoundForNonConstTrait {
599#[primary_span]
600 #[label("can't be applied to `{$trait_name}`")]
601pub span: Span,
602pub modifier: &'static str,
603#[note("`{$trait_name}` can't be used with `{$modifier}` because it isn't `const`")]
604pub def_span: Option<Span>,
605#[suggestion(
606"{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations",
607 applicability = "machine-applicable",
608 code = "const ",
609 style = "verbose"
610)]
611pub suggestion: Option<Span>,
612pub suggestion_pre: &'static str,
613pub trait_name: String,
614}
615616#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for SelfInImplSelf
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
617#[diag("`Self` is not valid in the self type of an impl block")]
618pub(crate) struct SelfInImplSelf {
619#[primary_span]
620pub span: MultiSpan,
621#[note("replace `Self` with a different type")]
622pub note: (),
623}
624625#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LinkageType
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
626#[diag("invalid type for variable with `#[linkage]` attribute", code = E0791)]
627pub(crate) struct LinkageType {
628#[primary_span]
629pub span: Span,
630}
631632#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
AutoDerefReachedRecursionLimit<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
633#[help(
634"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
635)]
636#[diag("reached the recursion limit while auto-dereferencing `{$ty}`", code = E0055)]
637pub(crate) struct AutoDerefReachedRecursionLimit<'a> {
638#[primary_span]
639 #[label("deref recursion limit reached")]
640pub span: Span,
641pub ty: Ty<'a>,
642pub suggested_limit: Limit,
643pub crate_name: Symbol,
644}
645646#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
WhereClauseOnMain where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
647#[diag("`main` function is not allowed to have a `where` clause", code = E0646)]
648pub(crate) struct WhereClauseOnMain {
649#[primary_span]
650pub span: Span,
651#[label("`main` cannot have a `where` clause")]
652pub generics_span: Option<Span>,
653}
654655#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TrackCallerOnMain where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
656#[diag("`main` function is not allowed to be `#[track_caller]`")]
657pub(crate) struct TrackCallerOnMain {
658#[primary_span]
659 #[suggestion("remove this annotation", applicability = "maybe-incorrect", code = "")]
660pub span: Span,
661#[label("`main` function is not allowed to be `#[track_caller]`")]
662pub annotated: Span,
663}
664665#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TargetFeatureOnMain where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
666#[diag("`main` function is not allowed to have `#[target_feature]`")]
667pub(crate) struct TargetFeatureOnMain {
668#[primary_span]
669 #[label("`main` function is not allowed to have `#[target_feature]`")]
670pub main: Span,
671}
672673#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MainFunctionReturnTypeGeneric where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
674#[diag("`main` function return type is not allowed to have generic parameters", code = E0131)]
675pub(crate) struct MainFunctionReturnTypeGeneric {
676#[primary_span]
677pub span: Span,
678}
679680#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MainFunctionAsync where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
681#[diag("`main` function is not allowed to be `async`", code = E0752)]
682pub(crate) struct MainFunctionAsync {
683#[primary_span]
684pub span: Span,
685#[label("`main` function is not allowed to be `async`")]
686pub asyncness: Option<Span>,
687}
688689#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MainFunctionGenericParameters where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
690#[diag("`main` function is not allowed to have generic parameters", code = E0131)]
691pub(crate) struct MainFunctionGenericParameters {
692#[primary_span]
693pub span: Span,
694#[label("`main` cannot have generic parameters")]
695pub label_span: Option<Span>,
696}
697698#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
VariadicFunctionCompatibleConvention<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
699#[diag("C-variadic functions with the {$convention} calling convention are not supported", code = E0045)]
700pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
701#[primary_span]
702 #[label("C-variadic function must have a compatible calling convention")]
703pub span: Span,
704pub convention: &'a str,
705}
706707#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotCaptureLateBound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
708pub(crate) enum CannotCaptureLateBound {
709#[diag("cannot capture late-bound type parameter in {$what}")]
710Type {
711#[primary_span]
712use_span: Span,
713#[label("parameter defined here")]
714def_span: Span,
715 what: &'static str,
716 },
717#[diag("cannot capture late-bound const parameter in {$what}")]
718Const {
719#[primary_span]
720use_span: Span,
721#[label("parameter defined here")]
722def_span: Span,
723 what: &'static str,
724 },
725#[diag("cannot capture late-bound lifetime in {$what}")]
726Lifetime {
727#[primary_span]
728use_span: Span,
729#[label("lifetime defined here")]
730def_span: Span,
731 what: &'static str,
732 },
733}
734735#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for VariancesOf
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
VariancesOf { span: __binding_0, variances: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$variances}")));
;
diag.arg("variances", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
736#[diag("{$variances}")]
737pub(crate) struct VariancesOf {
738#[primary_span]
739pub span: Span,
740pub variances: String,
741}
742743#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
TypeOf<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
744#[diag("{$ty}")]
745pub(crate) struct TypeOf<'tcx> {
746#[primary_span]
747pub span: Span,
748pub ty: Ty<'tcx>,
749}
750751#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidUnionField where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
752#[diag("field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union", code = E0740)]
753pub(crate) struct InvalidUnionField {
754#[primary_span]
755pub field_span: Span,
756#[subdiagnostic]
757pub sugg: InvalidUnionFieldSuggestion,
758#[note(
759"union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`"
760)]
761pub note: (),
762}
763764#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
ReturnTypeNotationOnNonRpitit<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
765#[diag(
766"return type notation used on function that is not `async` and does not return `impl Trait`"
767)]
768pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
769#[primary_span]
770pub span: Span,
771pub ty: Ty<'tcx>,
772#[label("this function must be `async` or return `impl Trait`")]
773pub fn_span: Option<Span>,
774#[note("function returns `{$ty}`, which is not compatible with associated type return bounds")]
775pub note: (),
776}
777778#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidUnionFieldSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the field type in `ManuallyDrop<...>`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
779#[multipart_suggestion(
780"wrap the field type in `ManuallyDrop<...>`",
781 applicability = "machine-applicable"
782)]
783pub(crate) struct InvalidUnionFieldSuggestion {
784#[suggestion_part(code = "std::mem::ManuallyDrop<")]
785pub lo: Span,
786#[suggestion_part(code = ">")]
787pub hi: Span,
788}
789790#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReturnTypeNotationEqualityBound where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
791#[diag("return type notation is not allowed to use type equality")]
792pub(crate) struct ReturnTypeNotationEqualityBound {
793#[primary_span]
794pub span: Span,
795}
796797#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PlaceholderNotAllowedItemSignatures where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
798#[diag("the placeholder `_` is not allowed within types on item signatures for {$kind}", code = E0121)]
799pub(crate) struct PlaceholderNotAllowedItemSignatures {
800#[primary_span]
801 #[label("not allowed in type signatures")]
802pub spans: Vec<Span>,
803pub kind: String,
804}
805806#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AssociatedItemTraitUninferredGenericParams where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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("bound", __binding_2);
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)]
807#[diag("cannot use the {$what} of a trait with uninferred generic parameters", code = E0212)]
808pub(crate) struct AssociatedItemTraitUninferredGenericParams {
809#[primary_span]
810pub span: Span,
811#[suggestion(
812"use a fully qualified path with inferred lifetimes",
813 style = "verbose",
814 applicability = "maybe-incorrect",
815 code = "{bound}"
816)]
817pub inferred_sugg: Option<Span>,
818pub bound: String,
819#[subdiagnostic]
820pub mpart_sugg: Option<AssociatedItemTraitUninferredGenericParamsMultipartSuggestion>,
821pub what: &'static str,
822}
823824#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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));
diag.store_args();
diag.arg("first", __binding_1);
diag.arg("second", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a fully qualified path with explicit lifetimes")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
825#[multipart_suggestion(
826"use a fully qualified path with explicit lifetimes",
827 applicability = "maybe-incorrect"
828)]
829pub(crate) struct AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
830#[suggestion_part(code = "{first}")]
831pub fspan: Span,
832pub first: String,
833#[suggestion_part(code = "{second}")]
834pub sspan: Span,
835pub second: String,
836}
837838#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EnumDiscriminantOverflowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
839#[diag("enum discriminant overflowed", code = E0370)]
840#[note("explicitly set `{$item_name} = {$wrapped_discr}` if that is desired outcome")]
841pub(crate) struct EnumDiscriminantOverflowed {
842#[primary_span]
843 #[label("overflowed on value after {$discr}")]
844pub span: Span,
845pub discr: String,
846pub item_name: Ident,
847pub wrapped_discr: String,
848}
849850#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParenSugarAttribute where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenSugarAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(unboxed_closures)]` to the crate attributes to use it")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
851#[diag(
852"the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation"
853)]
854#[help("add `#![feature(unboxed_closures)]` to the crate attributes to use it")]
855pub(crate) struct ParenSugarAttribute {
856#[primary_span]
857pub span: Span,
858}
859860#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SIMDFFIHighlyExperimental where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
861#[diag("use of SIMD type{$snip} in FFI is highly experimental and may result in invalid code")]
862#[help("add `#![feature(simd_ffi)]` to the crate attributes to enable")]
863pub(crate) struct SIMDFFIHighlyExperimental {
864#[primary_span]
865pub span: Span,
866pub snip: String,
867}
868869#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ImplNotMarkedDefault where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
870pub(crate) enum ImplNotMarkedDefault {
871#[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
872 #[note("to specialize, `{$ident}` in the parent `impl` must be marked `default`")]
873Ok {
874#[primary_span]
875 #[label("cannot specialize default item `{$ident}`")]
876span: Span,
877#[label("parent `impl` is here")]
878ok_label: Span,
879 ident: Ident,
880 },
881#[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
882 #[note("parent implementation is in crate `{$cname}`")]
883Err {
884#[primary_span]
885span: Span,
886 cname: Symbol,
887 ident: Ident,
888 },
889}
890891#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for UselessImplItem
{
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UselessImplItem => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
892#[diag("this item cannot be used as its where bounds are not satisfied for the `Self` type")]
893pub(crate) struct UselessImplItem;
894895#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingTraitItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingTraitItem {
span: __binding_0,
missing_trait_item_label: __binding_1,
missing_trait_item: __binding_2,
missing_trait_item_none: __binding_3,
missing_items_msg: __binding_4 } => {
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_4);
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);
}
diag
}
}
}
}
};Diagnostic)]
896#[diag("not all trait items implemented, missing: `{$missing_items_msg}`", code = E0046)]
897pub(crate) struct MissingTraitItem {
898#[primary_span]
899 #[label("missing `{$missing_items_msg}` in implementation")]
900pub span: Span,
901#[subdiagnostic]
902pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
903#[subdiagnostic]
904pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
905#[subdiagnostic]
906pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
907pub missing_items_msg: String,
908}
909910#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingTraitItemLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MissingTraitItemLabel { span: __binding_0, item: __binding_1
} => {
diag.store_args();
diag.arg("item", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$item}` from trait")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
911#[label("`{$item}` from trait")]
912pub(crate) struct MissingTraitItemLabel {
913#[primary_span]
914pub span: Span,
915pub item: Symbol,
916}
917918#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingTraitItemSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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();
diag.store_args();
diag.arg("code", __binding_1);
diag.arg("snippet", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implement the missing item: `{$snippet}`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_16, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
919#[suggestion(
920"implement the missing item: `{$snippet}`",
921 style = "tool-only",
922 applicability = "has-placeholders",
923 code = "{code}"
924)]
925pub(crate) struct MissingTraitItemSuggestion {
926#[primary_span]
927pub span: Span,
928pub code: String,
929pub snippet: String,
930}
931932#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MissingTraitItemSuggestionNone {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MissingTraitItemSuggestionNone {
span: __binding_0, code: __binding_1, snippet: __binding_2 }
=> {
let __code_17 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("code", __binding_1);
diag.arg("snippet", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implement the missing item: `{$snippet}`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_17, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::HideCodeAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
933#[suggestion(
934"implement the missing item: `{$snippet}`",
935 style = "hidden",
936 applicability = "has-placeholders",
937 code = "{code}"
938)]
939pub(crate) struct MissingTraitItemSuggestionNone {
940#[primary_span]
941pub span: Span,
942pub code: String,
943pub snippet: String,
944}
945946#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingOneOfTraitItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingOneOfTraitItem {
span: __binding_0,
note: __binding_1,
missing_items_msg: __binding_2 } => {
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_2);
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")));
}
diag
}
}
}
}
};Diagnostic)]
947#[diag("not all trait items implemented, missing one of: `{$missing_items_msg}`", code = E0046)]
948pub(crate) struct MissingOneOfTraitItem {
949#[primary_span]
950 #[label("missing one of `{$missing_items_msg}` in implementation")]
951pub span: Span,
952#[note("required because of this annotation")]
953pub note: Option<Span>,
954pub missing_items_msg: String,
955}
956957#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingTraitItemUnstable where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
958#[diag("not all trait items implemented, missing: `{$missing_item_name}`", code = E0046)]
959#[note("default implementation of `{$missing_item_name}` is unstable")]
960pub(crate) struct MissingTraitItemUnstable {
961#[primary_span]
962pub span: Span,
963#[note("use of unstable library feature `{$feature}`: {$reason}")]
964pub some_note: bool,
965#[note("use of unstable library feature `{$feature}`")]
966pub none_note: bool,
967pub missing_item_name: Ident,
968pub feature: Symbol,
969pub reason: String,
970}
971972#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TransparentEnumVariant where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
973#[diag("transparent enum needs exactly one variant, but has {$number}", code = E0731)]
974pub(crate) struct TransparentEnumVariant {
975#[primary_span]
976 #[label("needs exactly one variant, but has {$number}")]
977pub span: Span,
978#[label("variant here")]
979pub spans: Vec<Span>,
980#[label("too many variants in `{$path}`")]
981pub many: Option<Span>,
982pub number: usize,
983pub path: String,
984}
985986#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
TransparentNonZeroSizedEnum<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TransparentNonZeroSizedEnum {
span: __binding_0,
spans: __binding_1,
field_count: __binding_2,
desc: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the variant of a transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}")));
diag.code(E0690);
;
diag.arg("field_count", __binding_2);
diag.arg("desc", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("needs at most one field with non-trivial size or alignment, but has {$field_count}")));
for __binding_1 in __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this field has non-zero size or requires alignment")));
}
diag
}
}
}
}
};Diagnostic)]
987#[diag("the variant of a transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}", code = E0690)]
988pub(crate) struct TransparentNonZeroSizedEnum<'a> {
989#[primary_span]
990 #[label("needs at most one field with non-trivial size or alignment, but has {$field_count}")]
991pub span: Span,
992#[label("this field has non-zero size or requires alignment")]
993pub spans: Vec<Span>,
994pub field_count: usize,
995pub desc: &'a str,
996}
997998#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
TransparentNonZeroSized<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TransparentNonZeroSized {
span: __binding_0,
spans: __binding_1,
field_count: __binding_2,
desc: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}")));
diag.code(E0690);
;
diag.arg("field_count", __binding_2);
diag.arg("desc", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("needs at most one field with non-trivial size or alignment, but has {$field_count}")));
for __binding_1 in __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this field has non-zero size or requires alignment")));
}
diag
}
}
}
}
};Diagnostic)]
999#[diag("transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}", code = E0690)]
1000pub(crate) struct TransparentNonZeroSized<'a> {
1001#[primary_span]
1002 #[label("needs at most one field with non-trivial size or alignment, but has {$field_count}")]
1003pub span: Span,
1004#[label("this field has non-zero size or requires alignment")]
1005pub spans: Vec<Span>,
1006pub field_count: usize,
1007pub desc: &'a str,
1008}
10091010#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TooLargeStatic
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1011#[diag("extern static is too large for the target architecture")]
1012pub(crate) struct TooLargeStatic {
1013#[primary_span]
1014pub span: Span,
1015}
10161017#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SpecializationTrait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1018#[diag("implementing `rustc_specialization_trait` traits is unstable")]
1019#[help("add `#![feature(min_specialization)]` to the crate attributes to enable")]
1020pub(crate) struct SpecializationTrait {
1021#[primary_span]
1022pub span: Span,
1023}
10241025#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ClosureImplicitHrtb where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1026#[diag("implicit types in closure signatures are forbidden when `for<...>` is present")]
1027pub(crate) struct ClosureImplicitHrtb {
1028#[primary_span]
1029pub spans: Vec<Span>,
1030#[label("`for<...>` is here")]
1031pub for_sp: Span,
1032}
10331034#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EmptySpecialization where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1035#[diag("specialization impl does not specialize any associated items")]
1036pub(crate) struct EmptySpecialization {
1037#[primary_span]
1038pub span: Span,
1039#[note("impl is a specialization of this impl")]
1040pub base_impl_span: Span,
1041}
10421043#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StaticSpecialize where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1044#[diag("cannot specialize on `'static` lifetime")]
1045pub(crate) struct StaticSpecialize {
1046#[primary_span]
1047pub span: Span,
1048}
10491050#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DropImplPolarity where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DropImplPolarity::Negative { 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
}
DropImplPolarity::Reservation { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reservation `Drop` impls are not supported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1051pub(crate) enum DropImplPolarity {
1052#[diag("negative `Drop` impls are not supported")]
1053Negative {
1054#[primary_span]
1055span: Span,
1056 },
1057#[diag("reservation `Drop` impls are not supported")]
1058Reservation {
1059#[primary_span]
1060span: Span,
1061 },
1062}
10631064#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReturnTypeNotationIllegalParam where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1065pub(crate) enum ReturnTypeNotationIllegalParam {
1066#[diag("return type notation is not allowed for functions that have type parameters")]
1067Type {
1068#[primary_span]
1069span: Span,
1070#[label("type parameter declared here")]
1071param_span: Span,
1072 },
1073#[diag("return type notation is not allowed for functions that have const parameters")]
1074Const {
1075#[primary_span]
1076span: Span,
1077#[label("const parameter declared here")]
1078param_span: Span,
1079 },
1080}
10811082#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LateBoundInApit where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1083pub(crate) enum LateBoundInApit {
1084#[diag("`impl Trait` can only mention type parameters from an fn or impl")]
1085Type {
1086#[primary_span]
1087span: Span,
1088#[label("type parameter declared here")]
1089param_span: Span,
1090 },
1091#[diag("`impl Trait` can only mention const parameters from an fn or impl")]
1092Const {
1093#[primary_span]
1094span: Span,
1095#[label("const parameter declared here")]
1096param_span: Span,
1097 },
1098#[diag("`impl Trait` can only mention lifetimes from an fn or impl")]
1099Lifetime {
1100#[primary_span]
1101span: Span,
1102#[label("lifetime declared here")]
1103param_span: Span,
1104 },
1105}
11061107#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnusedAssociatedTypeBounds {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnusedAssociatedTypeBounds { span: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary associated type bound for dyn-incompatible associated type")));
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`")));
;
let __code_18 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this bound")),
__code_18, rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
};
}
}
};LintDiagnostic)]
1108#[diag("unnecessary associated type bound for dyn-incompatible associated type")]
1109#[note(
1110"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`"
1111)]
1112pub(crate) struct UnusedAssociatedTypeBounds {
1113#[suggestion("remove this bound", code = "")]
1114pub span: Span,
1115}
11161117#[derive(const _: () =
{
impl<'__a, 'tcx> rustc_errors::LintDiagnostic<'__a, ()> for
ReturnPositionImplTraitInTraitRefined<'tcx> {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
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 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl trait in impl method signature does not match trait method signature")));
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")));
;
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}{2}{0}", __binding_4,
__binding_3, __binding_5))
})].into_iter();
diag.arg("pre", __binding_3);
diag.arg("post", __binding_4);
diag.arg("return_ty", __binding_5);
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_19, 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
}
};
}
}
};LintDiagnostic)]
1118#[diag("impl trait in impl method signature does not match trait method signature")]
1119#[note(
1120"add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1121)]
1122#[note(
1123"we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1124)]
1125pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
1126#[suggestion(
1127"replace the return type so that it matches the trait",
1128 applicability = "maybe-incorrect",
1129 code = "{pre}{return_ty}{post}"
1130)]
1131pub impl_return_span: Span,
1132#[label("return type from trait method defined here")]
1133pub trait_return_span: Option<Span>,
1134#[label("this bound is stronger than that defined on the trait")]
1135pub unmatched_bound: Option<Span>,
11361137pub pre: &'static str,
1138pub post: &'static str,
1139pub return_ty: Ty<'tcx>,
1140}
11411142#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
ReturnPositionImplTraitInTraitRefinedLifetimes {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
ReturnPositionImplTraitInTraitRefinedLifetimes {
suggestion_span: __binding_0, suggestion: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl trait in impl method captures fewer lifetimes than in trait")));
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")));
;
let __code_20 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.arg("suggestion", __binding_1);
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_20, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
};
}
}
};LintDiagnostic)]
1143#[diag("impl trait in impl method captures fewer lifetimes than in trait")]
1144#[note(
1145"add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1146)]
1147#[note(
1148"we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1149)]
1150pub(crate) struct ReturnPositionImplTraitInTraitRefinedLifetimes {
1151#[suggestion(
1152"modify the `use<..>` bound to capture the same lifetimes that the trait does",
1153 applicability = "maybe-incorrect",
1154 code = "{suggestion}"
1155)]
1156pub suggestion_span: Span,
1157pub suggestion: String,
1158}
11591160#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InherentTyOutside where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1161#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1162#[help("consider moving this inherent impl into the crate defining the type if possible")]
1163pub(crate) struct InherentTyOutside {
1164#[primary_span]
1165 #[help(
1166"alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items"
1167)]
1168pub span: Span,
1169}
11701171#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DispatchFromDynRepr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1172#[diag("structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`", code = E0378)]
1173pub(crate) struct DispatchFromDynRepr {
1174#[primary_span]
1175pub span: Span,
1176}
11771178#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoercePointeeNotStruct where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1179#[diag("`derive(CoercePointee)` is only applicable to `struct`, instead of `{$kind}`", code = E0802)]
1180pub(crate) struct CoercePointeeNotStruct {
1181#[primary_span]
1182pub span: Span,
1183pub kind: String,
1184}
11851186#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoercePointeeNotConcreteType where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1187#[diag("`derive(CoercePointee)` is only applicable to `struct`", code = E0802)]
1188pub(crate) struct CoercePointeeNotConcreteType {
1189#[primary_span]
1190pub span: Span,
1191}
11921193#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoercePointeeNoUserValidityAssertion where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1194#[diag("asserting applicability of `derive(CoercePointee)` on a target data is forbidden", code = E0802)]
1195pub(crate) struct CoercePointeeNoUserValidityAssertion {
1196#[primary_span]
1197pub span: Span,
1198}
11991200#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoercePointeeNotTransparent where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1201#[diag("`derive(CoercePointee)` is only applicable to `struct` with `repr(transparent)` layout", code = E0802)]
1202pub(crate) struct CoercePointeeNotTransparent {
1203#[primary_span]
1204pub span: Span,
1205}
12061207#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoercePointeeNoField where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1208#[diag("`CoercePointee` can only be derived on `struct`s with at least one field", code = E0802)]
1209pub(crate) struct CoercePointeeNoField {
1210#[primary_span]
1211pub span: Span,
1212}
12131214#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InherentTyOutsideRelevant where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1215#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1216#[help("consider moving this inherent impl into the crate defining the type if possible")]
1217pub(crate) struct InherentTyOutsideRelevant {
1218#[primary_span]
1219pub span: Span,
1220#[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1221pub help_span: Span,
1222}
12231224#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InherentTyOutsideNew where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InherentTyOutsideNew { 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(E0116);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("define and implement a trait or new type instead")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl for type defined outside of crate")));
diag
}
}
}
}
};Diagnostic)]
1225#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0116)]
1226#[note("define and implement a trait or new type instead")]
1227pub(crate) struct InherentTyOutsideNew {
1228#[primary_span]
1229 #[label("impl for type defined outside of crate")]
1230pub span: Span,
1231}
12321233#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InherentTyOutsidePrimitive where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1234#[diag("cannot define inherent `impl` for primitive types outside of `core`", code = E0390)]
1235#[help("consider moving this inherent impl into `core` if possible")]
1236pub(crate) struct InherentTyOutsidePrimitive {
1237#[primary_span]
1238pub span: Span,
1239#[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1240pub help_span: Span,
1241}
12421243#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
InherentPrimitiveTy<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1244#[diag("cannot define inherent `impl` for primitive types", code = E0390)]
1245#[help("consider using an extension trait instead")]
1246pub(crate) struct InherentPrimitiveTy<'a> {
1247#[primary_span]
1248pub span: Span,
1249#[subdiagnostic]
1250pub note: Option<InherentPrimitiveTyNote<'a>>,
1251}
12521253#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for InherentPrimitiveTyNote<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InherentPrimitiveTyNote { subty: __binding_0 } => {
diag.store_args();
diag.arg("subty", __binding_0);
let __message =
diag.eagerly_translate(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")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1254#[note(
1255"you could also try moving the reference to uses of `{$subty}` (such as `self`) within the implementation"
1256)]
1257pub(crate) struct InherentPrimitiveTyNote<'a> {
1258pub subty: Ty<'a>,
1259}
12601261#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InherentDyn
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1262#[diag("cannot define inherent `impl` for a dyn auto trait", code = E0785)]
1263#[note("define and implement a new trait or type instead")]
1264pub(crate) struct InherentDyn {
1265#[primary_span]
1266 #[label("impl requires at least one non-auto trait")]
1267pub span: Span,
1268}
12691270#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InherentNominal where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1271#[diag("no nominal type found for inherent implementation", code = E0118)]
1272#[note("either implement a trait on it or create a newtype to wrap it instead")]
1273pub(crate) struct InherentNominal {
1274#[primary_span]
1275 #[label("impl requires a nominal type")]
1276pub span: Span,
1277}
12781279#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DispatchFromDynZST<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1280#[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)]
1281#[note("extra field `{$name}` of type `{$ty}` is not allowed")]
1282pub(crate) struct DispatchFromDynZST<'a> {
1283#[primary_span]
1284pub span: Span,
1285pub name: Ident,
1286pub ty: Ty<'a>,
1287}
12881289#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CoerceNoField
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1290#[diag("implementing `{$trait_name}` requires a field to be coerced", code = E0374)]
1291pub(crate) struct CoerceNoField {
1292#[primary_span]
1293pub span: Span,
1294pub trait_name: &'static str,
1295#[note("expected a single field to be coerced, none found")]
1296pub note: bool,
1297}
12981299#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CoerceMulti
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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.arg("number", __binding_2);
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)]
1300#[diag("implementing `{$trait_name}` does not allow multiple fields to be coerced", code = E0375)]
1301pub(crate) struct CoerceMulti {
1302pub trait_name: &'static str,
1303#[primary_span]
1304pub span: Span,
1305pub number: usize,
1306#[note(
1307"the trait `{$trait_name}` may only be implemented when a single field is being coerced"
1308)]
1309pub fields: MultiSpan,
1310}
13111312#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoerceUnsizedNonStruct where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1313#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1314pub(crate) struct CoerceUnsizedNonStruct {
1315#[primary_span]
1316pub span: Span,
1317pub trait_name: &'static str,
1318}
13191320#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoerceSamePatKind where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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.arg("trait_name", __binding_1);
diag.arg("pat_a", __binding_2);
diag.arg("pat_b", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1321#[diag("only pattern types with the same pattern can be coerced between each other")]
1322pub(crate) struct CoerceSamePatKind {
1323#[primary_span]
1324pub span: Span,
1325pub trait_name: &'static str,
1326pub pat_a: String,
1327pub pat_b: String,
1328}
13291330#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CoerceSameStruct where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1331#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1332pub(crate) struct CoerceSameStruct {
1333#[primary_span]
1334pub span: Span,
1335pub trait_name: &'static str,
1336#[note(
1337"expected coercion between the same definition; expected `{$source_path}`, found `{$target_path}`"
1338)]
1339pub note: bool,
1340pub source_path: String,
1341pub target_path: String,
1342}
13431344#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
CoerceFieldValidity<'tcx> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1345#[diag(
1346"for `{$ty}` to have a valid implementation of `{$trait_name}`, it must be possible to coerce the field of type `{$field_ty}`"
1347)]
1348pub(crate) struct CoerceFieldValidity<'tcx> {
1349#[primary_span]
1350pub span: Span,
1351pub ty: Ty<'tcx>,
1352pub trait_name: &'static str,
1353#[label(
1354"`{$field_ty}` must be a pointer, reference, or smart pointer that is allowed to be unsized"
1355)]
1356pub field_span: Span,
1357pub field_ty: Ty<'tcx>,
1358}
13591360#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitCannotImplForTy where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1361#[diag("the trait `{$trait_name}` cannot be implemented for this type", code = E0204)]
1362pub(crate) struct TraitCannotImplForTy {
1363#[primary_span]
1364pub span: Span,
1365pub trait_name: String,
1366#[label("this field does not implement `{$trait_name}`")]
1367pub label_spans: Vec<Span>,
1368#[subdiagnostic]
1369pub notes: Vec<ImplForTyRequires>,
1370}
13711372#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImplForTyRequires {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ImplForTyRequires {
span: __binding_0,
error_predicate: __binding_1,
trait_name: __binding_2,
ty: __binding_3 } => {
diag.store_args();
diag.arg("error_predicate", __binding_1);
diag.arg("trait_name", __binding_2);
diag.arg("ty", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1373#[note("the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`")]
1374pub(crate) struct ImplForTyRequires {
1375#[primary_span]
1376pub span: MultiSpan,
1377pub error_predicate: String,
1378pub trait_name: String,
1379pub ty: String,
1380}
13811382#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
TraitsWithDefaultImpl<'a> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1383#[diag("traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`", code = E0321)]
1384#[note(
1385"a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds"
1386)]
1387pub(crate) struct TraitsWithDefaultImpl<'a> {
1388#[primary_span]
1389pub span: Span,
1390pub traits: String,
1391pub problematic_kind: &'a str,
1392pub self_ty: Ty<'a>,
1393}
13941395#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
CrossCrateTraits<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1396#[diag("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`", code = E0321)]
1397pub(crate) struct CrossCrateTraits<'a> {
1398#[primary_span]
1399 #[label("can't implement cross-crate trait with a default impl for non-struct/enum type")]
1400pub span: Span,
1401pub traits: String,
1402pub self_ty: Ty<'a>,
1403}
14041405#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CrossCrateTraitsDefined where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1406#[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)]
1407pub(crate) struct CrossCrateTraitsDefined {
1408#[primary_span]
1409 #[label("can't implement cross-crate trait for type in another crate")]
1410pub span: Span,
1411pub traits: String,
1412}
14131414#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
NoVariantNamed<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1415#[diag("no variant named `{$ident}` found for enum `{$ty}`", code = E0599)]
1416pub struct NoVariantNamed<'tcx> {
1417#[primary_span]
1418pub span: Span,
1419pub ident: Ident,
1420pub ty: Ty<'tcx>,
1421}
14221423// FIXME(fmease): Deduplicate:
14241425#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
TyParamFirstLocal<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TyParamFirstLocal {
span: __binding_0,
note: __binding_1,
param: __binding_2,
local_type: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)")));
diag.code(E0210);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type")));
;
diag.arg("param", __binding_2);
diag.arg("local_type", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last")));
diag
}
}
}
}
};Diagnostic)]
1426#[diag("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)", code = E0210)]
1427#[note(
1428"implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type"
1429)]
1430pub(crate) struct TyParamFirstLocal<'tcx> {
1431#[primary_span]
1432 #[label(
1433"type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)"
1434)]
1435pub span: Span,
1436#[note(
1437"in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last"
1438)]
1439pub note: (),
1440pub param: Ident,
1441pub local_type: Ty<'tcx>,
1442}
14431444#[derive(const _: () =
{
impl<'__a, 'tcx> rustc_errors::LintDiagnostic<'__a, ()> for
TyParamFirstLocalLint<'tcx> {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
TyParamFirstLocalLint {
span: __binding_0,
note: __binding_1,
param: __binding_2,
local_type: __binding_3 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)")));
diag.code(E0210);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type")));
;
diag.arg("param", __binding_2);
diag.arg("local_type", __binding_3);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last")));
diag
}
};
}
}
};LintDiagnostic)]
1445#[diag("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)", code = E0210)]
1446#[note(
1447"implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type"
1448)]
1449pub(crate) struct TyParamFirstLocalLint<'tcx> {
1450#[label(
1451"type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)"
1452)]
1453pub span: Span,
1454#[note(
1455"in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last"
1456)]
1457pub note: (),
1458pub param: Ident,
1459pub local_type: Ty<'tcx>,
1460}
14611462#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TyParamSome
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TyParamSome {
span: __binding_0, note: __binding_1, param: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)")));
diag.code(E0210);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing a foreign trait is only possible if at least one of the types for which it is implemented is local")));
;
diag.arg("param", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be used as the type parameter for some local type")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only traits defined in the current crate can be implemented for a type parameter")));
diag
}
}
}
}
};Diagnostic)]
1463#[diag("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)", code = E0210)]
1464#[note(
1465"implementing a foreign trait is only possible if at least one of the types for which it is implemented is local"
1466)]
1467pub(crate) struct TyParamSome {
1468#[primary_span]
1469 #[label("type parameter `{$param}` must be used as the type parameter for some local type")]
1470pub span: Span,
1471#[note("only traits defined in the current crate can be implemented for a type parameter")]
1472pub note: (),
1473pub param: Ident,
1474}
14751476#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for TyParamSomeLint
{
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
TyParamSomeLint {
span: __binding_0, note: __binding_1, param: __binding_2 }
=> {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)")));
diag.code(E0210);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing a foreign trait is only possible if at least one of the types for which it is implemented is local")));
;
diag.arg("param", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter `{$param}` must be used as the type parameter for some local type")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only traits defined in the current crate can be implemented for a type parameter")));
diag
}
};
}
}
};LintDiagnostic)]
1477#[diag("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)", code = E0210)]
1478#[note(
1479"implementing a foreign trait is only possible if at least one of the types for which it is implemented is local"
1480)]
1481pub(crate) struct TyParamSomeLint {
1482#[label("type parameter `{$param}` must be used as the type parameter for some local type")]
1483pub span: Span,
1484#[note("only traits defined in the current crate can be implemented for a type parameter")]
1485pub note: (),
1486pub param: Ident,
1487}
14881489#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OnlyCurrentTraits where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1490pub(crate) enum OnlyCurrentTraits {
1491#[diag("only traits defined in the current crate can be implemented for types defined outside of the crate", code = E0117)]
1492Outside {
1493#[primary_span]
1494span: Span,
1495#[note("impl doesn't have any local type before any uncovered type parameters")]
1496 #[note(
1497"for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1498)]
1499 #[note("define and implement a trait or new type instead")]
1500note: (),
1501 },
1502#[diag("only traits defined in the current crate can be implemented for primitive types", code = E0117)]
1503Primitive {
1504#[primary_span]
1505span: Span,
1506#[note("impl doesn't have any local type before any uncovered type parameters")]
1507 #[note(
1508"for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1509)]
1510 #[note("define and implement a trait or new type instead")]
1511note: (),
1512 },
1513#[diag("only traits defined in the current crate can be implemented for arbitrary types", code = E0117)]
1514Arbitrary {
1515#[primary_span]
1516span: Span,
1517#[note("impl doesn't have any local type before any uncovered type parameters")]
1518 #[note(
1519"for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1520)]
1521 #[note("define and implement a trait or new type instead")]
1522note: (),
1523 },
1524}
15251526#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OnlyCurrentTraitsOpaque {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OnlyCurrentTraitsOpaque { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(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")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1527#[label(
1528"type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate"
1529)]
1530pub(crate) struct OnlyCurrentTraitsOpaque {
1531#[primary_span]
1532pub span: Span,
1533}
1534#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OnlyCurrentTraitsForeign {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OnlyCurrentTraitsForeign { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is not defined in the current crate because this is a foreign trait")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1535#[label("this is not defined in the current crate because this is a foreign trait")]
1536pub(crate) struct OnlyCurrentTraitsForeign {
1537#[primary_span]
1538pub span: Span,
1539}
15401541#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OnlyCurrentTraitsName<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OnlyCurrentTraitsName { span: __binding_0, name: __binding_1
} => {
diag.store_args();
diag.arg("name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is not defined in the current crate because {$name} are always foreign")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1542#[label("this is not defined in the current crate because {$name} are always foreign")]
1543pub(crate) struct OnlyCurrentTraitsName<'a> {
1544#[primary_span]
1545pub span: Span,
1546pub name: &'a str,
1547}
15481549#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OnlyCurrentTraitsPointer<'a>
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OnlyCurrentTraitsPointer {
span: __binding_0, pointer: __binding_1 } => {
diag.store_args();
diag.arg("pointer", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$pointer}` is not defined in the current crate because raw pointers are always foreign")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1550#[label("`{$pointer}` is not defined in the current crate because raw pointers are always foreign")]
1551pub(crate) struct OnlyCurrentTraitsPointer<'a> {
1552#[primary_span]
1553pub span: Span,
1554pub pointer: Ty<'a>,
1555}
15561557#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OnlyCurrentTraitsTy<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OnlyCurrentTraitsTy { span: __binding_0, ty: __binding_1 }
=> {
diag.store_args();
diag.arg("ty", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` is not defined in the current crate")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1558#[label("`{$ty}` is not defined in the current crate")]
1559pub(crate) struct OnlyCurrentTraitsTy<'a> {
1560#[primary_span]
1561pub span: Span,
1562pub ty: Ty<'a>,
1563}
15641565#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OnlyCurrentTraitsAdt {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OnlyCurrentTraitsAdt { span: __binding_0, name: __binding_1
} => {
diag.store_args();
diag.arg("name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` is not defined in the current crate")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1566#[label("`{$name}` is not defined in the current crate")]
1567pub(crate) struct OnlyCurrentTraitsAdt {
1568#[primary_span]
1569pub span: Span,
1570pub name: String,
1571}
15721573#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
OnlyCurrentTraitsPointerSugg<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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_21 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("WrapperType"))
});
let __code_22 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("struct WrapperType(*{0}{1});\n\n",
__binding_2, __binding_3))
});
suggestions.push((__binding_0, __code_21));
suggestions.push((__binding_1, __code_22));
diag.store_args();
diag.arg("mut_key", __binding_2);
diag.arg("ptr_ty", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider introducing a new wrapper type")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1574#[multipart_suggestion(
1575"consider introducing a new wrapper type",
1576 applicability = "maybe-incorrect"
1577)]
1578pub(crate) struct OnlyCurrentTraitsPointerSugg<'a> {
1579#[suggestion_part(code = "WrapperType")]
1580pub wrapper_span: Span,
1581#[suggestion_part(code = "struct WrapperType(*{mut_key}{ptr_ty});\n\n")]
1582pub(crate) struct_span: Span,
1583pub mut_key: &'a str,
1584pub ptr_ty: Ty<'a>,
1585}
15861587#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedDelegation<'a> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1588#[diag("{$descr}")]
1589pub(crate) struct UnsupportedDelegation<'a> {
1590#[primary_span]
1591pub span: Span,
1592pub descr: &'a str,
1593#[label("callee defined here")]
1594pub callee_span: Span,
1595}
15961597#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MethodShouldReturnFuture where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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.arg("method_name", __binding_1);
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)]
1598#[diag("method should be `async` or return a future, but it is synchronous")]
1599pub(crate) struct MethodShouldReturnFuture {
1600#[primary_span]
1601pub span: Span,
1602pub method_name: Ident,
1603#[note("this method is `async` so it expects a future to be returned")]
1604pub trait_item_span: Option<Span>,
1605}
16061607#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedGenericParameter where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1608#[diag("{$param_def_kind} `{$param_name}` is never used")]
1609pub(crate) struct UnusedGenericParameter {
1610#[primary_span]
1611 #[label("unused {$param_def_kind}")]
1612pub span: Span,
1613pub param_name: Ident,
1614pub param_def_kind: &'static str,
1615#[label("`{$param_name}` is named here, but is likely unused in the containing type")]
1616pub usage_spans: Vec<Span>,
1617#[subdiagnostic]
1618pub help: UnusedGenericParameterHelp,
1619#[help(
1620"if you intended `{$param_name}` to be a const parameter, use `const {$param_name}: /* Type */` instead"
1621)]
1622pub const_param_help: bool,
1623}
16241625#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RecursiveGenericParameter where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1626#[diag("{$param_def_kind} `{$param_name}` is only used recursively")]
1627pub(crate) struct RecursiveGenericParameter {
1628#[primary_span]
1629pub spans: Vec<Span>,
1630#[label("{$param_def_kind} must be used non-recursively in the definition")]
1631pub param_span: Span,
1632pub param_name: Ident,
1633pub param_def_kind: &'static str,
1634#[subdiagnostic]
1635pub help: UnusedGenericParameterHelp,
1636#[note(
1637"all type parameters must be used in a non-recursive way in order to constrain their variance"
1638)]
1639pub note: (),
1640}
16411642#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedGenericParameterHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnusedGenericParameterHelp::Adt {
param_name: __binding_0, phantom_data: __binding_1 } => {
diag.store_args();
diag.arg("param_name", __binding_0);
diag.arg("phantom_data", __binding_1);
let __message =
diag.eagerly_translate(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}`")));
diag.help(__message);
diag.restore_args();
}
UnusedGenericParameterHelp::AdtNoPhantomData {
param_name: __binding_0 } => {
diag.store_args();
diag.arg("param_name", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing `{$param_name}` or referring to it in a field")));
diag.help(__message);
diag.restore_args();
}
UnusedGenericParameterHelp::TyAlias {
param_name: __binding_0 } => {
diag.store_args();
diag.arg("param_name", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing `{$param_name}` or referring to it in the body of the type alias")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1643pub(crate) enum UnusedGenericParameterHelp {
1644#[help(
1645"consider removing `{$param_name}`, referring to it in a field, or using a marker such as `{$phantom_data}`"
1646)]
1647Adt { param_name: Ident, phantom_data: String },
1648#[help("consider removing `{$param_name}` or referring to it in a field")]
1649AdtNoPhantomData { param_name: Ident },
1650#[help("consider removing `{$param_name}` or referring to it in the body of the type alias")]
1651TyAlias { param_name: Ident },
1652}
16531654#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnconstrainedGenericParameter where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1655#[diag(
1656"the {$param_def_kind} `{$param_name}` is not constrained by the impl trait, self type, or predicates"
1657)]
1658pub(crate) struct UnconstrainedGenericParameter {
1659#[primary_span]
1660 #[label("unconstrained {$param_def_kind}")]
1661pub span: Span,
1662pub param_name: Ident,
1663pub param_def_kind: &'static str,
1664#[note("expressions using a const parameter must map each value to a distinct output value")]
1665pub const_param_note: bool,
1666#[note(
1667"proving the result of expressions other than the parameter are unique is not supported"
1668)]
1669pub const_param_note2: bool,
1670}
16711672#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OpaqueCapturesHigherRankedLifetime where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1673#[diag("`impl Trait` cannot capture {$bad_place}", code = E0657)]
1674pub(crate) struct OpaqueCapturesHigherRankedLifetime {
1675#[primary_span]
1676pub span: MultiSpan,
1677#[label("`impl Trait` implicitly captures all lifetimes in scope")]
1678pub label: Option<Span>,
1679#[note("lifetime declared here")]
1680pub decl_span: MultiSpan,
1681pub bad_place: &'static str,
1682}
16831684#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidReceiverTyHint {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidReceiverTyHint::Weak => {
diag.store_args();
let __message =
diag.eagerly_translate(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`")));
diag.note(__message);
diag.restore_args();
}
InvalidReceiverTyHint::NonNull => {
diag.store_args();
let __message =
diag.eagerly_translate(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`")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1685pub(crate) enum InvalidReceiverTyHint {
1686#[note(
1687"`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`"
1688)]
1689Weak,
1690#[note(
1691"`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`"
1692)]
1693NonNull,
1694}
16951696#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidReceiverTyNoArbitrarySelfTypes<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1697#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1698#[note("type of `self` must be `Self` or a type that dereferences to it")]
1699#[help(
1700"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`)"
1701)]
1702pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
1703#[primary_span]
1704pub span: Span,
1705pub receiver_ty: Ty<'tcx>,
1706}
17071708#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidReceiverTy<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1709#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1710#[note("type of `self` must be `Self` or some type implementing `Receiver`")]
1711#[help(
1712"consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`"
1713)]
1714pub(crate) struct InvalidReceiverTy<'tcx> {
1715#[primary_span]
1716pub span: Span,
1717pub receiver_ty: Ty<'tcx>,
1718#[subdiagnostic]
1719pub hint: Option<InvalidReceiverTyHint>,
1720}
17211722#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidGenericReceiverTy<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1723#[diag("invalid generic `self` parameter type: `{$receiver_ty}`", code = E0801)]
1724#[note("type of `self` must not be a method generic parameter type")]
1725#[help(
1726"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`)"
1727)]
1728pub(crate) struct InvalidGenericReceiverTy<'tcx> {
1729#[primary_span]
1730pub span: Span,
1731pub receiver_ty: Ty<'tcx>,
1732}
17331734#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CmseInputsStackSpill where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1735#[diag("arguments for `{$abi}` function too large to pass via registers", code = E0798)]
1736#[note(
1737"functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit argument registers"
1738)]
1739pub(crate) struct CmseInputsStackSpill {
1740#[primary_span]
1741 #[label("does not fit in the available registers")]
1742pub spans: Vec<Span>,
1743pub abi: ExternAbi,
1744}
17451746#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CmseOutputStackSpill where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1747#[diag("return value of `{$abi}` function too large to pass via registers", code = E0798)]
1748#[note("functions with the `{$abi}` ABI must pass their result via the available return registers")]
1749#[note(
1750"the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size"
1751)]
1752pub(crate) struct CmseOutputStackSpill {
1753#[primary_span]
1754 #[label("this type doesn't fit in the available registers")]
1755pub span: Span,
1756pub abi: ExternAbi,
1757}
17581759#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CmseGeneric
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1760#[diag("generics are not allowed in `extern {$abi}` signatures", code = E0798)]
1761pub(crate) struct CmseGeneric {
1762#[primary_span]
1763pub span: Span,
1764pub abi: ExternAbi,
1765}
17661767#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CmseImplTrait
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1768#[diag("`impl Trait` is not allowed in `extern {$abi}` signatures", code = E0798)]
1769pub(crate) struct CmseImplTrait {
1770#[primary_span]
1771pub span: Span,
1772pub abi: ExternAbi,
1773}
17741775#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BadReturnTypeNotation where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BadReturnTypeNotation { span: __binding_0 } => {
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")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1776#[diag("return type notation not allowed in this position yet")]
1777pub(crate) struct BadReturnTypeNotation {
1778#[primary_span]
1779pub span: Span,
1780}
17811782#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
SupertraitItemShadowing {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
SupertraitItemShadowing {
item: __binding_0,
subtrait: __binding_1,
shadowee: __binding_2 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
1783#[diag("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")]
1784pub(crate) struct SupertraitItemShadowing {
1785pub item: Symbol,
1786pub subtrait: Symbol,
1787#[subdiagnostic]
1788pub shadowee: SupertraitItemShadowee,
1789}
17901791#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SupertraitItemShadowee {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SupertraitItemShadowee::Labeled {
span: __binding_0, supertrait: __binding_1 } => {
diag.store_args();
diag.arg("supertrait", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item from `{$supertrait}` is shadowed by a subtrait item")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
SupertraitItemShadowee::Several {
spans: __binding_0, traits: __binding_1 } => {
diag.store_args();
diag.arg("traits", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items from several supertraits are shadowed: {$traits}")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1792pub(crate) enum SupertraitItemShadowee {
1793#[note("item from `{$supertrait}` is shadowed by a subtrait item")]
1794Labeled {
1795#[primary_span]
1796span: Span,
1797 supertrait: Symbol,
1798 },
1799#[note("items from several supertraits are shadowed: {$traits}")]
1800Several {
1801#[primary_span]
1802spans: MultiSpan,
1803 traits: DiagSymbolList,
1804 },
1805}
18061807#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DynTraitAssocItemBindingMentionsSelf where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1808#[diag("{$kind} binding in trait object type mentions `Self`")]
1809pub(crate) struct DynTraitAssocItemBindingMentionsSelf {
1810#[primary_span]
1811 #[label("contains a mention of `Self`")]
1812pub span: Span,
1813pub kind: &'static str,
1814#[label("this binding mentions `Self`")]
1815pub binding: Span,
1816}
18171818#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiCustomClothedFunction where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AbiCustomClothedFunction {
span: __binding_0, naked_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items with the \"custom\" ABI can only be declared externally or defined via naked functions")));
let __code_23 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#[unsafe(naked)]\n"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert this to an `#[unsafe(naked)]` function")),
__code_23, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
1819#[diag(
1820"items with the \"custom\" ABI can only be declared externally or defined via naked functions"
1821)]
1822pub(crate) struct AbiCustomClothedFunction {
1823#[primary_span]
1824pub span: Span,
1825#[suggestion(
1826"convert this to an `#[unsafe(naked)]` function",
1827 applicability = "maybe-incorrect",
1828 code = "#[unsafe(naked)]\n",
1829 style = "short"
1830)]
1831pub naked_span: Span,
1832}
18331834#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AsyncDropWithoutSyncDrop where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1835#[diag("`AsyncDrop` impl without `Drop` impl")]
1836#[help(
1837"type implementing `AsyncDrop` trait must also implement `Drop` trait to be used in sync context and unwinds"
1838)]
1839pub(crate) struct AsyncDropWithoutSyncDrop {
1840#[primary_span]
1841pub span: Span,
1842}
18431844#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LifetimesOrBoundsMismatchOnEii where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1845#[diag("lifetime parameters or bounds of `{$ident}` do not match the declaration")]
1846pub(crate) struct LifetimesOrBoundsMismatchOnEii {
1847#[primary_span]
1848 #[label("lifetimes do not match")]
1849pub span: Span,
1850#[label("lifetimes in impl do not match this signature")]
1851pub generics_span: Span,
1852#[label("this `where` clause might not match the one in the trait")]
1853pub where_span: Option<Span>,
1854#[label("this bound might be missing in the impl")]
1855pub bounds_span: Vec<Span>,
1856pub ident: Symbol,
1857}
18581859#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EiiWithGenerics where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1860#[diag("`{$impl_name}` cannot have generic parameters other than lifetimes")]
1861#[help("`#[{$eii_name}]` marks the implementation of an \"externally implementable item\"")]
1862pub(crate) struct EiiWithGenerics {
1863#[primary_span]
1864pub span: Span,
1865#[label("required by this attribute")]
1866pub attr: Span,
1867pub eii_name: Symbol,
1868pub impl_name: Symbol,
1869}
18701871#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ImplUnpinForPinProjectedType where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1872#[diag("explicit impls for the `Unpin` trait are not permitted for structurally pinned types")]
1873pub(crate) struct ImplUnpinForPinProjectedType {
1874#[primary_span]
1875 #[label("impl of `Unpin` not allowed")]
1876pub span: Span,
1877#[help("`{$adt_name}` is structurally pinned because it is marked as `#[pin_v2]`")]
1878pub adt_span: Span,
1879pub adt_name: Symbol,
1880}