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, listify, msg,
8};
9use rustc_hir::limit::Limit;
10use rustc_macros::{Diagnostic, 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_format(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,
assoc_ident: __binding_1,
assoc_kind: __binding_2 } => {
diag.store_args();
diag.arg("assoc_ident", __binding_1);
diag.arg("assoc_kind", __binding_2);
let __message =
diag.eagerly_format(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_format(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 assoc_ident: Ident,
92 assoc_kind: &'static str,
93 },
94#[label(
95"there is {$identically_named ->
96 [true] an
97 *[false] a similarly named
98 } associated {$assoc_kind} `{$suggested_name}` in the trait `{$trait_name}`"
99)]
100FoundInOtherTrait {
101#[primary_span]
102span: Span,
103 assoc_kind: &'static str,
104 trait_name: &'a str,
105 suggested_name: Symbol,
106 identically_named: bool,
107 },
108}
109110#[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_format(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_format(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,
assoc_kind: __binding_6,
applicability: __binding_7 } => {
let mut suggestions = Vec::new();
let __code_4 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<"))
});
let __code_5 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" as {0}>", __binding_3))
});
let __code_6 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
});
suggestions.push((__binding_0, __code_4));
suggestions.push((__binding_1, __code_5));
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_6));
}
diag.store_args();
diag.arg("trait_ref", __binding_3);
diag.arg("suggested_name", __binding_4);
diag.arg("identically_named", __binding_5);
diag.arg("assoc_kind", __binding_6);
let __message =
diag.eagerly_format(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_7, 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_format(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)]
111112pub(crate) enum AssocItemNotFoundSugg<'a> {
113#[suggestion(
114"there is an associated {$assoc_kind} with a similar name",
115 code = "{suggested_name}",
116 applicability = "maybe-incorrect"
117)]
118Similar {
119#[primary_span]
120span: Span,
121 assoc_kind: &'static str,
122 suggested_name: Symbol,
123 },
124#[suggestion(
125"change the associated {$assoc_kind} name to use `{$suggested_name}` from `{$trait_name}`",
126 code = "{suggested_name}",
127 style = "verbose",
128 applicability = "maybe-incorrect"
129)]
130SimilarInOtherTrait {
131#[primary_span]
132span: Span,
133 trait_name: &'a str,
134 assoc_kind: &'static str,
135 suggested_name: Symbol,
136 },
137#[multipart_suggestion(
138"consider fully qualifying{$identically_named ->
139 [true] {\"\"}
140 *[false] {\" \"}and renaming
141 } the associated {$assoc_kind}",
142 style = "verbose"
143)]
144SimilarInOtherTraitQPath {
145#[suggestion_part(code = "<")]
146lo: Span,
147#[suggestion_part(code = " as {trait_ref}>")]
148mi: Span,
149#[suggestion_part(code = "{suggested_name}")]
150hi: Option<Span>,
151 trait_ref: String,
152 suggested_name: Symbol,
153 identically_named: bool,
154 assoc_kind: &'static str,
155#[applicability]
156applicability: Applicability,
157 },
158#[suggestion(
159"`{$qself}` has the following associated {$assoc_kind}",
160 code = "{suggested_name}",
161 applicability = "maybe-incorrect"
162)]
163Other {
164#[primary_span]
165span: Span,
166 qself: &'a str,
167 assoc_kind: &'static str,
168 suggested_name: Symbol,
169 },
170}
171172#[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)]
173#[diag("intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}", code = E0094)]
174pub(crate) struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
175#[primary_span]
176 #[label(
177"expected {$expected} {$descr} {$expected ->
178 [one] parameter
179 *[other] parameters
180 }"
181)]
182pub span: Span,
183pub found: usize,
184pub expected: usize,
185pub descr: &'a str,
186}
187188#[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)]
189#[diag("unrecognized intrinsic function: `{$name}`", code = E0093)]
190#[help("if you're adding an intrinsic, be sure to update `check_intrinsic_type`")]
191pub(crate) struct UnrecognizedIntrinsicFunction {
192#[primary_span]
193 #[label("unrecognized intrinsic")]
194pub span: Span,
195pub name: Symbol,
196}
197198#[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)]
199#[diag("lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration", code = E0195)]
200pub(crate) struct LifetimesOrBoundsMismatchOnTrait {
201#[primary_span]
202 #[label("lifetimes do not match {$item_kind} in trait")]
203pub span: Span,
204#[label("lifetimes in impl do not match this {$item_kind} in trait")]
205pub generics_span: Span,
206#[label("this `where` clause might not match the one in the trait")]
207pub where_span: Option<Span>,
208#[label("this bound might be missing in the impl")]
209pub bounds_span: Vec<Span>,
210pub item_kind: &'static str,
211pub ident: Ident,
212}
213214#[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)]
215#[diag("the `{$trait_}` trait may only be implemented for local structs, enums, and unions", code = E0120)]
216pub(crate) struct DropImplOnWrongItem {
217#[primary_span]
218 #[label("must be a struct, enum, or union in the current crate")]
219pub span: Span,
220pub trait_: Symbol,
221}
222223#[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)]
224pub(crate) enum FieldAlreadyDeclared {
225#[diag("field `{$field_name}` is already declared", code = E0124)]
226NotNested {
227 field_name: Ident,
228#[primary_span]
229 #[label("field already declared")]
230span: Span,
231#[label("`{$field_name}` first declared here")]
232prev_span: Span,
233 },
234#[diag("field `{$field_name}` is already declared")]
235CurrentNested {
236 field_name: Ident,
237#[primary_span]
238 #[label("field `{$field_name}` declared in this unnamed field")]
239span: Span,
240#[note("field `{$field_name}` declared here")]
241nested_field_span: Span,
242#[subdiagnostic]
243help: FieldAlreadyDeclaredNestedHelp,
244#[label("`{$field_name}` first declared here")]
245prev_span: Span,
246 },
247#[diag("field `{$field_name}` is already declared")]
248PreviousNested {
249 field_name: Ident,
250#[primary_span]
251 #[label("field already declared")]
252span: Span,
253#[label("`{$field_name}` first declared here in this unnamed field")]
254prev_span: Span,
255#[note("field `{$field_name}` first declared here")]
256prev_nested_field_span: Span,
257#[subdiagnostic]
258prev_help: FieldAlreadyDeclaredNestedHelp,
259 },
260#[diag("field `{$field_name}` is already declared")]
261BothNested {
262 field_name: Ident,
263#[primary_span]
264 #[label("field `{$field_name}` declared in this unnamed field")]
265span: Span,
266#[note("field `{$field_name}` declared here")]
267nested_field_span: Span,
268#[subdiagnostic]
269help: FieldAlreadyDeclaredNestedHelp,
270#[label("`{$field_name}` first declared here in this unnamed field")]
271prev_span: Span,
272#[note("field `{$field_name}` first declared here")]
273prev_nested_field_span: Span,
274#[subdiagnostic]
275prev_help: FieldAlreadyDeclaredNestedHelp,
276 },
277}
278279#[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_format(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)]
280#[help("fields from the type of this unnamed field are considered fields of the outer type")]
281pub(crate) struct FieldAlreadyDeclaredNestedHelp {
282#[primary_span]
283pub span: Span,
284}
285286#[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)]
287#[diag("the trait `Copy` cannot be implemented for this type; the type has a destructor", code = E0184)]
288pub(crate) struct CopyImplOnTypeWithDtor {
289#[primary_span]
290 #[label("`Copy` not allowed on types with destructors")]
291pub span: Span,
292#[note("destructor declared here")]
293pub impl_: Span,
294}
295296#[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)]
297#[diag("the trait `Copy` cannot be implemented for this type", code = E0206)]
298pub(crate) struct CopyImplOnNonAdt {
299#[primary_span]
300 #[label("type is not a structure or enumeration")]
301pub span: Span,
302}
303304#[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)]
305#[diag("the trait `ConstParamTy` may not be implemented for this type")]
306pub(crate) struct ConstParamTyImplOnUnsized {
307#[primary_span]
308 #[label("type is not `Sized`")]
309pub span: Span,
310}
311312#[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)]
313#[diag("the trait `ConstParamTy` may not be implemented for this type")]
314pub(crate) struct ConstParamTyImplOnNonAdt {
315#[primary_span]
316 #[label("type is not a structure or enumeration")]
317pub span: Span,
318}
319320#[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)]
321#[diag("at least one trait is required for an object type", code = E0224)]
322pub(crate) struct TraitObjectDeclaredWithNoTraits {
323#[primary_span]
324pub span: Span,
325#[label("this alias does not contain a trait")]
326pub trait_alias_span: Option<Span>,
327}
328329#[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)]
330#[diag("ambiguous lifetime bound, explicit lifetime bound required", code = E0227)]
331pub(crate) struct AmbiguousLifetimeBound {
332#[primary_span]
333pub span: Span,
334}
335336#[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)]
337#[diag("associated item constraints are not allowed here", code = E0229)]
338pub(crate) struct AssocItemConstraintsNotAllowedHere {
339#[primary_span]
340 #[label("associated item constraint not allowed here")]
341pub span: Span,
342343#[subdiagnostic]
344pub fn_trait_expansion: Option<ParenthesizedFnTraitExpansion>,
345}
346347#[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)]
348#[diag(
349"the type of the associated constant `{$assoc_const}` must not depend on {$param_category ->
350 [self] `Self`
351 [synthetic] `impl Trait`
352 *[normal] generic parameters
353 }"
354)]
355pub(crate) struct ParamInTyOfAssocConstBinding<'tcx> {
356#[primary_span]
357 #[label(
358"its type must not depend on {$param_category ->
359 [self] `Self`
360 [synthetic] `impl Trait`
361 *[normal] the {$param_def_kind} `{$param_name}`
362 }"
363)]
364pub span: Span,
365pub assoc_const: Ident,
366pub param_name: Symbol,
367pub param_def_kind: &'static str,
368pub param_category: &'static str,
369#[label(
370"{$param_category ->
371 [synthetic] the `impl Trait` is specified here
372 *[normal] the {$param_def_kind} `{$param_name}` is defined here
373 }"
374)]
375pub param_defined_here_label: Option<Span>,
376#[subdiagnostic]
377pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
378}
379380#[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_format(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)]
381#[note("`{$assoc_const}` has type `{$ty}`")]
382pub(crate) struct TyOfAssocConstBindingNote<'tcx> {
383pub assoc_const: Ident,
384pub ty: Ty<'tcx>,
385}
386387#[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)]
388#[diag(
389"the type of the associated constant `{$assoc_const}` cannot capture late-bound generic parameters"
390)]
391pub(crate) struct EscapingBoundVarInTyOfAssocConstBinding<'tcx> {
392#[primary_span]
393 #[label("its type cannot capture the late-bound {$var_def_kind} `{$var_name}`")]
394pub span: Span,
395pub assoc_const: Ident,
396pub var_name: Symbol,
397pub var_def_kind: &'static str,
398#[label("the late-bound {$var_def_kind} `{$var_name}` is defined here")]
399pub var_defined_here_label: Span,
400#[subdiagnostic]
401pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
402}
403404#[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_format(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)]
405#[help("parenthesized trait syntax expands to `{$expanded_type}`")]
406pub(crate) struct ParenthesizedFnTraitExpansion {
407#[primary_span]
408pub span: Span,
409410pub expanded_type: String,
411}
412413#[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)]
414#[diag("the value of the associated type `{$item_name}` in trait `{$def_path}` is already specified", code = E0719)]
415pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
416#[primary_span]
417 #[label("re-bound here")]
418pub span: Span,
419#[label("`{$item_name}` bound here first")]
420pub prev_span: Span,
421pub item_name: Ident,
422pub def_path: String,
423}
424425#[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)]
426#[diag("unconstrained opaque type")]
427#[note("`{$name}` must be used in combination with a concrete type within the same {$what}")]
428pub(crate) struct UnconstrainedOpaqueType {
429#[primary_span]
430pub span: Span,
431pub name: Ident,
432pub what: &'static str,
433}
434435pub(crate) struct MissingGenericParams {
436pub span: Span,
437pub def_span: Span,
438pub span_snippet: Option<String>,
439pub missing_generic_params: Vec<(Symbol, ty::GenericParamDefKind)>,
440pub empty_generic_args: bool,
441}
442443// FIXME: This doesn't need to be a manual impl!
444impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MissingGenericParams {
445#[track_caller]
446fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
447let mut err = Diag::new(
448dcx,
449level,
450rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$descr} {$parameterCount ->\n [one] parameter\n *[other] parameters\n } {$parameters} must be explicitly specified"))msg!(
451"the {$descr} {$parameterCount ->
452 [one] parameter
453 *[other] parameters
454 } {$parameters} must be explicitly specified"
455),
456 );
457err.span(self.span);
458err.code(E0393);
459err.span_label(
460self.def_span,
461rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr} {$parameterCount ->\n [one] parameter\n *[other] parameters\n } {$parameters} must be specified for this"))msg!(
462"{$descr} {$parameterCount ->
463 [one] parameter
464 *[other] parameters
465 } {$parameters} must be specified for this"
466),
467 );
468469enum Descr {
470 Generic,
471 Type,
472 Const,
473 }
474475let mut descr = None;
476for (_, kind) in &self.missing_generic_params {
477 descr = match (&descr, kind) {
478 (None, ty::GenericParamDefKind::Type { .. }) => Some(Descr::Type),
479 (None, ty::GenericParamDefKind::Const { .. }) => Some(Descr::Const),
480 (Some(Descr::Type), ty::GenericParamDefKind::Const { .. })
481 | (Some(Descr::Const), ty::GenericParamDefKind::Type { .. }) => {
482Some(Descr::Generic)
483 }
484_ => continue,
485 }
486 }
487488err.arg(
489"descr",
490match descr.unwrap() {
491 Descr::Generic => "generic",
492 Descr::Type => "type",
493 Descr::Const => "const",
494 },
495 );
496err.arg("parameterCount", self.missing_generic_params.len());
497err.arg(
498"parameters",
499listify(&self.missing_generic_params, |(n, _)| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", n))
})format!("`{n}`")).unwrap(),
500 );
501502let mut suggested = false;
503// Don't suggest setting the generic params if there are some already: The order is
504 // tricky to get right and the user will already know what the syntax is.
505if let Some(snippet) = self.span_snippet
506 && self.empty_generic_args
507 {
508if snippet.ends_with('>') {
509// The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion
510 // we would have to preserve the right order. For now, as clearly the user is
511 // aware of the syntax, we do nothing.
512} else {
513// The user wrote `Trait`, so we don't have a type we can suggest, but at
514 // least we can clue them to the correct syntax `Trait</* Term */>`.
515err.span_suggestion_verbose(
516self.span.shrink_to_hi(),
517rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly specify the {$descr} {$parameterCount ->\n [one] parameter\n *[other] parameters\n }"))msg!(
518"explicitly specify the {$descr} {$parameterCount ->
519 [one] parameter
520 *[other] parameters
521 }"
522),
523::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!(
524"<{}>",
525self.missing_generic_params
526 .iter()
527 .map(|(n, _)| format!("/* {n} */"))
528 .collect::<Vec<_>>()
529 .join(", ")
530 ),
531 Applicability::HasPlaceholders,
532 );
533suggested = true;
534 }
535 }
536if !suggested {
537err.span_label(
538self.span,
539rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing {$parameterCount ->\n [one] reference\n *[other] references\n } to {$parameters}"))msg!(
540"missing {$parameterCount ->
541 [one] reference
542 *[other] references
543 } to {$parameters}"
544),
545 );
546 }
547548err.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("because the parameter {$parameterCount ->\n [one] default references\n *[other] defaults reference\n } `Self`, the {$parameterCount ->\n [one] parameter\n *[other] parameters\n } must be specified on the trait object type"))msg!(
549"because the parameter {$parameterCount ->
550 [one] default references
551 *[other] defaults reference
552 } `Self`, the {$parameterCount ->
553 [one] parameter
554 *[other] parameters
555 } must be specified on the trait object type"
556));
557err558 }
559}
560561#[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)]
562#[diag("manual implementations of `{$trait_name}` are experimental", code = E0183)]
563#[help("add `#![feature(unboxed_closures)]` to the crate attributes to enable")]
564pub(crate) struct ManualImplementation {
565#[primary_span]
566 #[label("manual implementations of `{$trait_name}` are experimental")]
567pub span: Span,
568pub trait_name: String,
569}
570571#[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)]
572#[diag("could not resolve generic parameters on overridden impl")]
573pub(crate) struct GenericArgsOnOverriddenImpl {
574#[primary_span]
575pub span: Span,
576}
577578#[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)]
579#[diag("const `impl` for trait `{$trait_name}` which is not `const`")]
580pub(crate) struct ConstImplForNonConstTrait {
581#[primary_span]
582 #[label("this trait is not `const`")]
583pub trait_ref_span: Span,
584pub trait_name: String,
585#[suggestion(
586"{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations",
587 applicability = "machine-applicable",
588 code = "const ",
589 style = "verbose"
590)]
591pub suggestion: Option<Span>,
592pub suggestion_pre: &'static str,
593#[note("marking a trait with `const` ensures all default method bodies are `const`")]
594pub marking: (),
595#[note("adding a non-const method body in the future would be a breaking change")]
596pub adding: (),
597}
598599#[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)]
600#[diag("`{$modifier}` can only be applied to `const` traits")]
601pub(crate) struct ConstBoundForNonConstTrait {
602#[primary_span]
603 #[label("can't be applied to `{$trait_name}`")]
604pub span: Span,
605pub modifier: &'static str,
606#[note("`{$trait_name}` can't be used with `{$modifier}` because it isn't `const`")]
607pub def_span: Option<Span>,
608#[suggestion(
609"{$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations",
610 applicability = "machine-applicable",
611 code = "const ",
612 style = "verbose"
613)]
614pub suggestion: Option<Span>,
615pub suggestion_pre: &'static str,
616pub trait_name: String,
617}
618619#[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)]
620#[diag("`Self` is not valid in the self type of an impl block")]
621pub(crate) struct SelfInImplSelf {
622#[primary_span]
623pub span: MultiSpan,
624#[note("replace `Self` with a different type")]
625pub note: (),
626}
627628#[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)]
629#[diag("invalid type for variable with `#[linkage]` attribute", code = E0791)]
630pub(crate) struct LinkageType {
631#[primary_span]
632pub span: Span,
633}
634635#[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)]
636#[help(
637"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
638)]
639#[diag("reached the recursion limit while auto-dereferencing `{$ty}`", code = E0055)]
640pub(crate) struct AutoDerefReachedRecursionLimit<'a> {
641#[primary_span]
642 #[label("deref recursion limit reached")]
643pub span: Span,
644pub ty: Ty<'a>,
645pub suggested_limit: Limit,
646pub crate_name: Symbol,
647}
648649#[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)]
650#[diag("`main` function is not allowed to have a `where` clause", code = E0646)]
651pub(crate) struct WhereClauseOnMain {
652#[primary_span]
653pub span: Span,
654#[label("`main` cannot have a `where` clause")]
655pub generics_span: Option<Span>,
656}
657658#[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)]
659#[diag("`main` function is not allowed to be `#[track_caller]`")]
660pub(crate) struct TrackCallerOnMain {
661#[primary_span]
662 #[suggestion("remove this annotation", applicability = "maybe-incorrect", code = "")]
663pub span: Span,
664#[label("`main` function is not allowed to be `#[track_caller]`")]
665pub annotated: Span,
666}
667668#[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)]
669#[diag("`main` function is not allowed to have `#[target_feature]`")]
670pub(crate) struct TargetFeatureOnMain {
671#[primary_span]
672 #[label("`main` function is not allowed to have `#[target_feature]`")]
673pub main: Span,
674}
675676#[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)]
677#[diag("`main` function return type is not allowed to have generic parameters", code = E0131)]
678pub(crate) struct MainFunctionReturnTypeGeneric {
679#[primary_span]
680pub span: Span,
681}
682683#[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)]
684#[diag("`main` function is not allowed to be `async`", code = E0752)]
685pub(crate) struct MainFunctionAsync {
686#[primary_span]
687pub span: Span,
688#[label("`main` function is not allowed to be `async`")]
689pub asyncness: Option<Span>,
690}
691692#[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)]
693#[diag("`main` function is not allowed to have generic parameters", code = E0131)]
694pub(crate) struct MainFunctionGenericParameters {
695#[primary_span]
696pub span: Span,
697#[label("`main` cannot have generic parameters")]
698pub label_span: Option<Span>,
699}
700701#[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)]
702#[diag("C-variadic functions with the {$convention} calling convention are not supported", code = E0045)]
703pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
704#[primary_span]
705 #[label("C-variadic function must have a compatible calling convention")]
706pub span: Span,
707pub convention: &'a str,
708}
709710#[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)]
711pub(crate) enum CannotCaptureLateBound {
712#[diag("cannot capture late-bound type parameter in {$what}")]
713Type {
714#[primary_span]
715use_span: Span,
716#[label("parameter defined here")]
717def_span: Span,
718 what: &'static str,
719 },
720#[diag("cannot capture late-bound const parameter in {$what}")]
721Const {
722#[primary_span]
723use_span: Span,
724#[label("parameter defined here")]
725def_span: Span,
726 what: &'static str,
727 },
728#[diag("cannot capture late-bound lifetime in {$what}")]
729Lifetime {
730#[primary_span]
731use_span: Span,
732#[label("lifetime defined here")]
733def_span: Span,
734 what: &'static str,
735 },
736}
737738#[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)]
739#[diag("{$ty}")]
740pub(crate) struct TypeOf<'tcx> {
741#[primary_span]
742pub span: Span,
743pub ty: Ty<'tcx>,
744}
745746#[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)]
747#[diag("field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union", code = E0740)]
748pub(crate) struct InvalidUnionField {
749#[primary_span]
750pub field_span: Span,
751#[subdiagnostic]
752pub sugg: InvalidUnionFieldSuggestion,
753#[note(
754"union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`"
755)]
756pub note: (),
757}
758759#[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)]
760#[diag(
761"return type notation used on function that is not `async` and does not return `impl Trait`"
762)]
763pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
764#[primary_span]
765pub span: Span,
766pub ty: Ty<'tcx>,
767#[label("this function must be `async` or return `impl Trait`")]
768pub fn_span: Option<Span>,
769#[note("function returns `{$ty}`, which is not compatible with associated type return bounds")]
770pub note: (),
771}
772773#[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_format(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)]
774#[multipart_suggestion(
775"wrap the field type in `ManuallyDrop<...>`",
776 applicability = "machine-applicable"
777)]
778pub(crate) struct InvalidUnionFieldSuggestion {
779#[suggestion_part(code = "std::mem::ManuallyDrop<")]
780pub lo: Span,
781#[suggestion_part(code = ">")]
782pub hi: Span,
783}
784785#[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)]
786#[diag("return type notation is not allowed to use type equality")]
787pub(crate) struct ReturnTypeNotationEqualityBound {
788#[primary_span]
789pub span: Span,
790}
791792#[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)]
793#[diag("the placeholder `_` is not allowed within types on item signatures for {$kind}", code = E0121)]
794pub(crate) struct PlaceholderNotAllowedItemSignatures {
795#[primary_span]
796 #[label("not allowed in type signatures")]
797pub spans: Vec<Span>,
798pub kind: String,
799}
800801#[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)]
802#[diag("cannot use the {$what} of a trait with uninferred generic parameters", code = E0212)]
803pub(crate) struct AssociatedItemTraitUninferredGenericParams {
804#[primary_span]
805pub span: Span,
806#[suggestion(
807"use a fully qualified path with inferred lifetimes",
808 style = "verbose",
809 applicability = "maybe-incorrect",
810 code = "{bound}"
811)]
812pub inferred_sugg: Option<Span>,
813pub bound: String,
814#[subdiagnostic]
815pub mpart_sugg: Option<AssociatedItemTraitUninferredGenericParamsMultipartSuggestion>,
816pub what: &'static str,
817}
818819#[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_format(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)]
820#[multipart_suggestion(
821"use a fully qualified path with explicit lifetimes",
822 applicability = "maybe-incorrect"
823)]
824pub(crate) struct AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
825#[suggestion_part(code = "{first}")]
826pub fspan: Span,
827pub first: String,
828#[suggestion_part(code = "{second}")]
829pub sspan: Span,
830pub second: String,
831}
832833#[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)]
834#[diag("enum discriminant overflowed", code = E0370)]
835#[note("explicitly set `{$item_name} = {$wrapped_discr}` if that is desired outcome")]
836pub(crate) struct EnumDiscriminantOverflowed {
837#[primary_span]
838 #[label("overflowed on value after {$discr}")]
839pub span: Span,
840pub discr: String,
841pub item_name: Ident,
842pub wrapped_discr: String,
843}
844845#[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)]
846#[diag(
847"the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation"
848)]
849#[help("add `#![feature(unboxed_closures)]` to the crate attributes to use it")]
850pub(crate) struct ParenSugarAttribute {
851#[primary_span]
852pub span: Span,
853}
854855#[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)]
856#[diag("use of SIMD type{$snip} in FFI is highly experimental and may result in invalid code")]
857#[help("add `#![feature(simd_ffi)]` to the crate attributes to enable")]
858pub(crate) struct SIMDFFIHighlyExperimental {
859#[primary_span]
860pub span: Span,
861pub snip: String,
862}
863864#[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)]
865pub(crate) enum ImplNotMarkedDefault {
866#[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
867 #[note("to specialize, `{$ident}` in the parent `impl` must be marked `default`")]
868Ok {
869#[primary_span]
870 #[label("cannot specialize default item `{$ident}`")]
871span: Span,
872#[label("parent `impl` is here")]
873ok_label: Span,
874 ident: Ident,
875 },
876#[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
877 #[note("parent implementation is in crate `{$cname}`")]
878Err {
879#[primary_span]
880span: Span,
881 cname: Symbol,
882 ident: Ident,
883 },
884}
885886#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UselessImplItem 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 {
UselessImplItem => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this item cannot be used as its where bounds are not satisfied for the `Self` type")));
;
diag
}
}
}
}
};Diagnostic)]
887#[diag("this item cannot be used as its where bounds are not satisfied for the `Self` type")]
888pub(crate) struct UselessImplItem;
889890#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OverridingFinalTraitFunction 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 {
OverridingFinalTraitFunction {
impl_span: __binding_0,
trait_span: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot override `{$ident}` because it already has a `final` definition in the trait")));
;
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is marked final here")));
diag
}
}
}
}
};Diagnostic)]
891#[diag("cannot override `{$ident}` because it already has a `final` definition in the trait")]
892pub(crate) struct OverridingFinalTraitFunction {
893#[primary_span]
894pub impl_span: Span,
895#[note("`{$ident}` is marked final here")]
896pub trait_span: Span,
897pub ident: Ident,
898}
899900#[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)]
901#[diag("not all trait items implemented, missing: `{$missing_items_msg}`", code = E0046)]
902pub(crate) struct MissingTraitItem {
903#[primary_span]
904 #[label("missing `{$missing_items_msg}` in implementation")]
905pub span: Span,
906#[subdiagnostic]
907pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
908#[subdiagnostic]
909pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
910#[subdiagnostic]
911pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
912pub missing_items_msg: String,
913}
914915#[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_format(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$item}` from trait")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
916#[label("`{$item}` from trait")]
917pub(crate) struct MissingTraitItemLabel {
918#[primary_span]
919pub span: Span,
920pub item: Symbol,
921}
922923#[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_format(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)]
924#[suggestion(
925"implement the missing item: `{$snippet}`",
926 style = "tool-only",
927 applicability = "has-placeholders",
928 code = "{code}"
929)]
930pub(crate) struct MissingTraitItemSuggestion {
931#[primary_span]
932pub span: Span,
933pub code: String,
934pub snippet: String,
935}
936937#[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_format(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)]
938#[suggestion(
939"implement the missing item: `{$snippet}`",
940 style = "hidden",
941 applicability = "has-placeholders",
942 code = "{code}"
943)]
944pub(crate) struct MissingTraitItemSuggestionNone {
945#[primary_span]
946pub span: Span,
947pub code: String,
948pub snippet: String,
949}
950951#[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)]
952#[diag("not all trait items implemented, missing one of: `{$missing_items_msg}`", code = E0046)]
953pub(crate) struct MissingOneOfTraitItem {
954#[primary_span]
955 #[label("missing one of `{$missing_items_msg}` in implementation")]
956pub span: Span,
957#[note("required because of this annotation")]
958pub note: Option<Span>,
959pub missing_items_msg: String,
960}
961962#[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)]
963#[diag("not all trait items implemented, missing: `{$missing_item_name}`", code = E0046)]
964#[note("default implementation of `{$missing_item_name}` is unstable")]
965pub(crate) struct MissingTraitItemUnstable {
966#[primary_span]
967pub span: Span,
968#[note("use of unstable library feature `{$feature}`: {$reason}")]
969pub some_note: bool,
970#[note("use of unstable library feature `{$feature}`")]
971pub none_note: bool,
972pub missing_item_name: Ident,
973pub feature: Symbol,
974pub reason: String,
975}
976977#[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)]
978#[diag("transparent enum needs exactly one variant, but has {$number}", code = E0731)]
979pub(crate) struct TransparentEnumVariant {
980#[primary_span]
981 #[label("needs exactly one variant, but has {$number}")]
982pub span: Span,
983#[label("variant here")]
984pub spans: Vec<Span>,
985#[label("too many variants in `{$path}`")]
986pub many: Option<Span>,
987pub number: usize,
988pub path: String,
989}
990991#[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)]
992#[diag("the variant of a transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}", code = E0690)]
993pub(crate) struct TransparentNonZeroSizedEnum<'a> {
994#[primary_span]
995 #[label("needs at most one field with non-trivial size or alignment, but has {$field_count}")]
996pub span: Span,
997#[label("this field has non-zero size or requires alignment")]
998pub spans: Vec<Span>,
999pub field_count: usize,
1000pub desc: &'a str,
1001}
10021003#[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)]
1004#[diag("transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}", code = E0690)]
1005pub(crate) struct TransparentNonZeroSized<'a> {
1006#[primary_span]
1007 #[label("needs at most one field with non-trivial size or alignment, but has {$field_count}")]
1008pub span: Span,
1009#[label("this field has non-zero size or requires alignment")]
1010pub spans: Vec<Span>,
1011pub field_count: usize,
1012pub desc: &'a str,
1013}
10141015#[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)]
1016#[diag("extern static is too large for the target architecture")]
1017pub(crate) struct TooLargeStatic {
1018#[primary_span]
1019pub span: Span,
1020}
10211022#[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)]
1023#[diag("implementing `rustc_specialization_trait` traits is unstable")]
1024#[help("add `#![feature(min_specialization)]` to the crate attributes to enable")]
1025pub(crate) struct SpecializationTrait {
1026#[primary_span]
1027pub span: Span,
1028}
10291030#[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)]
1031#[diag("implicit types in closure signatures are forbidden when `for<...>` is present")]
1032pub(crate) struct ClosureImplicitHrtb {
1033#[primary_span]
1034pub spans: Vec<Span>,
1035#[label("`for<...>` is here")]
1036pub for_sp: Span,
1037}
10381039#[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)]
1040#[diag("specialization impl does not specialize any associated items")]
1041pub(crate) struct EmptySpecialization {
1042#[primary_span]
1043pub span: Span,
1044#[note("impl is a specialization of this impl")]
1045pub base_impl_span: Span,
1046}
10471048#[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)]
1049#[diag("cannot specialize on `'static` lifetime")]
1050pub(crate) struct StaticSpecialize {
1051#[primary_span]
1052pub span: Span,
1053}
10541055#[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)]
1056pub(crate) enum DropImplPolarity {
1057#[diag("negative `Drop` impls are not supported")]
1058Negative {
1059#[primary_span]
1060span: Span,
1061 },
1062#[diag("reservation `Drop` impls are not supported")]
1063Reservation {
1064#[primary_span]
1065span: Span,
1066 },
1067}
10681069#[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)]
1070pub(crate) enum ReturnTypeNotationIllegalParam {
1071#[diag("return type notation is not allowed for functions that have type parameters")]
1072Type {
1073#[primary_span]
1074span: Span,
1075#[label("type parameter declared here")]
1076param_span: Span,
1077 },
1078#[diag("return type notation is not allowed for functions that have const parameters")]
1079Const {
1080#[primary_span]
1081span: Span,
1082#[label("const parameter declared here")]
1083param_span: Span,
1084 },
1085}
10861087#[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)]
1088pub(crate) enum LateBoundInApit {
1089#[diag("`impl Trait` can only mention type parameters from an fn or impl")]
1090Type {
1091#[primary_span]
1092span: Span,
1093#[label("type parameter declared here")]
1094param_span: Span,
1095 },
1096#[diag("`impl Trait` can only mention const parameters from an fn or impl")]
1097Const {
1098#[primary_span]
1099span: Span,
1100#[label("const parameter declared here")]
1101param_span: Span,
1102 },
1103#[diag("`impl Trait` can only mention lifetimes from an fn or impl")]
1104Lifetime {
1105#[primary_span]
1106span: Span,
1107#[label("lifetime declared here")]
1108param_span: Span,
1109 },
1110}
11111112#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedAssociatedTypeBounds 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 {
UnusedAssociatedTypeBounds { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary associated type bound for dyn-incompatible associated type")));
let __code_18 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized`")));
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this bound")),
__code_18, rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1113#[diag("unnecessary associated type bound for dyn-incompatible associated type")]
1114#[note(
1115"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`"
1116)]
1117pub(crate) struct UnusedAssociatedTypeBounds {
1118#[suggestion("remove this bound", code = "")]
1119pub span: Span,
1120}
11211122#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReturnPositionImplTraitInTraitRefined 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 {
ReturnPositionImplTraitInTraitRefined {
impl_return_span: __binding_0,
trait_return_span: __binding_1,
unmatched_bound: __binding_2,
pre: __binding_3,
post: __binding_4,
return_ty: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl trait in impl method signature does not match trait method signature")));
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}{2}{0}", __binding_4,
__binding_3, __binding_5))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information")));
;
diag.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
}
}
}
}
};Diagnostic)]
1123#[diag("impl trait in impl method signature does not match trait method signature")]
1124#[note(
1125"add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1126)]
1127#[note(
1128"we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1129)]
1130pub(crate) struct ReturnPositionImplTraitInTraitRefined {
1131#[suggestion(
1132"replace the return type so that it matches the trait",
1133 applicability = "maybe-incorrect",
1134 code = "{pre}{return_ty}{post}"
1135)]
1136pub impl_return_span: Span,
1137#[label("return type from trait method defined here")]
1138pub trait_return_span: Option<Span>,
1139#[label("this bound is stronger than that defined on the trait")]
1140pub unmatched_bound: Option<Span>,
11411142pub pre: &'static str,
1143pub post: &'static str,
1144pub return_ty: String,
1145}
11461147#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReturnPositionImplTraitInTraitRefinedLifetimes 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 {
ReturnPositionImplTraitInTraitRefinedLifetimes {
suggestion_span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl trait in impl method captures fewer lifetimes than in trait")));
let __code_20 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information")));
;
diag.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
}
}
}
}
};Diagnostic)]
1148#[diag("impl trait in impl method captures fewer lifetimes than in trait")]
1149#[note(
1150"add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1151)]
1152#[note(
1153"we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1154)]
1155pub(crate) struct ReturnPositionImplTraitInTraitRefinedLifetimes {
1156#[suggestion(
1157"modify the `use<..>` bound to capture the same lifetimes that the trait does",
1158 applicability = "maybe-incorrect",
1159 code = "{suggestion}"
1160)]
1161pub suggestion_span: Span,
1162pub suggestion: String,
1163}
11641165#[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)]
1166#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1167#[help("consider moving this inherent impl into the crate defining the type if possible")]
1168pub(crate) struct InherentTyOutside {
1169#[primary_span]
1170 #[help(
1171"alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items"
1172)]
1173pub span: Span,
1174}
11751176#[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)]
1177#[diag("structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`", code = E0378)]
1178pub(crate) struct DispatchFromDynRepr {
1179#[primary_span]
1180pub span: Span,
1181}
11821183#[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)]
1184#[diag("`derive(CoercePointee)` is only applicable to `struct`, instead of `{$kind}`", code = E0802)]
1185pub(crate) struct CoercePointeeNotStruct {
1186#[primary_span]
1187pub span: Span,
1188pub kind: String,
1189}
11901191#[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)]
1192#[diag("`derive(CoercePointee)` is only applicable to `struct`", code = E0802)]
1193pub(crate) struct CoercePointeeNotConcreteType {
1194#[primary_span]
1195pub span: Span,
1196}
11971198#[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)]
1199#[diag("asserting applicability of `derive(CoercePointee)` on a target data is forbidden", code = E0802)]
1200pub(crate) struct CoercePointeeNoUserValidityAssertion {
1201#[primary_span]
1202pub span: Span,
1203}
12041205#[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)]
1206#[diag("`derive(CoercePointee)` is only applicable to `struct` with `repr(transparent)` layout", code = E0802)]
1207pub(crate) struct CoercePointeeNotTransparent {
1208#[primary_span]
1209pub span: Span,
1210}
12111212#[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)]
1213#[diag("`CoercePointee` can only be derived on `struct`s with at least one field", code = E0802)]
1214pub(crate) struct CoercePointeeNoField {
1215#[primary_span]
1216pub span: Span,
1217}
12181219#[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)]
1220#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1221#[help("consider moving this inherent impl into the crate defining the type if possible")]
1222pub(crate) struct InherentTyOutsideRelevant {
1223#[primary_span]
1224pub span: Span,
1225#[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1226pub help_span: Span,
1227}
12281229#[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, note: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define inherent `impl` for a type outside of the crate where the type is defined")));
diag.code(E0116);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("impl for type defined outside of crate")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1230#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0116)]
1231#[help(
1232"consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it"
1233)]
1234#[note(
1235"for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>"
1236)]
1237pub(crate) struct InherentTyOutsideNew {
1238#[primary_span]
1239 #[label("impl for type defined outside of crate")]
1240pub span: Span,
1241#[subdiagnostic]
1242pub note: Option<InherentTyOutsideNewAliasNote>,
1243}
12441245#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InherentTyOutsideNewAliasNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InherentTyOutsideNewAliasNote {
span: __binding_0,
ty_name: __binding_1,
alias_ty_name: __binding_2 } => {
diag.store_args();
diag.arg("ty_name", __binding_1);
diag.arg("alias_ty_name", __binding_2);
let __message =
diag.eagerly_format(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty_name}` does not define a new type, only an alias of `{$alias_ty_name}` defined here")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1246#[note("`{$ty_name}` does not define a new type, only an alias of `{$alias_ty_name}` defined here")]
1247pub(crate) struct InherentTyOutsideNewAliasNote {
1248#[primary_span]
1249pub span: Span,
1250pub ty_name: String,
1251pub alias_ty_name: String,
1252}
12531254#[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)]
1255#[diag("cannot define inherent `impl` for primitive types outside of `core`", code = E0390)]
1256#[help("consider moving this inherent impl into `core` if possible")]
1257pub(crate) struct InherentTyOutsidePrimitive {
1258#[primary_span]
1259pub span: Span,
1260#[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1261pub help_span: Span,
1262}
12631264#[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)]
1265#[diag("cannot define inherent `impl` for primitive types", code = E0390)]
1266#[help("consider using an extension trait instead")]
1267pub(crate) struct InherentPrimitiveTy<'a> {
1268#[primary_span]
1269pub span: Span,
1270#[subdiagnostic]
1271pub note: Option<InherentPrimitiveTyNote<'a>>,
1272}
12731274#[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_format(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)]
1275#[note(
1276"you could also try moving the reference to uses of `{$subty}` (such as `self`) within the implementation"
1277)]
1278pub(crate) struct InherentPrimitiveTyNote<'a> {
1279pub subty: Ty<'a>,
1280}
12811282#[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)]
1283#[diag("cannot define inherent `impl` for a dyn auto trait", code = E0785)]
1284#[note("define and implement a new trait or type instead")]
1285pub(crate) struct InherentDyn {
1286#[primary_span]
1287 #[label("impl requires at least one non-auto trait")]
1288pub span: Span,
1289}
12901291#[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)]
1292#[diag("no nominal type found for inherent implementation", code = E0118)]
1293#[note("either implement a trait on it or create a newtype to wrap it instead")]
1294pub(crate) struct InherentNominal {
1295#[primary_span]
1296 #[label("impl requires a nominal type")]
1297pub span: Span,
1298}
12991300#[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)]
1301#[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)]
1302#[note("extra field `{$name}` of type `{$ty}` is not allowed")]
1303pub(crate) struct DispatchFromDynZST<'a> {
1304#[primary_span]
1305pub span: Span,
1306pub name: Ident,
1307pub ty: Ty<'a>,
1308}
13091310#[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)]
1311#[diag("implementing `{$trait_name}` requires a field to be coerced", code = E0374)]
1312pub(crate) struct CoerceNoField {
1313#[primary_span]
1314pub span: Span,
1315pub trait_name: &'static str,
1316#[note("expected a single field to be coerced, none found")]
1317pub note: bool,
1318}
13191320#[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)]
1321#[diag("implementing `{$trait_name}` does not allow multiple fields to be coerced", code = E0375)]
1322pub(crate) struct CoerceMulti {
1323pub trait_name: &'static str,
1324#[primary_span]
1325pub span: Span,
1326pub number: usize,
1327#[note(
1328"the trait `{$trait_name}` may only be implemented when a single field is being coerced"
1329)]
1330pub fields: MultiSpan,
1331}
13321333#[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)]
1334#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1335pub(crate) struct CoerceUnsizedNonStruct {
1336#[primary_span]
1337pub span: Span,
1338pub trait_name: &'static str,
1339}
13401341#[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)]
1342#[diag("only pattern types with the same pattern can be coerced between each other")]
1343pub(crate) struct CoerceSamePatKind {
1344#[primary_span]
1345pub span: Span,
1346pub trait_name: &'static str,
1347pub pat_a: String,
1348pub pat_b: String,
1349}
13501351#[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)]
1352#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1353pub(crate) struct CoerceSameStruct {
1354#[primary_span]
1355pub span: Span,
1356pub trait_name: &'static str,
1357#[note(
1358"expected coercion between the same definition; expected `{$source_path}`, found `{$target_path}`"
1359)]
1360pub note: bool,
1361pub source_path: String,
1362pub target_path: String,
1363}
13641365#[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)]
1366#[diag(
1367"for `{$ty}` to have a valid implementation of `{$trait_name}`, it must be possible to coerce the field of type `{$field_ty}`"
1368)]
1369pub(crate) struct CoerceFieldValidity<'tcx> {
1370#[primary_span]
1371pub span: Span,
1372pub ty: Ty<'tcx>,
1373pub trait_name: &'static str,
1374#[label(
1375"`{$field_ty}` must be a pointer, reference, or smart pointer that is allowed to be unsized"
1376)]
1377pub field_span: Span,
1378pub field_ty: Ty<'tcx>,
1379}
13801381#[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)]
1382#[diag("the trait `{$trait_name}` cannot be implemented for this type", code = E0204)]
1383pub(crate) struct TraitCannotImplForTy {
1384#[primary_span]
1385pub span: Span,
1386pub trait_name: String,
1387#[label("this field does not implement `{$trait_name}`")]
1388pub label_spans: Vec<Span>,
1389#[subdiagnostic]
1390pub notes: Vec<ImplForTyRequires>,
1391}
13921393#[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_format(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)]
1394#[note("the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`")]
1395pub(crate) struct ImplForTyRequires {
1396#[primary_span]
1397pub span: MultiSpan,
1398pub error_predicate: String,
1399pub trait_name: String,
1400pub ty: String,
1401}
14021403#[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)]
1404#[diag("traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`", code = E0321)]
1405#[note(
1406"a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds"
1407)]
1408pub(crate) struct TraitsWithDefaultImpl<'a> {
1409#[primary_span]
1410pub span: Span,
1411pub traits: String,
1412pub problematic_kind: &'a str,
1413pub self_ty: Ty<'a>,
1414}
14151416#[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)]
1417#[diag("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`", code = E0321)]
1418pub(crate) struct CrossCrateTraits<'a> {
1419#[primary_span]
1420 #[label("can't implement cross-crate trait with a default impl for non-struct/enum type")]
1421pub span: Span,
1422pub traits: String,
1423pub self_ty: Ty<'a>,
1424}
14251426#[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)]
1427#[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)]
1428pub(crate) struct CrossCrateTraitsDefined {
1429#[primary_span]
1430 #[label("can't implement cross-crate trait for type in another crate")]
1431pub span: Span,
1432pub traits: String,
1433}
14341435#[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)]
1436#[diag("no variant named `{$ident}` found for enum `{$ty}`", code = E0599)]
1437pub struct NoVariantNamed<'tcx> {
1438#[primary_span]
1439pub span: Span,
1440pub ident: Ident,
1441pub ty: Ty<'tcx>,
1442}
14431444#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
NoFieldOnType<'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 {
NoFieldOnType {
span: __binding_0, ty: __binding_1, field: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no field `{$field}` on type `{$ty}`")));
diag.code(E0609);
;
diag.arg("ty", __binding_1);
diag.arg("field", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1445#[diag("no field `{$field}` on type `{$ty}`", code = E0609)]
1446pub struct NoFieldOnType<'tcx> {
1447#[primary_span]
1448pub span: Span,
1449pub ty: Ty<'tcx>,
1450pub field: Ident,
1451}
14521453// FIXME(fmease): Deduplicate:
14541455#[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)]
1456#[diag("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)", code = E0210)]
1457#[note(
1458"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"
1459)]
1460pub(crate) struct TyParamFirstLocal<'tcx> {
1461#[primary_span]
1462 #[label(
1463"type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)"
1464)]
1465pub span: Span,
1466#[note(
1467"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"
1468)]
1469pub note: (),
1470pub param: Ident,
1471pub local_type: Ty<'tcx>,
1472}
14731474#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
TyParamFirstLocalLint<'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 {
TyParamFirstLocalLint {
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_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)]
1475#[diag("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)", code = E0210)]
1476#[note(
1477"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"
1478)]
1479pub(crate) struct TyParamFirstLocalLint<'tcx> {
1480#[label(
1481"type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)"
1482)]
1483pub span: Span,
1484#[note(
1485"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"
1486)]
1487pub note: (),
1488pub param: Ident,
1489pub local_type: Ty<'tcx>,
1490}
14911492#[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)]
1493#[diag("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)", code = E0210)]
1494#[note(
1495"implementing a foreign trait is only possible if at least one of the types for which it is implemented is local"
1496)]
1497pub(crate) struct TyParamSome {
1498#[primary_span]
1499 #[label("type parameter `{$param}` must be used as the type parameter for some local type")]
1500pub span: Span,
1501#[note("only traits defined in the current crate can be implemented for a type parameter")]
1502pub note: (),
1503pub param: Ident,
1504}
15051506#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TyParamSomeLint 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 {
TyParamSomeLint {
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_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)]
1507#[diag("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)", code = E0210)]
1508#[note(
1509"implementing a foreign trait is only possible if at least one of the types for which it is implemented is local"
1510)]
1511pub(crate) struct TyParamSomeLint {
1512#[label("type parameter `{$param}` must be used as the type parameter for some local type")]
1513pub span: Span,
1514#[note("only traits defined in the current crate can be implemented for a type parameter")]
1515pub note: (),
1516pub param: Ident,
1517}
15181519#[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)]
1520pub(crate) enum OnlyCurrentTraits {
1521#[diag("only traits defined in the current crate can be implemented for types defined outside of the crate", code = E0117)]
1522Outside {
1523#[primary_span]
1524span: Span,
1525#[note("impl doesn't have any local type before any uncovered type parameters")]
1526 #[note(
1527"for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1528)]
1529 #[note("define and implement a trait or new type instead")]
1530note: (),
1531 },
1532#[diag("only traits defined in the current crate can be implemented for primitive types", code = E0117)]
1533Primitive {
1534#[primary_span]
1535span: Span,
1536#[note("impl doesn't have any local type before any uncovered type parameters")]
1537 #[note(
1538"for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1539)]
1540 #[note("define and implement a trait or new type instead")]
1541note: (),
1542 },
1543#[diag("only traits defined in the current crate can be implemented for arbitrary types", code = E0117)]
1544Arbitrary {
1545#[primary_span]
1546span: Span,
1547#[note("impl doesn't have any local type before any uncovered type parameters")]
1548 #[note(
1549"for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1550)]
1551 #[note("define and implement a trait or new type instead")]
1552note: (),
1553 },
1554}
15551556#[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_format(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)]
1557#[label(
1558"type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate"
1559)]
1560pub(crate) struct OnlyCurrentTraitsOpaque {
1561#[primary_span]
1562pub span: Span,
1563}
1564#[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_format(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)]
1565#[label("this is not defined in the current crate because this is a foreign trait")]
1566pub(crate) struct OnlyCurrentTraitsForeign {
1567#[primary_span]
1568pub span: Span,
1569}
15701571#[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_format(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)]
1572#[label("this is not defined in the current crate because {$name} are always foreign")]
1573pub(crate) struct OnlyCurrentTraitsName<'a> {
1574#[primary_span]
1575pub span: Span,
1576pub name: &'a str,
1577}
15781579#[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_format(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)]
1580#[label("`{$pointer}` is not defined in the current crate because raw pointers are always foreign")]
1581pub(crate) struct OnlyCurrentTraitsPointer<'a> {
1582#[primary_span]
1583pub span: Span,
1584pub pointer: Ty<'a>,
1585}
15861587#[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_format(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)]
1588#[label("`{$ty}` is not defined in the current crate")]
1589pub(crate) struct OnlyCurrentTraitsTy<'a> {
1590#[primary_span]
1591pub span: Span,
1592pub ty: Ty<'a>,
1593}
15941595#[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_format(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)]
1596#[label("`{$name}` is not defined in the current crate")]
1597pub(crate) struct OnlyCurrentTraitsAdt {
1598#[primary_span]
1599pub span: Span,
1600pub name: String,
1601}
16021603#[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_format(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)]
1604#[multipart_suggestion(
1605"consider introducing a new wrapper type",
1606 applicability = "maybe-incorrect"
1607)]
1608pub(crate) struct OnlyCurrentTraitsPointerSugg<'a> {
1609#[suggestion_part(code = "WrapperType")]
1610pub wrapper_span: Span,
1611#[suggestion_part(code = "struct WrapperType(*{mut_key}{ptr_ty});\n\n")]
1612pub(crate) struct_span: Span,
1613pub mut_key: &'a str,
1614pub ptr_ty: Ty<'a>,
1615}
16161617#[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)]
1618#[diag("{$descr}")]
1619pub(crate) struct UnsupportedDelegation<'a> {
1620#[primary_span]
1621pub span: Span,
1622pub descr: &'a str,
1623#[label("callee defined here")]
1624pub callee_span: Span,
1625}
16261627#[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)]
1628#[diag("method should be `async` or return a future, but it is synchronous")]
1629pub(crate) struct MethodShouldReturnFuture {
1630#[primary_span]
1631pub span: Span,
1632pub method_name: Ident,
1633#[note("this method is `async` so it expects a future to be returned")]
1634pub trait_item_span: Option<Span>,
1635}
16361637#[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)]
1638#[diag("{$param_def_kind} `{$param_name}` is never used")]
1639pub(crate) struct UnusedGenericParameter {
1640#[primary_span]
1641 #[label("unused {$param_def_kind}")]
1642pub span: Span,
1643pub param_name: Ident,
1644pub param_def_kind: &'static str,
1645#[label("`{$param_name}` is named here, but is likely unused in the containing type")]
1646pub usage_spans: Vec<Span>,
1647#[subdiagnostic]
1648pub help: UnusedGenericParameterHelp,
1649#[help(
1650"if you intended `{$param_name}` to be a const parameter, use `const {$param_name}: /* Type */` instead"
1651)]
1652pub const_param_help: bool,
1653}
16541655#[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)]
1656#[diag("{$param_def_kind} `{$param_name}` is only used recursively")]
1657pub(crate) struct RecursiveGenericParameter {
1658#[primary_span]
1659pub spans: Vec<Span>,
1660#[label("{$param_def_kind} must be used non-recursively in the definition")]
1661pub param_span: Span,
1662pub param_name: Ident,
1663pub param_def_kind: &'static str,
1664#[subdiagnostic]
1665pub help: UnusedGenericParameterHelp,
1666#[note(
1667"all type parameters must be used in a non-recursive way in order to constrain their variance"
1668)]
1669pub note: (),
1670}
16711672#[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_format(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_format(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_format(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)]
1673pub(crate) enum UnusedGenericParameterHelp {
1674#[help(
1675"consider removing `{$param_name}`, referring to it in a field, or using a marker such as `{$phantom_data}`"
1676)]
1677Adt { param_name: Ident, phantom_data: String },
1678#[help("consider removing `{$param_name}` or referring to it in a field")]
1679AdtNoPhantomData { param_name: Ident },
1680#[help("consider removing `{$param_name}` or referring to it in the body of the type alias")]
1681TyAlias { param_name: Ident },
1682}
16831684#[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)]
1685#[diag(
1686"the {$param_def_kind} `{$param_name}` is not constrained by the impl trait, self type, or predicates"
1687)]
1688pub(crate) struct UnconstrainedGenericParameter {
1689#[primary_span]
1690 #[label("unconstrained {$param_def_kind}")]
1691pub span: Span,
1692pub param_name: Ident,
1693pub param_def_kind: &'static str,
1694#[note("expressions using a const parameter must map each value to a distinct output value")]
1695pub const_param_note: bool,
1696#[note(
1697"proving the result of expressions other than the parameter are unique is not supported"
1698)]
1699pub const_param_note2: bool,
1700}
17011702#[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)]
1703#[diag("`impl Trait` cannot capture {$bad_place}", code = E0657)]
1704pub(crate) struct OpaqueCapturesHigherRankedLifetime {
1705#[primary_span]
1706pub span: MultiSpan,
1707#[label("`impl Trait` implicitly captures all lifetimes in scope")]
1708pub label: Option<Span>,
1709#[note("lifetime declared here")]
1710pub decl_span: MultiSpan,
1711pub bad_place: &'static str,
1712}
17131714#[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_format(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_format(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)]
1715pub(crate) enum InvalidReceiverTyHint {
1716#[note(
1717"`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`"
1718)]
1719Weak,
1720#[note(
1721"`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`"
1722)]
1723NonNull,
1724}
17251726#[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)]
1727#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1728#[note("type of `self` must be `Self` or a type that dereferences to it")]
1729#[help(
1730"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`)"
1731)]
1732pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
1733#[primary_span]
1734pub span: Span,
1735pub receiver_ty: Ty<'tcx>,
1736}
17371738#[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)]
1739#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1740#[note("type of `self` must be `Self` or some type implementing `Receiver`")]
1741#[help(
1742"consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`"
1743)]
1744pub(crate) struct InvalidReceiverTy<'tcx> {
1745#[primary_span]
1746pub span: Span,
1747pub receiver_ty: Ty<'tcx>,
1748#[subdiagnostic]
1749pub hint: Option<InvalidReceiverTyHint>,
1750}
17511752#[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)]
1753#[diag("invalid generic `self` parameter type: `{$receiver_ty}`", code = E0801)]
1754#[note("type of `self` must not be a method generic parameter type")]
1755#[help(
1756"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`)"
1757)]
1758pub(crate) struct InvalidGenericReceiverTy<'tcx> {
1759#[primary_span]
1760pub span: Span,
1761pub receiver_ty: Ty<'tcx>,
1762}
17631764#[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)]
1765#[diag("arguments for `{$abi}` function too large to pass via registers", code = E0798)]
1766#[note(
1767"functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit argument registers"
1768)]
1769pub(crate) struct CmseInputsStackSpill {
1770#[primary_span]
1771 #[label("does not fit in the available registers")]
1772pub spans: Vec<Span>,
1773pub abi: ExternAbi,
1774}
17751776#[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)]
1777#[diag("return value of `{$abi}` function too large to pass via registers", code = E0798)]
1778#[note("functions with the `{$abi}` ABI must pass their result via the available return registers")]
1779#[note(
1780"the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size"
1781)]
1782pub(crate) struct CmseOutputStackSpill {
1783#[primary_span]
1784 #[label("this type doesn't fit in the available registers")]
1785pub span: Span,
1786pub abi: ExternAbi,
1787}
17881789#[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)]
1790#[diag("generics are not allowed in `extern {$abi}` signatures", code = E0798)]
1791pub(crate) struct CmseGeneric {
1792#[primary_span]
1793pub span: Span,
1794pub abi: ExternAbi,
1795}
17961797#[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)]
1798#[diag("`impl Trait` is not allowed in `extern {$abi}` signatures", code = E0798)]
1799pub(crate) struct CmseImplTrait {
1800#[primary_span]
1801pub span: Span,
1802pub abi: ExternAbi,
1803}
18041805#[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)]
1806#[diag("return type notation not allowed in this position yet")]
1807pub(crate) struct BadReturnTypeNotation {
1808#[primary_span]
1809pub span: Span,
1810}
18111812#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SupertraitItemShadowing 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 {
SupertraitItemShadowing {
item: __binding_0,
subtrait: __binding_1,
shadowee: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")));
;
diag.arg("item", __binding_0);
diag.arg("subtrait", __binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1813#[diag("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")]
1814pub(crate) struct SupertraitItemShadowing {
1815pub item: Symbol,
1816pub subtrait: Symbol,
1817#[subdiagnostic]
1818pub shadowee: SupertraitItemShadowee,
1819}
18201821#[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_format(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_format(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)]
1822pub(crate) enum SupertraitItemShadowee {
1823#[note("item from `{$supertrait}` is shadowed by a subtrait item")]
1824Labeled {
1825#[primary_span]
1826span: Span,
1827 supertrait: Symbol,
1828 },
1829#[note("items from several supertraits are shadowed: {$traits}")]
1830Several {
1831#[primary_span]
1832spans: MultiSpan,
1833 traits: DiagSymbolList,
1834 },
1835}
18361837#[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)]
1838#[diag("{$kind} binding in trait object type mentions `Self`")]
1839pub(crate) struct DynTraitAssocItemBindingMentionsSelf {
1840#[primary_span]
1841 #[label("contains a mention of `Self`")]
1842pub span: Span,
1843pub kind: &'static str,
1844#[label("this binding mentions `Self`")]
1845pub binding: Span,
1846}
18471848#[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)]
1849#[diag(
1850"items with the \"custom\" ABI can only be declared externally or defined via naked functions"
1851)]
1852pub(crate) struct AbiCustomClothedFunction {
1853#[primary_span]
1854pub span: Span,
1855#[suggestion(
1856"convert this to an `#[unsafe(naked)]` function",
1857 applicability = "maybe-incorrect",
1858 code = "#[unsafe(naked)]\n",
1859 style = "short"
1860)]
1861pub naked_span: Span,
1862}
18631864#[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)]
1865#[diag("`AsyncDrop` impl without `Drop` impl")]
1866#[help(
1867"type implementing `AsyncDrop` trait must also implement `Drop` trait to be used in sync context and unwinds"
1868)]
1869pub(crate) struct AsyncDropWithoutSyncDrop {
1870#[primary_span]
1871pub span: Span,
1872}
18731874#[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)]
1875#[diag("lifetime parameters or bounds of `{$ident}` do not match the declaration")]
1876pub(crate) struct LifetimesOrBoundsMismatchOnEii {
1877#[primary_span]
1878 #[label("lifetimes do not match")]
1879pub span: Span,
1880#[label("lifetimes in impl do not match this signature")]
1881pub generics_span: Span,
1882#[label("this `where` clause might not match the one in the trait")]
1883pub where_span: Option<Span>,
1884#[label("this bound might be missing in the impl")]
1885pub bounds_span: Vec<Span>,
1886pub ident: Symbol,
1887}
18881889#[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)]
1890#[diag("`{$impl_name}` cannot have generic parameters other than lifetimes")]
1891#[help("`#[{$eii_name}]` marks the implementation of an \"externally implementable item\"")]
1892pub(crate) struct EiiWithGenerics {
1893#[primary_span]
1894pub span: Span,
1895#[label("required by this attribute")]
1896pub attr: Span,
1897pub eii_name: Symbol,
1898pub impl_name: Symbol,
1899}
19001901#[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)]
1902#[diag("explicit impls for the `Unpin` trait are not permitted for structurally pinned types")]
1903pub(crate) struct ImplUnpinForPinProjectedType {
1904#[primary_span]
1905 #[label("impl of `Unpin` not allowed")]
1906pub span: Span,
1907#[help("`{$adt_name}` is structurally pinned because it is marked as `#[pin_v2]`")]
1908pub adt_span: Span,
1909pub adt_name: Symbol,
1910}