1use rustc_abi::ExternAbi;
4use rustc_errors::codes::*;
5use rustc_errors::{
6 Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
7 MultiSpan, listify, msg,
8};
9use rustc_hir::limit::Limit;
10use rustc_macros::{Diagnostic, Subdiagnostic};
11use rustc_middle::ty::{self, Ty};
12use rustc_span::{Ident, Span, Symbol};
13pub(crate) mod wrong_number_of_generic_args;
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
ParenSugarAttribute where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParenSugarAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(unboxed_closures)]` to the crate attributes to use it")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
866#[diag(
867 "the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation"
868)]
869#[help("add `#![feature(unboxed_closures)]` to the crate attributes to use it")]
870pub(crate) struct ParenSugarAttribute {
871 #[primary_span]
872 pub span: Span,
873}
874
875#[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)]
876#[diag("use of SIMD type{$snip} in FFI is highly experimental and may result in invalid code")]
877#[help("add `#![feature(simd_ffi)]` to the crate attributes to enable")]
878pub(crate) struct SIMDFFIHighlyExperimental {
879 #[primary_span]
880 pub span: Span,
881 pub snip: String,
882}
883
884#[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)]
885pub(crate) enum ImplNotMarkedDefault {
886 #[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
887 #[note("to specialize, `{$ident}` in the parent `impl` must be marked `default`")]
888 Ok {
889 #[primary_span]
890 #[label("cannot specialize default item `{$ident}`")]
891 span: Span,
892 #[label("parent `impl` is here")]
893 ok_label: Span,
894 ident: Ident,
895 },
896 #[diag("`{$ident}` specializes an item from a parent `impl`, but that item is not marked `default`", code = E0520)]
897 #[note("parent implementation is in crate `{$cname}`")]
898 Err {
899 #[primary_span]
900 span: Span,
901 cname: Symbol,
902 ident: Ident,
903 },
904}
905
906#[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)]
907#[diag("this item cannot be used as its where bounds are not satisfied for the `Self` type")]
908pub(crate) struct UselessImplItem;
909
910#[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)]
911#[diag("cannot override `{$ident}` because it already has a `final` definition in the trait")]
912pub(crate) struct OverridingFinalTraitFunction {
913 #[primary_span]
914 pub impl_span: Span,
915 #[note("`{$ident}` is marked final here")]
916 pub trait_span: Span,
917 pub ident: Ident,
918}
919
920#[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)]
921#[diag("not all trait items implemented, missing: `{$missing_items_msg}`", code = E0046)]
922pub(crate) struct MissingTraitItem {
923 #[primary_span]
924 #[label("missing `{$missing_items_msg}` in implementation")]
925 pub span: Span,
926 #[subdiagnostic]
927 pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
928 #[subdiagnostic]
929 pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
930 #[subdiagnostic]
931 pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
932 pub missing_items_msg: String,
933}
934
935#[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)]
936#[label("`{$item}` from trait")]
937pub(crate) struct MissingTraitItemLabel {
938 #[primary_span]
939 pub span: Span,
940 pub item: Symbol,
941}
942
943#[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)]
944#[suggestion(
945 "implement the missing item: `{$snippet}`",
946 style = "tool-only",
947 applicability = "has-placeholders",
948 code = "{code}"
949)]
950pub(crate) struct MissingTraitItemSuggestion {
951 #[primary_span]
952 pub span: Span,
953 pub code: String,
954 pub snippet: String,
955}
956
957#[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)]
958#[suggestion(
959 "implement the missing item: `{$snippet}`",
960 style = "hidden",
961 applicability = "has-placeholders",
962 code = "{code}"
963)]
964pub(crate) struct MissingTraitItemSuggestionNone {
965 #[primary_span]
966 pub span: Span,
967 pub code: String,
968 pub snippet: String,
969}
970
971#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingOneOfTraitItem where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingOneOfTraitItem {
span: __binding_0,
note: __binding_1,
missing_items_msg: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not all trait items implemented, missing one of: `{$missing_items_msg}`")));
diag.code(E0046);
;
diag.arg("missing_items_msg", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing one of `{$missing_items_msg}` in implementation")));
if let Some(__binding_1) = __binding_1 {
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required because of this annotation")));
}
diag
}
}
}
}
};Diagnostic)]
972#[diag("not all trait items implemented, missing one of: `{$missing_items_msg}`", code = E0046)]
973pub(crate) struct MissingOneOfTraitItem {
974 #[primary_span]
975 #[label("missing one of `{$missing_items_msg}` in implementation")]
976 pub span: Span,
977 #[note("required because of this annotation")]
978 pub note: Option<Span>,
979 pub missing_items_msg: String,
980}
981
982#[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)]
983#[diag("not all trait items implemented, missing: `{$missing_item_name}`", code = E0046)]
984#[note("default implementation of `{$missing_item_name}` is unstable")]
985pub(crate) struct MissingTraitItemUnstable {
986 #[primary_span]
987 pub span: Span,
988 #[note("use of unstable library feature `{$feature}`: {$reason}")]
989 pub some_note: bool,
990 #[note("use of unstable library feature `{$feature}`")]
991 pub none_note: bool,
992 pub missing_item_name: Ident,
993 pub feature: Symbol,
994 pub reason: String,
995}
996
997#[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)]
998#[diag("transparent enum needs exactly one variant, but has {$number}", code = E0731)]
999pub(crate) struct TransparentEnumVariant {
1000 #[primary_span]
1001 #[label("needs exactly one variant, but has {$number}")]
1002 pub span: Span,
1003 #[label("variant here")]
1004 pub spans: Vec<Span>,
1005 #[label("too many variants in `{$path}`")]
1006 pub many: Option<Span>,
1007 pub number: usize,
1008 pub path: String,
1009}
1010
1011#[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)]
1012#[diag("extern static is too large for the target architecture")]
1013pub(crate) struct TooLargeStatic {
1014 #[primary_span]
1015 pub span: Span,
1016}
1017
1018#[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)]
1019#[diag("implementing `rustc_specialization_trait` traits is unstable")]
1020#[help("add `#![feature(min_specialization)]` to the crate attributes to enable")]
1021pub(crate) struct SpecializationTrait {
1022 #[primary_span]
1023 pub span: Span,
1024}
1025
1026#[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)]
1027#[diag("trait cannot be implemented outside `{$restriction_path}`")]
1028pub(crate) struct ImplOfRestrictedTrait {
1029 #[primary_span]
1030 pub impl_span: Span,
1031 #[note("trait restricted here")]
1032 pub restriction_span: Span,
1033 pub restriction_path: String,
1034}
1035
1036#[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)]
1037#[diag("implicit types in closure signatures are forbidden when `for<...>` is present")]
1038pub(crate) struct ClosureImplicitHrtb {
1039 #[primary_span]
1040 pub spans: Vec<Span>,
1041 #[label("`for<...>` is here")]
1042 pub for_sp: Span,
1043}
1044
1045#[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)]
1046#[diag("specialization impl does not specialize any associated items")]
1047pub(crate) struct EmptySpecialization {
1048 #[primary_span]
1049 pub span: Span,
1050 #[note("impl is a specialization of this impl")]
1051 pub base_impl_span: Span,
1052}
1053
1054#[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)]
1055#[diag("cannot specialize on `'static` lifetime")]
1056pub(crate) struct StaticSpecialize {
1057 #[primary_span]
1058 pub span: Span,
1059}
1060
1061#[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)]
1062pub(crate) enum DropImplPolarity {
1063 #[diag("negative `Drop` impls are not supported")]
1064 Negative {
1065 #[primary_span]
1066 span: Span,
1067 },
1068 #[diag("reservation `Drop` impls are not supported")]
1069 Reservation {
1070 #[primary_span]
1071 span: Span,
1072 },
1073}
1074
1075#[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)]
1076pub(crate) enum ReturnTypeNotationIllegalParam {
1077 #[diag("return type notation is not allowed for functions that have type parameters")]
1078 Type {
1079 #[primary_span]
1080 span: Span,
1081 #[label("type parameter declared here")]
1082 param_span: Span,
1083 },
1084 #[diag("return type notation is not allowed for functions that have const parameters")]
1085 Const {
1086 #[primary_span]
1087 span: Span,
1088 #[label("const parameter declared here")]
1089 param_span: Span,
1090 },
1091}
1092
1093#[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)]
1094pub(crate) enum LateBoundInApit {
1095 #[diag("`impl Trait` can only mention type parameters from an fn or impl")]
1096 Type {
1097 #[primary_span]
1098 span: Span,
1099 #[label("type parameter declared here")]
1100 param_span: Span,
1101 },
1102 #[diag("`impl Trait` can only mention const parameters from an fn or impl")]
1103 Const {
1104 #[primary_span]
1105 span: Span,
1106 #[label("const parameter declared here")]
1107 param_span: Span,
1108 },
1109 #[diag("`impl Trait` can only mention lifetimes from an fn or impl")]
1110 Lifetime {
1111 #[primary_span]
1112 span: Span,
1113 #[label("lifetime declared here")]
1114 param_span: Span,
1115 },
1116}
1117
1118#[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)]
1119#[diag("unnecessary associated type bound for dyn-incompatible associated type")]
1120#[note(
1121 "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`"
1122)]
1123pub(crate) struct UnusedAssociatedTypeBounds {
1124 #[suggestion("remove this bound", code = "")]
1125 pub span: Span,
1126}
1127
1128#[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)]
1129#[diag("impl trait in impl method signature does not match trait method signature")]
1130#[note(
1131 "add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1132)]
1133#[note(
1134 "we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1135)]
1136pub(crate) struct ReturnPositionImplTraitInTraitRefined {
1137 #[suggestion(
1138 "replace the return type so that it matches the trait",
1139 applicability = "maybe-incorrect",
1140 code = "{pre}{return_ty}{post}"
1141 )]
1142 pub impl_return_span: Span,
1143 #[label("return type from trait method defined here")]
1144 pub trait_return_span: Option<Span>,
1145 #[label("this bound is stronger than that defined on the trait")]
1146 pub unmatched_bound: Option<Span>,
1147
1148 pub pre: &'static str,
1149 pub post: &'static str,
1150 pub return_ty: String,
1151}
1152
1153#[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)]
1154#[diag("impl trait in impl method captures fewer lifetimes than in trait")]
1155#[note(
1156 "add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate"
1157)]
1158#[note(
1159 "we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
1160)]
1161pub(crate) struct ReturnPositionImplTraitInTraitRefinedLifetimes {
1162 #[suggestion(
1163 "modify the `use<..>` bound to capture the same lifetimes that the trait does",
1164 applicability = "maybe-incorrect",
1165 code = "{suggestion}"
1166 )]
1167 pub suggestion_span: Span,
1168 pub suggestion: String,
1169}
1170
1171#[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)]
1172#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1173#[help("consider moving this inherent impl into the crate defining the type if possible")]
1174pub(crate) struct InherentTyOutside {
1175 #[primary_span]
1176 #[help(
1177 "alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items"
1178 )]
1179 pub span: Span,
1180}
1181
1182#[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)]
1183#[diag("structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`", code = E0378)]
1184pub(crate) struct DispatchFromDynRepr {
1185 #[primary_span]
1186 pub span: Span,
1187}
1188
1189#[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)]
1190#[diag("`derive(CoercePointee)` is only applicable to `struct`, instead of `{$kind}`", code = E0802)]
1191pub(crate) struct CoercePointeeNotStruct {
1192 #[primary_span]
1193 pub span: Span,
1194 pub kind: String,
1195}
1196
1197#[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)]
1198#[diag("`derive(CoercePointee)` is only applicable to `struct`", code = E0802)]
1199pub(crate) struct CoercePointeeNotConcreteType {
1200 #[primary_span]
1201 pub span: Span,
1202}
1203
1204#[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)]
1205#[diag("asserting applicability of `derive(CoercePointee)` on a target data is forbidden", code = E0802)]
1206pub(crate) struct CoercePointeeNoUserValidityAssertion {
1207 #[primary_span]
1208 pub span: Span,
1209}
1210
1211#[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)]
1212#[diag("`derive(CoercePointee)` is only applicable to `struct` with `repr(transparent)` layout", code = E0802)]
1213pub(crate) struct CoercePointeeNotTransparent {
1214 #[primary_span]
1215 pub span: Span,
1216}
1217
1218#[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)]
1219#[diag("`CoercePointee` can only be derived on `struct`s with at least one field", code = E0802)]
1220pub(crate) struct CoercePointeeNoField {
1221 #[primary_span]
1222 pub span: Span,
1223}
1224
1225#[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)]
1226#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0390)]
1227#[help("consider moving this inherent impl into the crate defining the type if possible")]
1228pub(crate) struct InherentTyOutsideRelevant {
1229 #[primary_span]
1230 pub span: Span,
1231 #[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1232 pub help_span: Span,
1233}
1234
1235#[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)]
1236#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0116)]
1237#[help(
1238 "consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it"
1239)]
1240#[note(
1241 "for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>"
1242)]
1243pub(crate) struct InherentTyOutsideNew {
1244 #[primary_span]
1245 #[label("impl for type defined outside of crate")]
1246 pub span: Span,
1247 #[subdiagnostic]
1248 pub note: Option<InherentTyOutsideNewAliasNote>,
1249}
1250
1251#[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)]
1252#[note("`{$ty_name}` does not define a new type, only an alias of `{$alias_ty_name}` defined here")]
1253pub(crate) struct InherentTyOutsideNewAliasNote {
1254 #[primary_span]
1255 pub span: Span,
1256 pub ty_name: String,
1257 pub alias_ty_name: String,
1258}
1259
1260#[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)]
1261#[diag("cannot define inherent `impl` for primitive types outside of `core`", code = E0390)]
1262#[help("consider moving this inherent impl into `core` if possible")]
1263pub(crate) struct InherentTyOutsidePrimitive {
1264 #[primary_span]
1265 pub span: Span,
1266 #[help("alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items")]
1267 pub help_span: Span,
1268}
1269
1270#[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)]
1271#[diag("cannot define inherent `impl` for primitive types", code = E0390)]
1272#[help("consider using an extension trait instead")]
1273pub(crate) struct InherentPrimitiveTy<'a> {
1274 #[primary_span]
1275 pub span: Span,
1276 #[subdiagnostic]
1277 pub note: Option<InherentPrimitiveTyNote<'a>>,
1278}
1279
1280#[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)]
1281#[note(
1282 "you could also try moving the reference to uses of `{$subty}` (such as `self`) within the implementation"
1283)]
1284pub(crate) struct InherentPrimitiveTyNote<'a> {
1285 pub subty: Ty<'a>,
1286}
1287
1288#[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)]
1289#[diag("cannot define inherent `impl` for a dyn auto trait", code = E0785)]
1290#[note("define and implement a new trait or type instead")]
1291pub(crate) struct InherentDyn {
1292 #[primary_span]
1293 #[label("impl requires at least one non-auto trait")]
1294 pub span: Span,
1295}
1296
1297#[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)]
1298#[diag("no nominal type found for inherent implementation", code = E0118)]
1299#[note("either implement a trait on it or create a newtype to wrap it instead")]
1300pub(crate) struct InherentNominal {
1301 #[primary_span]
1302 #[label("impl requires a nominal type")]
1303 pub span: Span,
1304}
1305
1306#[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)]
1307#[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)]
1308#[note("extra field `{$name}` of type `{$ty}` is not allowed")]
1309pub(crate) struct DispatchFromDynZST<'a> {
1310 #[primary_span]
1311 pub span: Span,
1312 pub name: Ident,
1313 pub ty: Ty<'a>,
1314}
1315
1316#[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)]
1317#[diag("implementing `{$trait_name}` requires a field to be coerced", code = E0374)]
1318pub(crate) struct CoerceNoField {
1319 #[primary_span]
1320 pub span: Span,
1321 pub trait_name: &'static str,
1322 #[note("expected a single field to be coerced, none found")]
1323 pub note: bool,
1324}
1325
1326#[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)]
1327#[diag("implementing `{$trait_name}` does not allow multiple fields to be coerced", code = E0375)]
1328pub(crate) struct CoerceMulti {
1329 pub trait_name: &'static str,
1330 #[primary_span]
1331 pub span: Span,
1332 pub number: usize,
1333 #[note(
1334 "the trait `{$trait_name}` may only be implemented when a single field is being coerced"
1335 )]
1336 pub fields: MultiSpan,
1337}
1338
1339#[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)]
1340#[diag(
1341 "implementing `{$trait_name}` requires that a single lifetime parameter is passed between source and target"
1342)]
1343pub(crate) struct CoerceSharedNotSingleLifetimeParam {
1344 #[primary_span]
1345 pub span: Span,
1346 pub trait_name: &'static str,
1347}
1348
1349#[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)]
1350#[diag("implementing `{$trait_name}` does not allow multiple lifetimes or fields to be coerced")]
1351pub(crate) struct CoerceSharedMulti {
1352 #[primary_span]
1353 pub span: Span,
1354 pub trait_name: &'static str,
1355}
1356
1357#[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)]
1358#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1359pub(crate) struct CoerceUnsizedNonStruct {
1360 #[primary_span]
1361 pub span: Span,
1362 pub trait_name: &'static str,
1363}
1364
1365#[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)]
1366#[diag("only pattern types with the same pattern can be coerced between each other")]
1367pub(crate) struct CoerceSamePatKind {
1368 #[primary_span]
1369 pub span: Span,
1370 pub trait_name: &'static str,
1371 pub pat_a: String,
1372 pub pat_b: String,
1373}
1374
1375#[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)]
1376#[diag("the trait `{$trait_name}` may only be implemented for a coercion between structures", code = E0377)]
1377pub(crate) struct CoerceSameStruct {
1378 #[primary_span]
1379 pub span: Span,
1380 pub trait_name: &'static str,
1381 #[note(
1382 "expected coercion between the same definition; expected `{$source_path}`, found `{$target_path}`"
1383 )]
1384 pub note: bool,
1385 pub source_path: String,
1386 pub target_path: String,
1387}
1388
1389#[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)]
1390#[diag(
1391 "for `{$ty}` to have a valid implementation of `{$trait_name}`, it must be possible to coerce the field of type `{$field_ty}`"
1392)]
1393pub(crate) struct CoerceFieldValidity<'tcx> {
1394 #[primary_span]
1395 pub span: Span,
1396 pub ty: Ty<'tcx>,
1397 pub trait_name: &'static str,
1398 #[label(
1399 "`{$field_ty}` must be a pointer, reference, or smart pointer that is allowed to be unsized"
1400 )]
1401 pub field_span: Span,
1402 pub field_ty: Ty<'tcx>,
1403}
1404
1405#[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)]
1406#[diag("the trait `{$trait_name}` cannot be implemented for this type", code = E0204)]
1407pub(crate) struct TraitCannotImplForTy {
1408 #[primary_span]
1409 pub span: Span,
1410 pub trait_name: String,
1411 #[label("this field does not implement `{$trait_name}`")]
1412 pub label_spans: Vec<Span>,
1413 #[subdiagnostic]
1414 pub notes: Vec<ImplForTyRequires>,
1415}
1416
1417#[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)]
1418#[note("the `{$trait_name}` impl for `{$ty}` requires that `{$error_predicate}`")]
1419pub(crate) struct ImplForTyRequires {
1420 #[primary_span]
1421 pub span: MultiSpan,
1422 pub error_predicate: String,
1423 pub trait_name: String,
1424 pub ty: String,
1425}
1426
1427#[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)]
1428#[diag("traits with a default impl, like `{$traits}`, cannot be implemented for {$problematic_kind} `{$self_ty}`", code = E0321)]
1429#[note(
1430 "a trait object implements `{$traits}` if and only if `{$traits}` is one of the trait object's trait bounds"
1431)]
1432pub(crate) struct TraitsWithDefaultImpl<'a> {
1433 #[primary_span]
1434 pub span: Span,
1435 pub traits: String,
1436 pub problematic_kind: &'a str,
1437 pub self_ty: Ty<'a>,
1438}
1439
1440#[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)]
1441#[diag("cross-crate traits with a default impl, like `{$traits}`, can only be implemented for a struct/enum type, not `{$self_ty}`", code = E0321)]
1442pub(crate) struct CrossCrateTraits<'a> {
1443 #[primary_span]
1444 #[label("can't implement cross-crate trait with a default impl for non-struct/enum type")]
1445 pub span: Span,
1446 pub traits: String,
1447 pub self_ty: Ty<'a>,
1448}
1449
1450#[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)]
1451#[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)]
1452pub(crate) struct CrossCrateTraitsDefined {
1453 #[primary_span]
1454 #[label("can't implement cross-crate trait for type in another crate")]
1455 pub span: Span,
1456 pub traits: String,
1457}
1458
1459#[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)]
1460#[diag("no variant named `{$ident}` found for enum `{$ty}`", code = E0599)]
1461pub struct NoVariantNamed<'tcx> {
1462 #[primary_span]
1463 pub span: Span,
1464 pub ident: Ident,
1465 pub ty: Ty<'tcx>,
1466}
1467
1468#[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)]
1469#[diag("no field `{$field}` on type `{$ty}`", code = E0609)]
1470pub struct NoFieldOnType<'tcx> {
1471 #[primary_span]
1472 pub span: Span,
1473 pub ty: Ty<'tcx>,
1474 pub field: Ident,
1475}
1476
1477#[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)]
1478pub(crate) enum OnlyCurrentTraits {
1479 #[diag("only traits defined in the current crate can be implemented for types defined outside of the crate", code = E0117)]
1480 Outside {
1481 #[primary_span]
1482 span: Span,
1483 #[note("impl doesn't have any local type before any uncovered type parameters")]
1484 #[note(
1485 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1486 )]
1487 #[note("define and implement a trait or new type instead")]
1488 note: (),
1489 },
1490 #[diag("only traits defined in the current crate can be implemented for primitive types", code = E0117)]
1491 Primitive {
1492 #[primary_span]
1493 span: Span,
1494 #[note("impl doesn't have any local type before any uncovered type parameters")]
1495 #[note(
1496 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1497 )]
1498 #[note("define and implement a trait or new type instead")]
1499 note: (),
1500 },
1501 #[diag("only traits defined in the current crate can be implemented for arbitrary types", code = E0117)]
1502 Arbitrary {
1503 #[primary_span]
1504 span: Span,
1505 #[note("impl doesn't have any local type before any uncovered type parameters")]
1506 #[note(
1507 "for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules"
1508 )]
1509 #[note("define and implement a trait or new type instead")]
1510 note: (),
1511 },
1512}
1513
1514#[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)]
1515#[label(
1516 "type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate"
1517)]
1518pub(crate) struct OnlyCurrentTraitsOpaque {
1519 #[primary_span]
1520 pub span: Span,
1521}
1522#[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)]
1523#[label("this is not defined in the current crate because this is a foreign trait")]
1524pub(crate) struct OnlyCurrentTraitsForeign {
1525 #[primary_span]
1526 pub span: Span,
1527}
1528
1529#[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)]
1530#[label("this is not defined in the current crate because {$name} are always foreign")]
1531pub(crate) struct OnlyCurrentTraitsName<'a> {
1532 #[primary_span]
1533 pub span: Span,
1534 pub name: &'a str,
1535}
1536
1537#[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)]
1538#[label("`{$pointer}` is not defined in the current crate because raw pointers are always foreign")]
1539pub(crate) struct OnlyCurrentTraitsPointer<'a> {
1540 #[primary_span]
1541 pub span: Span,
1542 pub pointer: Ty<'a>,
1543}
1544
1545#[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)]
1546#[label("`{$ty}` is not defined in the current crate")]
1547pub(crate) struct OnlyCurrentTraitsTy<'a> {
1548 #[primary_span]
1549 pub span: Span,
1550 pub ty: Ty<'a>,
1551}
1552
1553#[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)]
1554#[label("`{$name}` is not defined in the current crate")]
1555pub(crate) struct OnlyCurrentTraitsAdt {
1556 #[primary_span]
1557 pub span: Span,
1558 pub name: String,
1559}
1560
1561#[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)]
1562#[multipart_suggestion(
1563 "consider introducing a new wrapper type",
1564 applicability = "maybe-incorrect"
1565)]
1566pub(crate) struct OnlyCurrentTraitsPointerSugg<'a> {
1567 #[suggestion_part(code = "WrapperType")]
1568 pub wrapper_span: Span,
1569 #[suggestion_part(code = "struct WrapperType(*{mut_key}{ptr_ty});\n\n")]
1570 pub(crate) struct_span: Span,
1571 pub mut_key: &'a str,
1572 pub ptr_ty: Ty<'a>,
1573}
1574
1575#[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)]
1576#[diag("{$descr}")]
1577pub(crate) struct UnsupportedDelegation<'a> {
1578 #[primary_span]
1579 pub span: Span,
1580 pub descr: &'a str,
1581 #[label("callee defined here")]
1582 pub callee_span: Span,
1583}
1584
1585#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DelegationSelfTypeNotSpecified where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DelegationSelfTypeNotSpecified { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("delegation self type is not specified")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1586#[diag("delegation self type is not specified")]
1587#[help("consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`")]
1588pub(crate) struct DelegationSelfTypeNotSpecified {
1589 #[primary_span]
1590 pub span: Span,
1591}
1592
1593#[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)]
1594#[diag("inferred lifetimes are not allowed in delegations as we need to inherit signature")]
1595pub(crate) struct ElidedLifetimesAreNotAllowedInDelegations {
1596 #[primary_span]
1597 pub span: Span,
1598}
1599
1600#[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)]
1601#[diag("method should be `async` or return a future, but it is synchronous")]
1602pub(crate) struct MethodShouldReturnFuture {
1603 #[primary_span]
1604 pub span: Span,
1605 pub method_name: Ident,
1606 #[note("this method is `async` so it expects a future to be returned")]
1607 pub trait_item_span: Option<Span>,
1608}
1609
1610#[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)]
1611#[diag("{$param_def_kind} `{$param_name}` is never used")]
1612pub(crate) struct UnusedGenericParameter {
1613 #[primary_span]
1614 #[label("unused {$param_def_kind}")]
1615 pub span: Span,
1616 pub param_name: Ident,
1617 pub param_def_kind: &'static str,
1618 #[label("`{$param_name}` is named here, but is likely unused in the containing type")]
1619 pub usage_spans: Vec<Span>,
1620 #[subdiagnostic]
1621 pub help: UnusedGenericParameterHelp,
1622 #[help(
1623 "if you intended `{$param_name}` to be a const parameter, use `const {$param_name}: /* Type */` instead"
1624 )]
1625 pub const_param_help: bool,
1626}
1627
1628#[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)]
1629#[diag("{$param_def_kind} `{$param_name}` is only used recursively")]
1630pub(crate) struct RecursiveGenericParameter {
1631 #[primary_span]
1632 pub spans: Vec<Span>,
1633 #[label("{$param_def_kind} must be used non-recursively in the definition")]
1634 pub param_span: Span,
1635 pub param_name: Ident,
1636 pub param_def_kind: &'static str,
1637 #[subdiagnostic]
1638 pub help: UnusedGenericParameterHelp,
1639 #[note(
1640 "all type parameters must be used in a non-recursive way in order to constrain their variance"
1641 )]
1642 pub note: (),
1643}
1644
1645#[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)]
1646pub(crate) enum UnusedGenericParameterHelp {
1647 #[help(
1648 "consider removing `{$param_name}`, referring to it in a field, or using a marker such as `{$phantom_data}`"
1649 )]
1650 Adt { param_name: Ident, phantom_data: String },
1651 #[help("consider removing `{$param_name}` or referring to it in a field")]
1652 AdtNoPhantomData { param_name: Ident },
1653 #[help("consider removing `{$param_name}` or referring to it in the body of the type alias")]
1654 TyAlias { param_name: Ident },
1655}
1656
1657#[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)]
1658#[diag(
1659 "the {$param_def_kind} `{$param_name}` is not constrained by the impl trait, self type, or predicates"
1660)]
1661pub(crate) struct UnconstrainedGenericParameter {
1662 #[primary_span]
1663 #[label("unconstrained {$param_def_kind}")]
1664 pub span: Span,
1665 pub param_name: Ident,
1666 pub param_def_kind: &'static str,
1667 #[note("expressions using a const parameter must map each value to a distinct output value")]
1668 pub const_param_note: bool,
1669 #[note(
1670 "proving the result of expressions other than the parameter are unique is not supported"
1671 )]
1672 pub const_param_note2: bool,
1673}
1674
1675#[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)]
1676#[diag("`impl Trait` cannot capture {$bad_place}", code = E0657)]
1677pub(crate) struct OpaqueCapturesHigherRankedLifetime {
1678 #[primary_span]
1679 pub span: MultiSpan,
1680 #[label("`impl Trait` implicitly captures all lifetimes in scope")]
1681 pub label: Option<Span>,
1682 #[note("lifetime declared here")]
1683 pub decl_span: MultiSpan,
1684 pub bad_place: &'static str,
1685}
1686
1687#[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)]
1688pub(crate) enum InvalidReceiverTyHint {
1689 #[note(
1690 "`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`"
1691 )]
1692 Weak,
1693 #[note(
1694 "`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`"
1695 )]
1696 NonNull,
1697}
1698
1699#[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)]
1700#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1701#[note("type of `self` must be `Self` or a type that dereferences to it")]
1702#[help(
1703 "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`)"
1704)]
1705pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
1706 #[primary_span]
1707 pub span: Span,
1708 pub receiver_ty: Ty<'tcx>,
1709}
1710
1711#[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)]
1712#[diag("invalid `self` parameter type: `{$receiver_ty}`", code = E0307)]
1713#[note("type of `self` must be `Self` or some type implementing `Receiver`")]
1714#[help(
1715 "consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`"
1716)]
1717pub(crate) struct InvalidReceiverTy<'tcx> {
1718 #[primary_span]
1719 pub span: Span,
1720 pub receiver_ty: Ty<'tcx>,
1721 #[subdiagnostic]
1722 pub hint: Option<InvalidReceiverTyHint>,
1723}
1724
1725#[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)]
1726#[diag("invalid generic `self` parameter type: `{$receiver_ty}`", code = E0801)]
1727#[note("type of `self` must not be a method generic parameter type")]
1728#[help(
1729 "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`)"
1730)]
1731pub(crate) struct InvalidGenericReceiverTy<'tcx> {
1732 #[primary_span]
1733 pub span: Span,
1734 pub receiver_ty: Ty<'tcx>,
1735}
1736
1737#[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)]
1738#[diag("arguments for `{$abi}` function too large to pass via registers", code = E0798)]
1739#[note(
1740 "functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit argument registers"
1741)]
1742pub(crate) struct CmseInputsStackSpill {
1743 #[primary_span]
1744 #[label("does not fit in the available registers")]
1745 pub spans: Vec<Span>,
1746 pub abi: ExternAbi,
1747}
1748
1749#[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)]
1750#[diag("return value of `{$abi}` function too large to pass via registers", code = E0798)]
1751#[note("functions with the `{$abi}` ABI must pass their result via the available return registers")]
1752#[note(
1753 "the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size"
1754)]
1755pub(crate) struct CmseOutputStackSpill {
1756 #[primary_span]
1757 #[label("this type doesn't fit in the available registers")]
1758 pub span: Span,
1759 pub abi: ExternAbi,
1760}
1761
1762#[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)]
1763#[diag("generics are not allowed in `extern {$abi}` signatures", code = E0798)]
1764pub(crate) struct CmseGeneric {
1765 #[primary_span]
1766 pub span: Span,
1767 pub abi: ExternAbi,
1768}
1769
1770#[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)]
1771#[diag("`impl Trait` is not allowed in `extern {$abi}` signatures", code = E0798)]
1772pub(crate) struct CmseImplTrait {
1773 #[primary_span]
1774 pub span: Span,
1775 pub abi: ExternAbi,
1776}
1777
1778#[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)]
1779#[diag("return type notation not allowed in this position yet")]
1780pub(crate) struct BadReturnTypeNotation {
1781 #[primary_span]
1782 pub span: Span,
1783 #[suggestion(
1784 "furthermore, argument types not allowed with return type notation",
1785 applicability = "maybe-incorrect",
1786 code = "(..)",
1787 style = "verbose"
1788 )]
1789 pub suggestion: Option<Span>,
1790}
1791
1792#[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)]
1793#[diag("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")]
1794pub(crate) struct SupertraitItemShadowing {
1795 pub item: Symbol,
1796 pub subtrait: Symbol,
1797 #[subdiagnostic]
1798 pub shadowee: SupertraitItemShadowee,
1799}
1800
1801#[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)]
1802pub(crate) enum SupertraitItemShadowee {
1803 #[note("item from `{$supertrait}` is shadowed by a subtrait item")]
1804 Labeled {
1805 #[primary_span]
1806 span: Span,
1807 supertrait: Symbol,
1808 },
1809 #[note("items from several supertraits are shadowed: {$traits}")]
1810 Several {
1811 #[primary_span]
1812 spans: MultiSpan,
1813 traits: DiagSymbolList,
1814 },
1815}
1816
1817#[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)]
1818#[diag("{$kind} binding in trait object type mentions `Self`")]
1819pub(crate) struct DynTraitAssocItemBindingMentionsSelf {
1820 #[primary_span]
1821 #[label("contains a mention of `Self`")]
1822 pub span: Span,
1823 pub kind: &'static str,
1824 #[label("this binding mentions `Self`")]
1825 pub binding: Span,
1826}
1827
1828#[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)]
1829#[diag(
1830 "items with the \"custom\" ABI can only be declared externally or defined via naked functions"
1831)]
1832pub(crate) struct AbiCustomClothedFunction {
1833 #[primary_span]
1834 pub span: Span,
1835 #[suggestion(
1836 "convert this to an `#[unsafe(naked)]` function",
1837 applicability = "maybe-incorrect",
1838 code = "#[unsafe(naked)]\n",
1839 style = "short"
1840 )]
1841 pub naked_span: Span,
1842}
1843
1844#[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)]
1845#[diag("`AsyncDrop` impl without `Drop` impl")]
1846#[help(
1847 "type implementing `AsyncDrop` trait must also implement `Drop` trait to be used in sync context and unwinds"
1848)]
1849pub(crate) struct AsyncDropWithoutSyncDrop {
1850 #[primary_span]
1851 pub span: Span,
1852}
1853
1854#[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)]
1855#[diag("lifetime parameters or bounds of `{$ident}` do not match the declaration")]
1856pub(crate) struct LifetimesOrBoundsMismatchOnEii {
1857 #[primary_span]
1858 #[label("lifetimes do not match")]
1859 pub span: Span,
1860 #[label("lifetimes in impl do not match this signature")]
1861 pub generics_span: Span,
1862 #[label("this `where` clause might not match the one in the trait")]
1863 pub where_span: Option<Span>,
1864 #[label("this bound might be missing in the impl")]
1865 pub bounds_span: Vec<Span>,
1866 pub ident: Symbol,
1867}
1868
1869#[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)]
1870#[diag("`{$impl_name}` cannot have generic parameters other than lifetimes")]
1871#[help("`#[{$eii_name}]` marks the implementation of an \"externally implementable item\"")]
1872pub(crate) struct EiiWithGenerics {
1873 #[primary_span]
1874 pub span: Span,
1875 #[label("required by this attribute")]
1876 pub attr: Span,
1877 pub eii_name: Symbol,
1878 pub impl_name: Symbol,
1879}
1880
1881#[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)]
1882#[diag("explicit impls for the `Unpin` trait are not permitted for structurally pinned types")]
1883pub(crate) struct ImplUnpinForPinProjectedType {
1884 #[primary_span]
1885 #[label("impl of `Unpin` not allowed")]
1886 pub span: Span,
1887 #[help("`{$adt_name}` is structurally pinned because it is marked as `#[pin_v2]`")]
1888 pub adt_span: Span,
1889 pub adt_name: Symbol,
1890}
1891
1892#[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)]
1893#[diag("`#[{$eii_name}]` must be used on a {$expected_kind}")]
1894pub(crate) struct EiiDefkindMismatch {
1895 #[primary_span]
1896 pub span: Span,
1897 pub eii_name: Symbol,
1898 pub expected_kind: &'static str,
1899}
1900
1901#[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)]
1902#[diag("mutability does not match with the definition of`#[{$eii_name}]`")]
1903pub(crate) struct EiiDefkindMismatchStaticMutability {
1904 #[primary_span]
1905 pub span: Span,
1906 pub eii_name: Symbol,
1907}
1908
1909#[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)]
1910#[diag("safety does not match with the definition of`#[{$eii_name}]`")]
1911pub(crate) struct EiiDefkindMismatchStaticSafety {
1912 #[primary_span]
1913 pub span: Span,
1914 pub eii_name: Symbol,
1915}
1916
1917#[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)]
1918#[diag("conflicting implementations of `Drop::drop` and `Drop::pin_drop`")]
1919pub(crate) struct ConflictImplDropAndPinDrop {
1920 #[primary_span]
1921 pub span: Span,
1922 #[label("`drop(&mut self)` implemented here")]
1923 pub drop_span: Span,
1924 #[label("`pin_drop(&pin mut self)` implemented here")]
1925 pub pin_drop_span: Span,
1926}
1927
1928#[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)]
1929#[diag("`{$adt_name}` must implement `pin_drop`")]
1930#[help("structurally pinned types must keep `Pin`'s safety contract")]
1931pub(crate) struct PinV2WithoutPinDrop {
1932 #[primary_span]
1933 #[suggestion(
1934 "implement `pin_drop` instead",
1935 code = "fn pin_drop(&pin mut self)",
1936 applicability = "maybe-incorrect"
1937 )]
1938 pub span: Span,
1939 #[note("`{$adt_name}` is marked `#[pin_v2]` here")]
1940 #[suggestion(
1941 "remove the `#[pin_v2]` attribute if it is not intended for structurally pinning",
1942 code = "",
1943 applicability = "maybe-incorrect"
1944 )]
1945 pub pin_v2_span: Option<Span>,
1946 pub adt_name: Symbol,
1947}
1948
1949#[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)]
1950#[diag("`#[pin_v2]` types may not have `#[repr(packed)]`")]
1951#[note(
1952 "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"
1953)]
1954pub(crate) struct PinV2OnPacked {
1955 #[primary_span]
1956 pub span: Span,
1957 #[note("`{$adt_name}` is marked `#[pin_v2]` here")]
1958 pub pin_v2_span: Option<Span>,
1959 pub adt_name: Symbol,
1960}
1961
1962pub(crate) struct UncoveredTyParam<'tcx> {
1963 pub(crate) param: Ident,
1964 pub(crate) local_ty: Option<Ty<'tcx>>,
1965}
1966
1967impl<G: EmissionGuarantee> Diagnostic<'_, G> for UncoveredTyParam<'_> {
1968 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
1969 let Self { param, local_ty } = self;
1970
1971 let mut diag = Diag::new(dcx, level, "")
1972 .with_span(param.span)
1973 .with_span_label(param.span, "uncovered type parameter");
1974 if diag.is_error() {
1975 diag.code(E0210);
1976 }
1977
1978 let note = "\
1979 implementing a foreign trait is only possible if \
1980 at least one of the types for which it is implemented is local";
1981
1982 if let Some(local_ty) = local_ty {
1983 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!(
1984 "type parameter `{param}` must be covered by another type when \
1985 it appears before the first local type (`{local_ty}`)"
1986 ));
1987
1988 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!(
1989 "{note},\nand no uncovered type parameters appear before that first local type"
1990 ));
1991 diag.note(
1992 "in this case, 'before' refers to the following order: \
1993 `impl<..> ForeignTrait<T1, ..., Tn> for T0`,\n\
1994 where `T0` is the first and `Tn` is the last",
1995 );
1996 } else {
1997 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!(
1998 "type parameter `{param}` must be used as an argument to \
1999 some local type (e.g., `MyStruct<{param}>`)"
2000 ));
2001
2002 diag.note(note);
2003 diag.note(
2004 "only traits defined in the current crate can be implemented for a type parameter",
2005 );
2006 }
2007
2008 diag
2009 }
2010}