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