1use rustc_errors::codes::*;
2use rustc_errors::formatting::DiagMessageAddArg;
3use rustc_errors::{
4 Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, ElidedLifetimeInPathSubdiag,
5 IntoDiagArg, Level, MultiSpan, Subdiagnostic, msg,
6};
7use rustc_macros::{Diagnostic, Subdiagnostic};
8use rustc_span::{Ident, Span, Spanned, Symbol};
9
10use crate::Res;
11use crate::late::{Duplicate, PatternSource};
12
13pub(crate) mod impls;
14
15#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
GenericParamsFromOuterItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
GenericParamsFromOuterItem {
span: __binding_0,
label: __binding_1,
refer_to_type_directly: __binding_2,
use_let: __binding_3,
sugg: __binding_4,
static_or_const: __binding_5,
is_self: __binding_6,
item: __binding_7 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't use {$is_self ->\n [true] `Self`\n *[false] generic parameters\n } from outer item")));
diag.code(E0401);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("nested items are independent from their parent item for everything except for privacy and name resolution")));
;
diag.arg("is_self", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of {$is_self ->\n [true] `Self`\n *[false] generic parameter\n } from outer item")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
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_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
diag
}
}
}
}
};Diagnostic)]
16#[diag("can't use {$is_self ->
17 [true] `Self`
18 *[false] generic parameters
19 } from outer item", code = E0401)]
20#[note(
21 "nested items are independent from their parent item for everything except for privacy and name resolution"
22)]
23pub(crate) struct GenericParamsFromOuterItem {
24 #[primary_span]
25 #[label(
26 "use of {$is_self ->
27 [true] `Self`
28 *[false] generic parameter
29 } from outer item"
30 )]
31 pub(crate) span: Span,
32 #[subdiagnostic]
33 pub(crate) label: Option<GenericParamsFromOuterItemLabel>,
34 #[subdiagnostic]
35 pub(crate) refer_to_type_directly: Option<UseTypeDirectly>,
36 #[subdiagnostic]
37 pub(crate) use_let: Option<GenericParamsFromOuterItemUseLet>,
38 #[subdiagnostic]
39 pub(crate) sugg: Option<GenericParamsFromOuterItemSugg>,
40 #[subdiagnostic]
41 pub(crate) static_or_const: Option<GenericParamsFromOuterItemStaticOrConst>,
42 pub(crate) is_self: bool,
43 #[subdiagnostic]
44 pub(crate) item: Option<GenericParamsFromOuterItemInnerItem>,
45}
46
47#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
GenericParamsFromOuterItemInnerItem {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
GenericParamsFromOuterItemInnerItem {
span: __binding_0, descr: __binding_1, is_self: __binding_2
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("is_self".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("{$is_self ->\n [true] `Self`\n *[false] generic parameter\n } used in this inner {$descr}")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
48#[label(
49 "{$is_self ->
50 [true] `Self`
51 *[false] generic parameter
52 } used in this inner {$descr}"
53)]
54pub(crate) struct GenericParamsFromOuterItemInnerItem {
55 #[primary_span]
56 pub(crate) span: Span,
57 pub(crate) descr: String,
58 pub(crate) is_self: bool,
59}
60
61#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
GenericParamsFromOuterItemStaticOrConst {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
GenericParamsFromOuterItemStaticOrConst::Static => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `static` is a separate item from the item that contains it")),
&sub_args);
diag.note(__message);
}
GenericParamsFromOuterItemStaticOrConst::Const => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `const` is a separate item from the item that contains it")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
62pub(crate) enum GenericParamsFromOuterItemStaticOrConst {
63 #[note("a `static` is a separate item from the item that contains it")]
64 Static,
65 #[note("a `const` is a separate item from the item that contains it")]
66 Const,
67}
68
69#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for GenericParamsFromOuterItemLabel {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
GenericParamsFromOuterItemLabel::SelfTyParam(__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("can't use `Self` here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
GenericParamsFromOuterItemLabel::SelfTyAlias(__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("`Self` type implicitly declared here, by this `impl`")),
&sub_args);
diag.span_label(__binding_0, __message);
}
GenericParamsFromOuterItemLabel::TyParam(__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 parameter from outer item")),
&sub_args);
diag.span_label(__binding_0, __message);
}
GenericParamsFromOuterItemLabel::ConstParam(__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("const parameter from outer item")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
70pub(crate) enum GenericParamsFromOuterItemLabel {
71 #[label("can't use `Self` here")]
72 SelfTyParam(#[primary_span] Span),
73 #[label("`Self` type implicitly declared here, by this `impl`")]
74 SelfTyAlias(#[primary_span] Span),
75 #[label("type parameter from outer item")]
76 TyParam(#[primary_span] Span),
77 #[label("const parameter from outer item")]
78 ConstParam(#[primary_span] Span),
79}
80
81#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for GenericParamsFromOuterItemSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
GenericParamsFromOuterItemSugg {
span: __binding_0, snippet: __binding_1 } => {
let __code_0 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try introducing a local generic parameter here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_0, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
82#[suggestion(
83 "try introducing a local generic parameter here",
84 code = "{snippet}",
85 applicability = "maybe-incorrect",
86 style = "verbose"
87)]
88pub(crate) struct GenericParamsFromOuterItemSugg {
89 #[primary_span]
90 pub(crate) span: Span,
91 pub(crate) snippet: String,
92}
93
94#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for GenericParamsFromOuterItemUseLet
{
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
GenericParamsFromOuterItemUseLet { span: __binding_0 } => {
let __code_1 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using a local `let` binding instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_1, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
95#[suggestion(
96 "try using a local `let` binding instead",
97 code = "let",
98 applicability = "maybe-incorrect",
99 style = "verbose"
100)]
101pub(crate) struct GenericParamsFromOuterItemUseLet {
102 #[primary_span]
103 pub(crate) span: Span,
104}
105
106#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UseTypeDirectly {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UseTypeDirectly { span: __binding_0, snippet: __binding_1 }
=> {
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("refer to the type directly here instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
107#[suggestion(
108 "refer to the type directly here instead",
109 code = "{snippet}",
110 applicability = "maybe-incorrect",
111 style = "verbose"
112)]
113pub(crate) struct UseTypeDirectly {
114 #[primary_span]
115 pub(crate) span: Span,
116 pub(crate) snippet: String,
117}
118
119#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NameAlreadyUsedInParameterList {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NameAlreadyUsedInParameterList {
span: __binding_0,
first_use_span: __binding_1,
name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the name `{$name}` is already used for a generic parameter in this item's generic parameters")));
diag.code(E0403);
;
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("already used")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first use of `{$name}`")));
diag
}
}
}
}
};Diagnostic)]
120#[diag("the name `{$name}` is already used for a generic parameter in this item's generic parameters", code = E0403)]
121pub(crate) struct NameAlreadyUsedInParameterList {
122 #[primary_span]
123 #[label("already used")]
124 pub(crate) span: Span,
125 #[label("first use of `{$name}`")]
126 pub(crate) first_use_span: Span,
127 pub(crate) name: Ident,
128}
129
130#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MethodNotMemberOfTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MethodNotMemberOfTrait {
span: __binding_0,
method: __binding_1,
trait_: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("method `{$method}` is not a member of trait `{$trait_}`")));
diag.code(E0407);
;
diag.arg("method", __binding_1);
diag.arg("trait_", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a member of trait `{$trait_}`")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
131#[diag("method `{$method}` is not a member of trait `{$trait_}`", code = E0407)]
132pub(crate) struct MethodNotMemberOfTrait {
133 #[primary_span]
134 #[label("not a member of trait `{$trait_}`")]
135 pub(crate) span: Span,
136 pub(crate) method: Ident,
137 pub(crate) trait_: String,
138 #[subdiagnostic]
139 pub(crate) sub: Option<AssociatedFnWithSimilarNameExists>,
140}
141
142#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AssociatedFnWithSimilarNameExists
{
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AssociatedFnWithSimilarNameExists {
span: __binding_0, candidate: __binding_1 } => {
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated function with a similar name")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_3, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
143#[suggestion(
144 "there is an associated function with a similar name",
145 code = "{candidate}",
146 applicability = "maybe-incorrect"
147)]
148pub(crate) struct AssociatedFnWithSimilarNameExists {
149 #[primary_span]
150 pub(crate) span: Span,
151 pub(crate) candidate: Symbol,
152}
153
154#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TypeNotMemberOfTrait
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TypeNotMemberOfTrait {
span: __binding_0,
type_: __binding_1,
trait_: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type `{$type_}` is not a member of trait `{$trait_}`")));
diag.code(E0437);
;
diag.arg("type_", __binding_1);
diag.arg("trait_", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a member of trait `{$trait_}`")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
155#[diag("type `{$type_}` is not a member of trait `{$trait_}`", code = E0437)]
156pub(crate) struct TypeNotMemberOfTrait {
157 #[primary_span]
158 #[label("not a member of trait `{$trait_}`")]
159 pub(crate) span: Span,
160 pub(crate) type_: Ident,
161 pub(crate) trait_: String,
162 #[subdiagnostic]
163 pub(crate) sub: Option<AssociatedTypeWithSimilarNameExists>,
164}
165
166#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AssociatedTypeWithSimilarNameExists {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AssociatedTypeWithSimilarNameExists {
span: __binding_0, candidate: __binding_1 } => {
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated type with a similar name")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_4, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
167#[suggestion(
168 "there is an associated type with a similar name",
169 code = "{candidate}",
170 applicability = "maybe-incorrect"
171)]
172pub(crate) struct AssociatedTypeWithSimilarNameExists {
173 #[primary_span]
174 pub(crate) span: Span,
175 pub(crate) candidate: Symbol,
176}
177
178#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConstNotMemberOfTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstNotMemberOfTrait {
span: __binding_0,
const_: __binding_1,
trait_: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const `{$const_}` is not a member of trait `{$trait_}`")));
diag.code(E0438);
;
diag.arg("const_", __binding_1);
diag.arg("trait_", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a member of trait `{$trait_}`")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
179#[diag("const `{$const_}` is not a member of trait `{$trait_}`", code = E0438)]
180pub(crate) struct ConstNotMemberOfTrait {
181 #[primary_span]
182 #[label("not a member of trait `{$trait_}`")]
183 pub(crate) span: Span,
184 pub(crate) const_: Ident,
185 pub(crate) trait_: String,
186 #[subdiagnostic]
187 pub(crate) sub: Option<AssociatedConstWithSimilarNameExists>,
188}
189
190#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AssociatedConstWithSimilarNameExists {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AssociatedConstWithSimilarNameExists {
span: __binding_0, candidate: __binding_1 } => {
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated constant with a similar name")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_5, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
191#[suggestion(
192 "there is an associated constant with a similar name",
193 code = "{candidate}",
194 applicability = "maybe-incorrect"
195)]
196pub(crate) struct AssociatedConstWithSimilarNameExists {
197 #[primary_span]
198 pub(crate) span: Span,
199 pub(crate) candidate: Symbol,
200}
201
202#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
VariableBoundWithDifferentMode {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
VariableBoundWithDifferentMode {
span: __binding_0,
first_binding_span: __binding_1,
variable_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`")));
diag.code(E0409);
;
diag.arg("variable_name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bound in different ways")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first binding")));
diag
}
}
}
}
};Diagnostic)]
203#[diag("variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`", code = E0409)]
204pub(crate) struct VariableBoundWithDifferentMode {
205 #[primary_span]
206 #[label("bound in different ways")]
207 pub(crate) span: Span,
208 #[label("first binding")]
209 pub(crate) first_binding_span: Span,
210 pub(crate) variable_name: Ident,
211}
212
213#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
IdentifierBoundMoreThanOnceInParameterList {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IdentifierBoundMoreThanOnceInParameterList {
span: __binding_0, identifier: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("identifier `{$identifier}` is bound more than once in this parameter list")));
diag.code(E0415);
;
diag.arg("identifier", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("used as parameter more than once")));
diag
}
}
}
}
};Diagnostic)]
214#[diag("identifier `{$identifier}` is bound more than once in this parameter list", code = E0415)]
215pub(crate) struct IdentifierBoundMoreThanOnceInParameterList {
216 #[primary_span]
217 #[label("used as parameter more than once")]
218 pub(crate) span: Span,
219 pub(crate) identifier: Ident,
220}
221
222#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
IdentifierBoundMoreThanOnceInSamePattern {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IdentifierBoundMoreThanOnceInSamePattern {
span: __binding_0, identifier: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("identifier `{$identifier}` is bound more than once in the same pattern")));
diag.code(E0416);
;
diag.arg("identifier", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("used in a pattern more than once")));
diag
}
}
}
}
};Diagnostic)]
223#[diag("identifier `{$identifier}` is bound more than once in the same pattern", code = E0416)]
224pub(crate) struct IdentifierBoundMoreThanOnceInSamePattern {
225 #[primary_span]
226 #[label("used in a pattern more than once")]
227 pub(crate) span: Span,
228 pub(crate) identifier: Ident,
229}
230
231#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UndeclaredLabel {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UndeclaredLabel {
span: __binding_0,
name: __binding_1,
sub_reachable: __binding_2,
sub_reachable_suggestion: __binding_3,
sub_unreachable: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of undeclared label `{$name}`")));
diag.code(E0426);
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("undeclared label `{$name}`")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag
}
}
}
}
};Diagnostic)]
232#[diag("use of undeclared label `{$name}`", code = E0426)]
233pub(crate) struct UndeclaredLabel {
234 #[primary_span]
235 #[label("undeclared label `{$name}`")]
236 pub(crate) span: Span,
237 pub(crate) name: Symbol,
238 #[subdiagnostic]
239 pub(crate) sub_reachable: Option<LabelWithSimilarNameReachable>,
240 #[subdiagnostic]
241 pub(crate) sub_reachable_suggestion: Option<TryUsingSimilarlyNamedLabel>,
242 #[subdiagnostic]
243 pub(crate) sub_unreachable: Option<UnreachableLabelWithSimilarNameExists>,
244}
245
246#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for LabelWithSimilarNameReachable {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
LabelWithSimilarNameReachable(__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("a label with a similar name is reachable")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
247#[label("a label with a similar name is reachable")]
248pub(crate) struct LabelWithSimilarNameReachable(#[primary_span] pub(crate) Span);
249
250#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TryUsingSimilarlyNamedLabel {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
TryUsingSimilarlyNamedLabel {
span: __binding_0, ident_name: __binding_1 } => {
let __code_6 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using similarly named label")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_6, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
251#[suggestion(
252 "try using similarly named label",
253 code = "{ident_name}",
254 applicability = "maybe-incorrect"
255)]
256pub(crate) struct TryUsingSimilarlyNamedLabel {
257 #[primary_span]
258 pub(crate) span: Span,
259 pub(crate) ident_name: Symbol,
260}
261
262#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnreachableLabelWithSimilarNameExists {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnreachableLabelWithSimilarNameExists {
ident_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("a label with a similar name exists but is unreachable")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
263#[label("a label with a similar name exists but is unreachable")]
264pub(crate) struct UnreachableLabelWithSimilarNameExists {
265 #[primary_span]
266 pub(crate) ident_span: Span,
267}
268
269#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotCaptureDynamicEnvironmentInFnItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotCaptureDynamicEnvironmentInFnItem {
span: __binding_0, suggest_closure: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't capture dynamic environment in a fn item")));
diag.code(E0434);
;
diag.span(__binding_0);
if __binding_1 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use the `|| {\"{\"} ... {\"}\"}` closure form instead")));
}
diag
}
}
}
}
};Diagnostic)]
270#[diag("can't capture dynamic environment in a fn item", code = E0434)]
271pub(crate) struct CannotCaptureDynamicEnvironmentInFnItem {
272 #[primary_span]
273 pub(crate) span: Span,
274 #[help("use the `|| {\"{\"} ... {\"}\"}` closure form instead")]
275 pub(crate) suggest_closure: bool,
276}
277
278#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
AttemptToUseNonConstantValueInConstant<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AttemptToUseNonConstantValueInConstant {
span: __binding_0,
with: __binding_1,
with_label: __binding_2,
without: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attempt to use a non-constant value in a constant")));
diag.code(E0435);
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
279#[diag("attempt to use a non-constant value in a constant", code = E0435)]
280pub(crate) struct AttemptToUseNonConstantValueInConstant<'a> {
281 #[primary_span]
282 pub(crate) span: Span,
283 #[subdiagnostic]
284 pub(crate) with: Option<AttemptToUseNonConstantValueInConstantWithSuggestion<'a>>,
285 #[subdiagnostic]
286 pub(crate) with_label: Option<AttemptToUseNonConstantValueInConstantLabelWithSuggestion>,
287 #[subdiagnostic]
288 pub(crate) without: Option<AttemptToUseNonConstantValueInConstantWithoutSuggestion<'a>>,
289}
290
291#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AttemptToUseNonConstantValueInConstantWithSuggestion<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AttemptToUseNonConstantValueInConstantWithSuggestion::Placeholder {
span: __binding_0,
suggestion: __binding_1,
type_span: __binding_2,
current: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", __binding_1))
});
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": /* Type */"))
});
suggestions.push((__binding_0, __code_7));
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_8));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggestion".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("current".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("consider using `{$suggestion}` instead of `{$current}`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
}
AttemptToUseNonConstantValueInConstantWithSuggestion::Usize {
span: __binding_0,
suggestion: __binding_1,
type_span: __binding_2,
current: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_9 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", __binding_1))
});
let __code_10 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": usize"))
});
suggestions.push((__binding_0, __code_9));
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_10));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggestion".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("current".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("consider using `{$suggestion}` instead of `{$current}`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
292pub(crate) enum AttemptToUseNonConstantValueInConstantWithSuggestion<'a> {
293 #[multipart_suggestion(
294 "consider using `{$suggestion}` instead of `{$current}`",
295 style = "verbose",
296 applicability = "has-placeholders"
297 )]
298 Placeholder {
299 #[suggestion_part(code = "{suggestion} ")]
300 span: Span,
301 suggestion: &'a str,
302 #[suggestion_part(code = ": /* Type */")]
303 type_span: Option<Span>,
304 current: &'a str,
305 },
306 #[multipart_suggestion(
307 "consider using `{$suggestion}` instead of `{$current}`",
308 style = "verbose",
309 applicability = "machine-applicable"
310 )]
311 Usize {
312 #[suggestion_part(code = "{suggestion} ")]
313 span: Span,
314 suggestion: &'a str,
315 #[suggestion_part(code = ": usize")]
316 type_span: Option<Span>,
317 current: &'a str,
318 },
319}
320
321#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AttemptToUseNonConstantValueInConstantLabelWithSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AttemptToUseNonConstantValueInConstantLabelWithSuggestion {
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("non-constant value")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
322#[label("non-constant value")]
323pub(crate) struct AttemptToUseNonConstantValueInConstantLabelWithSuggestion {
324 #[primary_span]
325 pub(crate) span: Span,
326}
327
328#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AttemptToUseNonConstantValueInConstantWithoutSuggestion<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AttemptToUseNonConstantValueInConstantWithoutSuggestion {
ident_span: __binding_0, suggestion: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggestion".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 would need to be a `{$suggestion}`")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
329#[label("this would need to be a `{$suggestion}`")]
330pub(crate) struct AttemptToUseNonConstantValueInConstantWithoutSuggestion<'a> {
331 #[primary_span]
332 pub(crate) ident_span: Span,
333 pub(crate) suggestion: &'a str,
334}
335
336#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
BindingShadowsSomethingUnacceptable<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BindingShadowsSomethingUnacceptable {
span: __binding_0,
shadowing_binding: __binding_1,
shadowed_binding: __binding_2,
article: __binding_3,
sub_suggestion: __binding_4,
shadowed_binding_span: __binding_5,
participle: __binding_6,
name: __binding_7 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$shadowing_binding}s cannot shadow {$shadowed_binding}s")));
diag.code(E0530);
;
diag.arg("shadowing_binding", __binding_1);
diag.arg("shadowed_binding", __binding_2);
diag.arg("article", __binding_3);
diag.arg("participle", __binding_6);
diag.arg("name", __binding_7);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot be named the same as {$article} {$shadowed_binding}")));
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag.span_label(__binding_5,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$shadowed_binding} `{$name}` is {$participle} here")));
diag
}
}
}
}
};Diagnostic)]
337#[diag("{$shadowing_binding}s cannot shadow {$shadowed_binding}s", code = E0530)]
338pub(crate) struct BindingShadowsSomethingUnacceptable<'a> {
339 #[primary_span]
340 #[label("cannot be named the same as {$article} {$shadowed_binding}")]
341 pub(crate) span: Span,
342 pub(crate) shadowing_binding: PatternSource,
343 pub(crate) shadowed_binding: Res,
344 pub(crate) article: &'a str,
345 #[subdiagnostic]
346 pub(crate) sub_suggestion: Option<BindingShadowsSomethingUnacceptableSuggestion>,
347 #[label("the {$shadowed_binding} `{$name}` is {$participle} here")]
348 pub(crate) shadowed_binding_span: Span,
349 pub(crate) participle: &'a str,
350 pub(crate) name: Symbol,
351}
352
353#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
BindingShadowsSomethingUnacceptableSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
BindingShadowsSomethingUnacceptableSuggestion {
span: __binding_0, name: __binding_1 } => {
let __code_11 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}(..)", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try specify the pattern arguments")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_11, rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
354#[suggestion(
355 "try specify the pattern arguments",
356 code = "{name}(..)",
357 applicability = "unspecified"
358)]
359pub(crate) struct BindingShadowsSomethingUnacceptableSuggestion {
360 #[primary_span]
361 pub(crate) span: Span,
362 pub(crate) name: Symbol,
363}
364
365#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ForwardDeclaredGenericParam {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ForwardDeclaredGenericParam {
span: __binding_0, param: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameter defaults cannot reference parameters before they are declared")));
diag.code(E0128);
;
diag.arg("param", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot reference `{$param}` before it is declared")));
diag
}
}
}
}
};Diagnostic)]
366#[diag("generic parameter defaults cannot reference parameters before they are declared", code = E0128)]
367pub(crate) struct ForwardDeclaredGenericParam {
368 #[primary_span]
369 #[label("cannot reference `{$param}` before it is declared")]
370 pub(crate) span: Span,
371 pub(crate) param: Symbol,
372}
373
374#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ForwardDeclaredGenericInConstParamTy {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ForwardDeclaredGenericInConstParamTy {
span: __binding_0, param: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameter types cannot reference parameters before they are declared")));
;
diag.arg("param", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameter type cannot reference `{$param}` before it is declared")));
diag
}
}
}
}
};Diagnostic)]
375#[diag("const parameter types cannot reference parameters before they are declared")]
376pub(crate) struct ForwardDeclaredGenericInConstParamTy {
377 #[primary_span]
378 #[label("const parameter type cannot reference `{$param}` before it is declared")]
379 pub(crate) span: Span,
380 pub(crate) param: Symbol,
381}
382
383#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ParamInTyOfConstParam {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ParamInTyOfConstParam { span: __binding_0, name: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type of const parameters must not depend on other generic parameters")));
diag.code(E0770);
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type must not depend on the parameter `{$name}`")));
diag
}
}
}
}
};Diagnostic)]
384#[diag("the type of const parameters must not depend on other generic parameters", code = E0770)]
385pub(crate) struct ParamInTyOfConstParam {
386 #[primary_span]
387 #[label("the type must not depend on the parameter `{$name}`")]
388 pub(crate) span: Span,
389 pub(crate) name: Symbol,
390}
391
392#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
SelfInGenericParamDefault {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SelfInGenericParamDefault { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters cannot use `Self` in their defaults")));
diag.code(E0735);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
393#[diag("generic parameters cannot use `Self` in their defaults", code = E0735)]
394pub(crate) struct SelfInGenericParamDefault {
395 #[primary_span]
396 pub(crate) span: Span,
397}
398
399#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for SelfInConstGenericTy
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SelfInConstGenericTy {
span: __binding_0, enable_feature: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use `Self` in const parameter type")));
;
diag.span(__binding_0);
if __binding_1 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(min_adt_const_params)]` to the crate attributes to enable `Self` as a const parameter type")));
}
diag
}
}
}
}
};Diagnostic)]
400#[diag("cannot use `Self` in const parameter type")]
401pub(crate) struct SelfInConstGenericTy {
402 #[primary_span]
403 pub(crate) span: Span,
404 #[help(
405 "add `#![feature(min_adt_const_params)]` to the crate attributes to enable `Self` as a const parameter type"
406 )]
407 pub(crate) enable_feature: bool,
408}
409
410#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ParamInNonTrivialAnonConst {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ParamInNonTrivialAnonConst {
span: __binding_0,
name: __binding_1,
param_kind: __binding_2,
help: __binding_3,
is_gca_const_items: __binding_4,
help_gca: __binding_5,
help_suggest_gca: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_gca_const_items ->\n [true] generic parameters in const blocks are not allowed; use a named `const` item instead\n *[false] generic parameters may not be used in const operations\n}")));
;
diag.arg("name", __binding_1);
diag.arg("is_gca_const_items", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot perform const operation using `{$name}`")));
diag.subdiagnostic(__binding_2);
if __binding_3 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(generic_const_exprs)]` to allow generic const expressions")));
}
if __binding_5 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider wrapping the expression in the `gca!` macro")));
}
if __binding_6 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatively, you can use `#![feature(gca_const_items)]` and wrap the expression in the `gca!` macro")));
}
diag
}
}
}
}
};Diagnostic)]
411#[diag(
412 "{$is_gca_const_items ->
413 [true] generic parameters in const blocks are not allowed; use a named `const` item instead
414 *[false] generic parameters may not be used in const operations
415}"
416)]
417pub(crate) struct ParamInNonTrivialAnonConst {
418 #[primary_span]
419 #[label("cannot perform const operation using `{$name}`")]
420 pub(crate) span: Span,
421 pub(crate) name: Symbol,
422 #[subdiagnostic]
423 pub(crate) param_kind: ParamKindInNonTrivialAnonConst,
424 #[help("add `#![feature(generic_const_exprs)]` to allow generic const expressions")]
425 pub(crate) help: bool,
426 pub(crate) is_gca_const_items: bool,
427 #[help("consider wrapping the expression in the `gca!` macro")]
428 pub(crate) help_gca: bool,
429 #[help(
430 "alternatively, you can use `#![feature(gca_const_items)]` and wrap the expression in the `gca!` macro"
431 )]
432 pub(crate) help_suggest_gca: bool,
433}
434
435#[derive(#[automatically_derived]impl ::core::fmt::Debug for
ParamKindInNonTrivialAnonConst {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Type => ::core::fmt::Formatter::write_str(f, "Type"),
Self::Const { name: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Const name", &__self_0),
Self::Lifetime =>
::core::fmt::Formatter::write_str(f, "Lifetime"),
}
}
}Debug)]
436#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParamKindInNonTrivialAnonConst {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ParamKindInNonTrivialAnonConst::Type => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameters may not be used in const expressions")),
&sub_args);
diag.note(__message);
}
ParamKindInNonTrivialAnonConst::Const { name: __binding_0 }
=> {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("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("const parameters may only be used as standalone arguments here, i.e. `{$name}`")),
&sub_args);
diag.help(__message);
}
ParamKindInNonTrivialAnonConst::Lifetime => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters may not be used in const expressions")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
437pub(crate) enum ParamKindInNonTrivialAnonConst {
438 #[note("type parameters may not be used in const expressions")]
439 Type,
440 #[help("const parameters may only be used as standalone arguments here, i.e. `{$name}`")]
441 Const { name: Symbol },
442 #[note("lifetime parameters may not be used in const expressions")]
443 Lifetime,
444}
445
446#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnreachableLabel {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnreachableLabel {
span: __binding_0,
name: __binding_1,
definition_span: __binding_2,
sub_suggestion: __binding_3,
sub_suggestion_label: __binding_4,
sub_unreachable_label: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unreachable label `{$name}`")));
diag.code(E0767);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labels are unreachable through functions, closures, async blocks and modules")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable label `{$name}`")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable label defined here")));
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag
}
}
}
}
};Diagnostic)]
447#[diag("use of unreachable label `{$name}`", code = E0767)]
448#[note("labels are unreachable through functions, closures, async blocks and modules")]
449pub(crate) struct UnreachableLabel {
450 #[primary_span]
451 #[label("unreachable label `{$name}`")]
452 pub(crate) span: Span,
453 pub(crate) name: Symbol,
454 #[label("unreachable label defined here")]
455 pub(crate) definition_span: Span,
456 #[subdiagnostic]
457 pub(crate) sub_suggestion: Option<UnreachableLabelSubSuggestion>,
458 #[subdiagnostic]
459 pub(crate) sub_suggestion_label: Option<UnreachableLabelSubLabel>,
460 #[subdiagnostic]
461 pub(crate) sub_unreachable_label: Option<UnreachableLabelSubLabelUnreachable>,
462}
463
464#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnreachableLabelSubSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnreachableLabelSubSuggestion {
span: __binding_0, ident_name: __binding_1 } => {
let __code_12 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using similarly named label")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_12, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
465#[suggestion(
466 "try using similarly named label",
467 code = "{ident_name}",
468 applicability = "maybe-incorrect"
469)]
470pub(crate) struct UnreachableLabelSubSuggestion {
471 #[primary_span]
472 pub(crate) span: Span,
473 pub(crate) ident_name: Symbol,
474}
475
476#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnreachableLabelSubLabel {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnreachableLabelSubLabel { ident_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("a label with a similar name is reachable")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
477#[label("a label with a similar name is reachable")]
478pub(crate) struct UnreachableLabelSubLabel {
479 #[primary_span]
480 pub(crate) ident_span: Span,
481}
482
483#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnreachableLabelSubLabelUnreachable {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnreachableLabelSubLabelUnreachable {
ident_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("a label with a similar name exists but is also unreachable")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
484#[label("a label with a similar name exists but is also unreachable")]
485pub(crate) struct UnreachableLabelSubLabelUnreachable {
486 #[primary_span]
487 pub(crate) ident_span: Span,
488}
489
490#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InvalidAsmSym {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
InvalidAsmSym { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `sym` operand")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`sym` operands must refer to either a function or a static")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("is a local variable")));
diag
}
}
}
}
};Diagnostic)]
491#[diag("invalid `sym` operand")]
492#[help("`sym` operands must refer to either a function or a static")]
493pub(crate) struct InvalidAsmSym {
494 #[primary_span]
495 #[label("is a local variable")]
496 pub(crate) span: Span,
497}
498
499#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for LowercaseSelf {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LowercaseSelf { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attempt to use a non-constant value in a constant")));
let __code_13 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Self"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `Self`")),
__code_13, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
500#[diag("attempt to use a non-constant value in a constant")]
501pub(crate) struct LowercaseSelf {
502 #[primary_span]
503 #[suggestion(
504 "try using `Self`",
505 code = "Self",
506 applicability = "maybe-incorrect",
507 style = "short"
508 )]
509 pub(crate) span: Span,
510}
511
512#[derive(#[automatically_derived]impl ::core::fmt::Debug for BindingInNeverPattern {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"BindingInNeverPattern span", &&self.span)
}
}Debug)]
513#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
BindingInNeverPattern {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BindingInNeverPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never patterns cannot contain variable bindings")));
let __code_14 =
[::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("use a wildcard `_` instead")),
__code_14, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
514#[diag("never patterns cannot contain variable bindings")]
515pub(crate) struct BindingInNeverPattern {
516 #[primary_span]
517 #[suggestion(
518 "use a wildcard `_` instead",
519 code = "_",
520 applicability = "machine-applicable",
521 style = "short"
522 )]
523 pub(crate) span: Span,
524}
525
526#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotUseInnerLocalInMoveExpr {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotUseInnerLocalInMoveExpr {
span: __binding_0,
ident: __binding_1,
binding_span: __binding_2,
move_expr_span: __binding_3,
scope_span: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use `{$ident}` in this move expression")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is defined here")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression is evaluated outside that scope")));
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is defined within this scope")));
diag
}
}
}
}
};Diagnostic)]
527#[diag("cannot use `{$ident}` in this move expression")]
528pub(crate) struct CannotUseInnerLocalInMoveExpr {
529 #[primary_span]
530 pub(crate) span: Span,
531 pub(crate) ident: Ident,
532 #[label("`{$ident}` is defined here")]
533 pub(crate) binding_span: Span,
534 #[label("this expression is evaluated outside that scope")]
535 pub(crate) move_expr_span: Span,
536 #[label("`{$ident}` is defined within this scope")]
537 pub(crate) scope_span: Span,
538}
539
540#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TraitImplDuplicate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TraitImplDuplicate {
span: __binding_0,
old_span: __binding_1,
trait_item_span: __binding_2,
trait_span: __binding_3,
impl_span: __binding_4,
name: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate definitions with name `{$name}`:")));
diag.code(E0201);
;
diag.arg("name", __binding_5);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate definition")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous definition here")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item in trait")));
diag.span_context(__binding_3);
diag.span_context(__binding_4);
diag
}
}
}
}
};Diagnostic)]
541#[diag("duplicate definitions with name `{$name}`:", code = E0201)]
542pub(crate) struct TraitImplDuplicate {
543 #[primary_span]
544 #[label("duplicate definition")]
545 pub(crate) span: Span,
546 #[label("previous definition here")]
547 pub(crate) old_span: Span,
548 #[label("item in trait")]
549 pub(crate) trait_item_span: Span,
550 #[context]
551 pub(crate) trait_span: Span,
552 #[context]
553 pub(crate) impl_span: Span,
554 pub(crate) name: Ident,
555}
556
557#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for Relative2018 {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
Relative2018 {
span: __binding_0,
path_span: __binding_1,
path_str: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("relative paths are not supported in visibilities in 2018 edition or later")));
let __code_15 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("crate::{0}",
__binding_2))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try")),
__code_15, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
558#[diag("relative paths are not supported in visibilities in 2018 edition or later")]
559pub(crate) struct Relative2018 {
560 #[primary_span]
561 pub(crate) span: Span,
562 #[suggestion("try", code = "crate::{path_str}", applicability = "maybe-incorrect")]
563 pub(crate) path_span: Span,
564 pub(crate) path_str: String,
565}
566
567#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AncestorOnly {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AncestorOnly(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("visibilities can only be restricted to ancestor modules")));
diag.code(E0742);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
568#[diag("visibilities can only be restricted to ancestor modules", code = E0742)]
569pub(crate) struct AncestorOnly(#[primary_span] pub(crate) Span);
570
571#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ExpectedModuleFound
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExpectedModuleFound {
span: __binding_0, res: __binding_1, path_str: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected module, found {$res} `{$path_str}`")));
diag.code(E0577);
;
diag.arg("res", __binding_1);
diag.arg("path_str", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a module")));
diag
}
}
}
}
};Diagnostic)]
572#[diag("expected module, found {$res} `{$path_str}`", code = E0577)]
573pub(crate) struct ExpectedModuleFound {
574 #[primary_span]
575 #[label("not a module")]
576 pub(crate) span: Span,
577 pub(crate) res: Res,
578 pub(crate) path_str: String,
579}
580
581#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for Indeterminate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
Indeterminate(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot determine resolution for the visibility")));
diag.code(E0578);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
582#[diag("cannot determine resolution for the visibility", code = E0578)]
583pub(crate) struct Indeterminate(#[primary_span] pub(crate) Span);
584
585#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ToolModuleImported {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ToolModuleImported { span: __binding_0, import: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use a tool module through an import")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the tool module imported here")));
diag
}
}
}
}
};Diagnostic)]
586#[diag("cannot use a tool module through an import")]
587pub(crate) struct ToolModuleImported {
588 #[primary_span]
589 pub(crate) span: Span,
590 #[note("the tool module imported here")]
591 pub(crate) import: Span,
592}
593
594#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ModuleOnly {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ModuleOnly(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("visibility must resolve to a module")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
595#[diag("visibility must resolve to a module")]
596pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span);
597
598#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
MacroExpectedFound<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroExpectedFound {
span: __binding_0,
found: __binding_1,
article: __binding_2,
expected: __binding_3,
macro_path: __binding_4,
remove_surrounding_derive: __binding_5,
add_as_non_derive: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected {$expected}, found {$found} `{$macro_path}`")));
;
diag.arg("found", __binding_1);
diag.arg("article", __binding_2);
diag.arg("expected", __binding_3);
diag.arg("macro_path", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not {$article} {$expected}")));
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
if let Some(__binding_6) = __binding_6 {
diag.subdiagnostic(__binding_6);
}
diag
}
}
}
}
};Diagnostic)]
599#[diag("expected {$expected}, found {$found} `{$macro_path}`")]
600pub(crate) struct MacroExpectedFound<'a> {
601 #[primary_span]
602 #[label("not {$article} {$expected}")]
603 pub(crate) span: Span,
604 pub(crate) found: &'a str,
605 pub(crate) article: &'static str,
606 pub(crate) expected: &'a str,
607 pub(crate) macro_path: &'a str,
608 #[subdiagnostic]
609 pub(crate) remove_surrounding_derive: Option<RemoveSurroundingDerive>,
610 #[subdiagnostic]
611 pub(crate) add_as_non_derive: Option<AddAsNonDerive<'a>>,
612}
613
614#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RemoveSurroundingDerive {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
RemoveSurroundingDerive { 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("remove from the surrounding `derive()`")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
615#[help("remove from the surrounding `derive()`")]
616pub(crate) struct RemoveSurroundingDerive {
617 #[primary_span]
618 pub(crate) span: Span,
619}
620
621#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for AddAsNonDerive<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AddAsNonDerive { macro_path: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("macro_path".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("\n add as non-Derive macro\n `#[{$macro_path}]`")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
622#[help(
623 "
624 add as non-Derive macro
625 `#[{$macro_path}]`"
626)]
627pub(crate) struct AddAsNonDerive<'a> {
628 pub(crate) macro_path: &'a str,
629}
630
631#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ProcMacroSameCrate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ProcMacroSameCrate { span: __binding_0, is_test: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't use a procedural macro from the same crate that defines it")));
;
diag.span(__binding_0);
if __binding_1 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can define integration tests in a directory named `tests`")));
}
diag
}
}
}
}
};Diagnostic)]
632#[diag("can't use a procedural macro from the same crate that defines it")]
633pub(crate) struct ProcMacroSameCrate {
634 #[primary_span]
635 pub(crate) span: Span,
636 #[help("you can define integration tests in a directory named `tests`")]
637 pub(crate) is_test: bool,
638}
639
640#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ProcMacroDeriveResolutionFallback {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ProcMacroDeriveResolutionFallback {
span: __binding_0, ns_descr: __binding_1, ident: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot find {$ns_descr} `{$ident}` in this scope")));
;
diag.arg("ns_descr", __binding_1);
diag.arg("ident", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("names from parent modules are not accessible without an explicit import")));
diag
}
}
}
}
};Diagnostic)]
641#[diag("cannot find {$ns_descr} `{$ident}` in this scope")]
642pub(crate) struct ProcMacroDeriveResolutionFallback {
643 #[label("names from parent modules are not accessible without an explicit import")]
644 pub span: Span,
645 pub ns_descr: &'static str,
646 pub ident: Symbol,
647}
648
649#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MacroExpandedMacroExportsAccessedByAbsolutePaths {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroExpandedMacroExportsAccessedByAbsolutePaths {
definition: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths")));
;
diag.span_note(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the macro is defined here")));
diag
}
}
}
}
};Diagnostic)]
650#[diag(
651 "macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"
652)]
653pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths {
654 #[note("the macro is defined here")]
655 pub definition: Span,
656}
657
658#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MacroUseExternCrateSelf {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroUseExternCrateSelf { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[macro_use]` is not supported on `extern crate self`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
659#[diag("`#[macro_use]` is not supported on `extern crate self`")]
660pub(crate) struct MacroUseExternCrateSelf {
661 #[primary_span]
662 pub(crate) span: Span,
663}
664
665#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CfgAccessibleUnsure
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CfgAccessibleUnsure { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not sure whether the path is accessible or not")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type may have associated items, but we are currently not checking them")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
666#[diag("not sure whether the path is accessible or not")]
667#[note("the type may have associated items, but we are currently not checking them")]
668pub(crate) struct CfgAccessibleUnsure {
669 #[primary_span]
670 pub(crate) span: Span,
671}
672
673#[derive(#[automatically_derived]impl ::core::fmt::Debug for ParamInEnumDiscriminant {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"ParamInEnumDiscriminant span name param_kind", &self.span,
&self.name, &&self.param_kind)
}
}Debug)]
674#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ParamInEnumDiscriminant {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ParamInEnumDiscriminant {
span: __binding_0,
name: __binding_1,
param_kind: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters may not be used in enum discriminant values")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot perform const operation using `{$name}`")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
675#[diag("generic parameters may not be used in enum discriminant values")]
676pub(crate) struct ParamInEnumDiscriminant {
677 #[primary_span]
678 #[label("cannot perform const operation using `{$name}`")]
679 pub(crate) span: Span,
680 pub(crate) name: Symbol,
681 #[subdiagnostic]
682 pub(crate) param_kind: ParamKindInEnumDiscriminant,
683}
684
685#[derive(#[automatically_derived]impl ::core::fmt::Debug for
ParamKindInEnumDiscriminant {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ParamKindInEnumDiscriminant::Type => "Type",
ParamKindInEnumDiscriminant::Const => "Const",
ParamKindInEnumDiscriminant::Lifetime => "Lifetime",
})
}
}Debug)]
686#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParamKindInEnumDiscriminant {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ParamKindInEnumDiscriminant::Type => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameters may not be used in enum discriminant values")),
&sub_args);
diag.note(__message);
}
ParamKindInEnumDiscriminant::Const => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameters may not be used in enum discriminant values")),
&sub_args);
diag.note(__message);
}
ParamKindInEnumDiscriminant::Lifetime => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters may not be used in enum discriminant values")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
687pub(crate) enum ParamKindInEnumDiscriminant {
688 #[note("type parameters may not be used in enum discriminant values")]
689 Type,
690 #[note("const parameters may not be used in enum discriminant values")]
691 Const,
692 #[note("lifetime parameters may not be used in enum discriminant values")]
693 Lifetime,
694}
695
696#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeImportBinding {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ChangeImportBinding { 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("you can use `as` to change the binding name of the import")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
697#[label("you can use `as` to change the binding name of the import")]
698pub(crate) struct ChangeImportBinding {
699 #[primary_span]
700 pub(crate) span: Span,
701}
702
703#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeImportBindingSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ChangeImportBindingSuggestion {
span: __binding_0, suggestion: __binding_1 } => {
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();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can use `as` to change the binding name of the import")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_16, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
704#[suggestion(
705 "you can use `as` to change the binding name of the import",
706 code = "{suggestion}",
707 applicability = "maybe-incorrect"
708)]
709pub(crate) struct ChangeImportBindingSuggestion {
710 #[primary_span]
711 pub(crate) span: Span,
712 pub(crate) suggestion: String,
713}
714
715#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
ImportsCannotReferTo<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ImportsCannotReferTo { span: __binding_0, what: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("imports cannot refer to {$what}")));
;
diag.arg("what", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
716#[diag("imports cannot refer to {$what}")]
717pub(crate) struct ImportsCannotReferTo<'a> {
718 #[primary_span]
719 pub(crate) span: Span,
720 pub(crate) what: &'a str,
721}
722
723#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
CannotFindIdentInThisScope<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotFindIdentInThisScope {
span: __binding_0, expected: __binding_1, ident: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot find {$expected} `{$ident}` in this scope")));
;
diag.arg("expected", __binding_1);
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
724#[diag("cannot find {$expected} `{$ident}` in this scope")]
725pub(crate) struct CannotFindIdentInThisScope<'a> {
726 #[primary_span]
727 pub(crate) span: Span,
728 pub(crate) expected: &'a str,
729 pub(crate) ident: Ident,
730}
731
732#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExplicitUnsafeTraits {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ExplicitUnsafeTraits { span: __binding_0, ident: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("unsafe traits like `{$ident}` should be implemented explicitly")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
733#[note("unsafe traits like `{$ident}` should be implemented explicitly")]
734pub(crate) struct ExplicitUnsafeTraits {
735 #[primary_span]
736 pub(crate) span: Span,
737 pub(crate) ident: Ident,
738}
739
740#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MacroDefinedLater {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MacroDefinedLater { 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("a macro with the same name exists, but it appears later")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
741#[note("a macro with the same name exists, but it appears later")]
742pub(crate) struct MacroDefinedLater {
743 #[primary_span]
744 pub(crate) span: Span,
745}
746
747#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MacroSuggMovePosition {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MacroSuggMovePosition {
span: __binding_0, ident: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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 moving the definition of `{$ident}` before this call")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
748#[label("consider moving the definition of `{$ident}` before this call")]
749pub(crate) struct MacroSuggMovePosition {
750 #[primary_span]
751 pub(crate) span: Span,
752 pub(crate) ident: Ident,
753}
754
755#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MacroRulesNot {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MacroRulesNot::Func { span: __binding_0, ident: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("`{$ident}` exists, but has no rules for function-like invocation")),
&sub_args);
diag.span_label(__binding_0, __message);
}
MacroRulesNot::Attr { span: __binding_0, ident: __binding_1
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("`{$ident}` exists, but has no `attr` rules")),
&sub_args);
diag.span_label(__binding_0, __message);
}
MacroRulesNot::Derive {
span: __binding_0, ident: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("`{$ident}` exists, but has no `derive` rules")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
756pub(crate) enum MacroRulesNot {
757 #[label("`{$ident}` exists, but has no rules for function-like invocation")]
758 Func {
759 #[primary_span]
760 span: Span,
761 ident: Ident,
762 },
763 #[label("`{$ident}` exists, but has no `attr` rules")]
764 Attr {
765 #[primary_span]
766 span: Span,
767 ident: Ident,
768 },
769 #[label("`{$ident}` exists, but has no `derive` rules")]
770 Derive {
771 #[primary_span]
772 span: Span,
773 ident: Ident,
774 },
775}
776
777#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MaybeMissingMacroRulesName {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MaybeMissingMacroRulesName { spans: __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("maybe you have forgotten to define a name for this `macro_rules!`")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
778#[note("maybe you have forgotten to define a name for this `macro_rules!`")]
779pub(crate) struct MaybeMissingMacroRulesName {
780 #[primary_span]
781 pub(crate) spans: MultiSpan,
782}
783
784#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddedMacroUse {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AddedMacroUse { 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("you might be missing a `#[macro_use]` attribute on a `mod` module or `use` import")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
785#[help("you might be missing a `#[macro_use]` attribute on a `mod` module or `use` import")]
786pub(crate) struct AddedMacroUse {
787 #[primary_span]
788 pub(crate) span: MultiSpan,
789}
790
791#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderAddingADerive {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ConsiderAddingADerive {
span: __binding_0, suggestion: __binding_1 } => {
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();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a derive")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_17, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
792#[suggestion("consider adding a derive", code = "{suggestion}", applicability = "maybe-incorrect")]
793pub(crate) struct ConsiderAddingADerive {
794 #[primary_span]
795 pub(crate) span: Span,
796 pub(crate) suggestion: String,
797}
798
799#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotDetermineImportResolution {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotDetermineImportResolution { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot determine resolution for the import")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
800#[diag("cannot determine resolution for the import")]
801pub(crate) struct CannotDetermineImportResolution {
802 #[primary_span]
803 pub(crate) span: Span,
804}
805
806#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotDetermineMacroResolution {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotDetermineMacroResolution {
span: __binding_0, kind: __binding_1, path: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot determine resolution for the {$kind} `{$path}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("import resolution is stuck, try simplifying macro imports")));
;
diag.arg("kind", __binding_1);
diag.arg("path", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
807#[diag("cannot determine resolution for the {$kind} `{$path}`")]
808#[note("import resolution is stuck, try simplifying macro imports")]
809pub(crate) struct CannotDetermineMacroResolution {
810 #[primary_span]
811 pub(crate) span: Span,
812 pub(crate) kind: &'static str,
813 pub(crate) path: String,
814}
815
816#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotBeReexportedPrivate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotBeReexportedPrivate {
span: __binding_0, ident: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is private, and cannot be re-exported")));
diag.code(E0364);
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
817#[diag("`{$ident}` is private, and cannot be re-exported", code = E0364)]
818pub(crate) struct CannotBeReexportedPrivate {
819 #[primary_span]
820 pub(crate) span: Span,
821 pub(crate) ident: Ident,
822}
823
824#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotBeReexportedCratePublic {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotBeReexportedCratePublic {
span: __binding_0, ident: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is only public within the crate, and cannot be re-exported outside")));
diag.code(E0364);
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
825#[diag("`{$ident}` is only public within the crate, and cannot be re-exported outside", code = E0364)]
826pub(crate) struct CannotBeReexportedCratePublic {
827 #[primary_span]
828 pub(crate) span: Span,
829 pub(crate) ident: Ident,
830}
831
832#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotBeReexportedPrivateNS {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotBeReexportedPrivateNS {
span: __binding_0,
ident: __binding_1,
parent: __binding_2,
descr: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is private, and cannot be re-exported")));
diag.code(E0365);
;
diag.arg("ident", __binding_1);
diag.arg("descr", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("re-export of private `{$ident}`")));
if let Some(__binding_2) = __binding_2 {
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider declaring {$descr} `{$ident}` with `pub`")));
}
diag
}
}
}
}
};Diagnostic)]
833#[diag("`{$ident}` is private, and cannot be re-exported", code = E0365)]
834pub(crate) struct CannotBeReexportedPrivateNS {
835 #[primary_span]
836 #[label("re-export of private `{$ident}`")]
837 pub(crate) span: Span,
838 pub(crate) ident: Ident,
839 #[note("consider declaring {$descr} `{$ident}` with `pub`")]
840 pub(crate) parent: Option<Span>,
841 pub(crate) descr: &'static str,
842}
843
844#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotBeReexportedCratePublicNS {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotBeReexportedCratePublicNS {
span: __binding_0,
ident: __binding_1,
parent: __binding_2,
descr: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is only public within the crate, and cannot be re-exported outside")));
diag.code(E0365);
;
diag.arg("ident", __binding_1);
diag.arg("descr", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("re-export of crate public `{$ident}`")));
if let Some(__binding_2) = __binding_2 {
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider declaring {$descr} `{$ident}` with `pub`")));
}
diag
}
}
}
}
};Diagnostic)]
845#[diag("`{$ident}` is only public within the crate, and cannot be re-exported outside", code = E0365)]
846pub(crate) struct CannotBeReexportedCratePublicNS {
847 #[primary_span]
848 #[label("re-export of crate public `{$ident}`")]
849 pub(crate) span: Span,
850 pub(crate) ident: Ident,
851 #[note("consider declaring {$descr} `{$ident}` with `pub`")]
852 pub(crate) parent: Option<Span>,
853 pub(crate) descr: &'static str,
854}
855
856#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PrivateExternCrateReexport {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PrivateExternCrateReexport {
ident: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern crate `{$ident}` is private and cannot be re-exported")));
let __code_18 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub "))
})].into_iter();
diag.code(E0365);
;
diag.arg("ident", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider making the `extern crate` item publicly accessible")),
__code_18, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
857#[diag("extern crate `{$ident}` is private and cannot be re-exported", code = E0365)]
858pub(crate) struct PrivateExternCrateReexport {
859 pub ident: Ident,
860 #[suggestion(
861 "consider making the `extern crate` item publicly accessible",
862 code = "pub ",
863 style = "verbose",
864 applicability = "maybe-incorrect"
865 )]
866 pub sugg: Option<Span>,
867}
868
869#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderAddingMacroExport {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ConsiderAddingMacroExport { 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("consider adding a `#[macro_export]` to the macro in the imported module")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
870#[help("consider adding a `#[macro_export]` to the macro in the imported module")]
871pub(crate) struct ConsiderAddingMacroExport {
872 #[primary_span]
873 pub(crate) span: Span,
874}
875
876#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderMarkingAsPubCrate {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ConsiderMarkingAsPubCrate { vis_span: __binding_0 } => {
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub(crate)"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_19, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
877#[suggestion(
878 "in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)`",
879 code = "pub(crate)",
880 applicability = "maybe-incorrect"
881)]
882pub(crate) struct ConsiderMarkingAsPubCrate {
883 #[primary_span]
884 pub(crate) vis_span: Span,
885}
886
887#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderMarkingAsPub {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ConsiderMarkingAsPub {
span: __binding_0, ident: __binding_1, descr: __binding_2 }
=> {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("descr".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("consider marking `{$ident}` as `pub` in the imported {$descr}")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
888#[note("consider marking `{$ident}` as `pub` in the imported {$descr}")]
889pub(crate) struct ConsiderMarkingAsPub {
890 #[primary_span]
891 pub(crate) span: MultiSpan,
892 pub(crate) ident: Ident,
893 pub(crate) descr: &'static str,
894}
895
896#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotGlobImportAllCrates {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotGlobImportAllCrates { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot glob-import all possible crates")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
897#[diag("cannot glob-import all possible crates")]
898pub(crate) struct CannotGlobImportAllCrates {
899 #[primary_span]
900 pub(crate) span: Span,
901}
902
903#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedResChangeTyToConstParamSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnexpectedResChangeTyToConstParamSugg {
span: __binding_0, applicability: __binding_1 } => {
let __code_20 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write a const parameter here")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_20, __binding_1,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
904#[suggestion(
905 "you might have meant to write a const parameter here",
906 code = "const ",
907 style = "verbose"
908)]
909pub(crate) struct UnexpectedResChangeTyToConstParamSugg {
910 #[primary_span]
911 pub span: Span,
912 #[applicability]
913 pub applicability: Applicability,
914}
915
916#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedMissingConstParameter {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnexpectedMissingConstParameter {
span: __binding_0,
snippet: __binding_1,
item_name: __binding_2,
item_location: __binding_3 } => {
let __code_21 =
[::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("item_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("item_location".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("you might have meant to introduce a const parameter `{$item_name}` on the {$item_location}")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_21, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
917#[suggestion(
918 "you might have meant to introduce a const parameter `{$item_name}` on the {$item_location}",
919 code = "{snippet}",
920 applicability = "machine-applicable",
921 style = "verbose"
922)]
923pub(crate) struct UnexpectedMissingConstParameter {
924 #[primary_span]
925 pub span: Span,
926 pub snippet: String,
927 pub item_name: String,
928 pub item_location: String,
929}
930
931#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedResChangeTyParamToConstParamSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnexpectedResChangeTyParamToConstParamSugg {
before: __binding_0, after: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_22 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
});
let __code_23 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": /* Type */"))
});
suggestions.push((__binding_0, __code_22));
suggestions.push((__binding_1, __code_23));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write a const parameter here")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
932#[multipart_suggestion(
933 "you might have meant to write a const parameter here",
934 applicability = "has-placeholders",
935 style = "verbose"
936)]
937pub(crate) struct UnexpectedResChangeTyParamToConstParamSugg {
938 #[suggestion_part(code = "const ")]
939 pub before: Span,
940 #[suggestion_part(code = ": /* Type */")]
941 pub after: Span,
942}
943
944#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedResUseAtOpInSlicePatWithRangeSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnexpectedResUseAtOpInSlicePatWithRangeSugg {
span: __binding_0, ident: __binding_1, snippet: __binding_2
} => {
let __code_24 =
[::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("ident".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("if you meant to collect the rest of the slice in `{$ident}`, use the at operator")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_24, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
945#[suggestion(
946 "if you meant to collect the rest of the slice in `{$ident}`, use the at operator",
947 code = "{snippet}",
948 applicability = "maybe-incorrect",
949 style = "verbose"
950)]
951pub(crate) struct UnexpectedResUseAtOpInSlicePatWithRangeSugg {
952 #[primary_span]
953 pub span: Span,
954 pub ident: Ident,
955 pub snippet: String,
956}
957
958#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ExternCrateLoadingMacroNotAtCrateRoot {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExternCrateLoadingMacroNotAtCrateRoot { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `extern crate` loading macros must be at the crate root")));
diag.code(E0468);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
959#[diag("an `extern crate` loading macros must be at the crate root", code = E0468)]
960pub(crate) struct ExternCrateLoadingMacroNotAtCrateRoot {
961 #[primary_span]
962 pub(crate) span: Span,
963}
964
965#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ExternCrateSelfRequiresRenaming {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExternCrateSelfRequiresRenaming { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern crate self;` requires renaming")));
let __code_25 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("extern crate self as name;"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rename the `self` crate to be able to import it")),
__code_25, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
966#[diag("`extern crate self;` requires renaming")]
967pub(crate) struct ExternCrateSelfRequiresRenaming {
968 #[primary_span]
969 #[suggestion(
970 "rename the `self` crate to be able to import it",
971 code = "extern crate self as name;",
972 applicability = "has-placeholders"
973 )]
974 pub(crate) span: Span,
975}
976
977#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MacroUseNameAlreadyInUse {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroUseNameAlreadyInUse {
span: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` is already in scope")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
978#[diag("`{$name}` is already in scope")]
979#[note("macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)")]
980pub(crate) struct MacroUseNameAlreadyInUse {
981 #[primary_span]
982 pub(crate) span: Span,
983 pub(crate) name: Symbol,
984}
985
986#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ImportedMacroNotFound {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ImportedMacroNotFound { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("imported macro not found")));
diag.code(E0469);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
987#[diag("imported macro not found", code = E0469)]
988pub(crate) struct ImportedMacroNotFound {
989 #[primary_span]
990 pub(crate) span: Span,
991}
992
993#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MacroExternDeprecated {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroExternDeprecated {
span: __binding_0, inner_attribute: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[macro_escape]` is a deprecated synonym for `#[macro_use]`")));
;
diag.span(__binding_0);
if __binding_1 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try an outer attribute: `#[macro_use]`")));
}
diag
}
}
}
}
};Diagnostic)]
994#[diag("`#[macro_escape]` is a deprecated synonym for `#[macro_use]`")]
995pub(crate) struct MacroExternDeprecated {
996 #[primary_span]
997 pub(crate) span: Span,
998 #[help("try an outer attribute: `#[macro_use]`")]
999 pub inner_attribute: bool,
1000}
1001
1002#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ArgumentsMacroUseNotAllowed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ArgumentsMacroUseNotAllowed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("arguments to `macro_use` are not allowed here")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1003#[diag("arguments to `macro_use` are not allowed here")]
1004pub(crate) struct ArgumentsMacroUseNotAllowed {
1005 #[primary_span]
1006 pub(crate) span: Span,
1007}
1008
1009#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnnamedImportSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnnamedImportSugg { span: __binding_0, ident: __binding_1 }
=> {
let mut suggestions = Vec::new();
let __code_26 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} as name",
__binding_1))
});
suggestions.push((__binding_0, __code_26));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try renaming it with a name")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1010#[multipart_suggestion(
1011 "try renaming it with a name",
1012 applicability = "maybe-incorrect",
1013 style = "verbose"
1014)]
1015pub(crate) struct UnnamedImportSugg {
1016 #[suggestion_part(code = "{ident} as name")]
1017 pub(crate) span: Span,
1018 pub(crate) ident: Ident,
1019}
1020
1021#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnnamedImport {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnnamedImport { span: __binding_0, sugg: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("imports need to be explicitly named")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1022#[diag("imports need to be explicitly named")]
1023pub(crate) struct UnnamedImport {
1024 #[primary_span]
1025 pub(crate) span: Span,
1026 #[subdiagnostic]
1027 pub(crate) sugg: UnnamedImportSugg,
1028}
1029
1030#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MacroExpandedExternCrateCannotShadowExternArguments {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroExpandedExternCrateCannotShadowExternArguments {
span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro-expanded `extern crate` items cannot shadow names passed with `--extern`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1031#[diag("macro-expanded `extern crate` items cannot shadow names passed with `--extern`")]
1032pub(crate) struct MacroExpandedExternCrateCannotShadowExternArguments {
1033 #[primary_span]
1034 pub(crate) span: Span,
1035}
1036
1037#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ElidedAnonymousLifetimeReportError {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ElidedAnonymousLifetimeReportError {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`&` without an explicit lifetime name cannot be used here")));
diag.code(E0637);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit lifetime name needed here")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1038#[diag("`&` without an explicit lifetime name cannot be used here", code = E0637)]
1039pub(crate) struct ElidedAnonymousLifetimeReportError {
1040 #[primary_span]
1041 #[label("explicit lifetime name needed here")]
1042 pub(crate) span: Span,
1043 #[subdiagnostic]
1044 pub(crate) suggestion: Option<ElidedAnonymousLifetimeReportErrorSuggestion>,
1045}
1046
1047#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
LendingIteratorReportError {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LendingIteratorReportError {
lifetime: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can't create an `Iterator` that borrows each `Item` from itself, but you can instead create a new type that borrows your existing type and implement `Iterator` for that new type")));
diag
}
}
}
}
};Diagnostic)]
1048#[diag(
1049 "associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type"
1050)]
1051pub(crate) struct LendingIteratorReportError {
1052 #[primary_span]
1053 pub(crate) lifetime: Span,
1054 #[note(
1055 "you can't create an `Iterator` that borrows each `Item` from itself, but you can instead create a new type that borrows your existing type and implement `Iterator` for that new type"
1056 )]
1057 pub(crate) ty: Span,
1058}
1059
1060#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AnonymousLifetimeNonGatReportError {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AnonymousLifetimeNonGatReportError {
lifetime: __binding_0, decl: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing lifetime in associated type")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this lifetime must come from the implemented type")));
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in the trait the associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type")));
diag
}
}
}
}
};Diagnostic)]
1061#[diag("missing lifetime in associated type")]
1062pub(crate) struct AnonymousLifetimeNonGatReportError {
1063 #[primary_span]
1064 #[label("this lifetime must come from the implemented type")]
1065 pub(crate) lifetime: Span,
1066 #[note(
1067 "in the trait the associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type"
1068 )]
1069 pub(crate) decl: MultiSpan,
1070}
1071
1072#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ElidedAnonymousLifetimeReportErrorSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ElidedAnonymousLifetimeReportErrorSuggestion {
lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_27 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("for<\'a> "))
});
let __code_28 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\'a "))
});
suggestions.push((__binding_0, __code_27));
suggestions.push((__binding_1, __code_28));
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 higher-ranked lifetime here")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1073#[multipart_suggestion(
1074 "consider introducing a higher-ranked lifetime here",
1075 applicability = "machine-applicable"
1076)]
1077pub(crate) struct ElidedAnonymousLifetimeReportErrorSuggestion {
1078 #[suggestion_part(code = "for<'a> ")]
1079 pub(crate) lo: Span,
1080 #[suggestion_part(code = "'a ")]
1081 pub(crate) hi: Span,
1082}
1083
1084#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ExplicitAnonymousLifetimeReportError {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExplicitAnonymousLifetimeReportError { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`'_` cannot be used here")));
diag.code(E0637);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`'_` is a reserved lifetime name")));
diag
}
}
}
}
};Diagnostic)]
1085#[diag("`'_` cannot be used here", code = E0637)]
1086pub(crate) struct ExplicitAnonymousLifetimeReportError {
1087 #[primary_span]
1088 #[label("`'_` is a reserved lifetime name")]
1089 pub(crate) span: Span,
1090}
1091
1092#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ImplicitElidedLifetimeNotAllowedHere {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ImplicitElidedLifetimeNotAllowedHere {
span: __binding_0, subdiag: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implicit elided lifetime not allowed here")));
diag.code(E0726);
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1093#[diag("implicit elided lifetime not allowed here", code = E0726)]
1094pub(crate) struct ImplicitElidedLifetimeNotAllowedHere {
1095 #[primary_span]
1096 pub(crate) span: Span,
1097 #[subdiagnostic]
1098 pub(crate) subdiag: ElidedLifetimeInPathSubdiag,
1099}
1100
1101#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnderscoreLifetimeIsReserved {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnderscoreLifetimeIsReserved { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`'_` cannot be used here")));
diag.code(E0637);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use another lifetime specifier")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`'_` is a reserved lifetime name")));
diag
}
}
}
}
};Diagnostic)]
1102#[diag("`'_` cannot be used here", code = E0637)]
1103#[help("use another lifetime specifier")]
1104pub(crate) struct UnderscoreLifetimeIsReserved {
1105 #[primary_span]
1106 #[label("`'_` is a reserved lifetime name")]
1107 pub(crate) span: Span,
1108}
1109
1110#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
StaticLifetimeIsReserved {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
StaticLifetimeIsReserved {
span: __binding_0, lifetime: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid lifetime parameter name: `{$lifetime}`")));
diag.code(E0262);
;
diag.arg("lifetime", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("'static is a reserved lifetime name")));
diag
}
}
}
}
};Diagnostic)]
1111#[diag("invalid lifetime parameter name: `{$lifetime}`", code = E0262)]
1112pub(crate) struct StaticLifetimeIsReserved {
1113 #[primary_span]
1114 #[label("'static is a reserved lifetime name")]
1115 pub(crate) span: Span,
1116 pub(crate) lifetime: Ident,
1117}
1118
1119#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
VariableIsNotBoundInAllPatterns {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
VariableIsNotBoundInAllPatterns {
multispan: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable `{$name}` is not bound in all patterns")));
diag.code(E0408);
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1120#[diag("variable `{$name}` is not bound in all patterns", code = E0408)]
1121pub(crate) struct VariableIsNotBoundInAllPatterns {
1122 #[primary_span]
1123 pub(crate) multispan: MultiSpan,
1124 pub(crate) name: Ident,
1125}
1126
1127#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for PatternDoesntBindName {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
PatternDoesntBindName { 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("pattern doesn't bind `{$name}`")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic, #[automatically_derived]impl ::core::fmt::Debug for PatternDoesntBindName {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"PatternDoesntBindName span name", &self.span, &&self.name)
}
}Debug, #[automatically_derived]impl ::core::clone::Clone for PatternDoesntBindName {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
PatternDoesntBindName {
span: ::core::clone::Clone::clone(&self.span),
name: ::core::clone::Clone::clone(&self.name),
}
}
}Clone)]
1128#[label("pattern doesn't bind `{$name}`")]
1129pub(crate) struct PatternDoesntBindName {
1130 #[primary_span]
1131 pub(crate) span: Span,
1132 pub(crate) name: Ident,
1133}
1134
1135#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for VariableNotInAllPatterns {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
VariableNotInAllPatterns { 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("variable not in all patterns")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic, #[automatically_derived]impl ::core::fmt::Debug for VariableNotInAllPatterns {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"VariableNotInAllPatterns span", &&self.span)
}
}Debug, #[automatically_derived]impl ::core::clone::Clone for VariableNotInAllPatterns
{
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
VariableNotInAllPatterns {
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone)]
1136#[label("variable not in all patterns")]
1137pub(crate) struct VariableNotInAllPatterns {
1138 #[primary_span]
1139 pub(crate) span: Span,
1140}
1141
1142#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for PatternBindingTypo {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
PatternBindingTypo { spans: __binding_0, typo: __binding_1 }
=> {
let mut suggestions = Vec::new();
let __code_29 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_29.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("typo".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("you might have meant to use the similarly named previously used binding `{$typo}`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1143#[multipart_suggestion(
1144 "you might have meant to use the similarly named previously used binding `{$typo}`",
1145 applicability = "maybe-incorrect",
1146 style = "verbose"
1147)]
1148pub(crate) struct PatternBindingTypo {
1149 #[suggestion_part(code = "{typo}")]
1150 pub(crate) spans: Vec<Span>,
1151 pub(crate) typo: Symbol,
1152}
1153
1154#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NameDefinedMultipleTime {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NameDefinedMultipleTime {
span: __binding_0,
name: __binding_1,
descr: __binding_2,
container: __binding_3,
label: __binding_4,
old_binding_label: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the name `{$name}` is defined multiple times")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` must be defined only once in the {$descr} namespace of this {$container}")));
;
diag.arg("name", __binding_1);
diag.arg("descr", __binding_2);
diag.arg("container", __binding_3);
diag.span(__binding_0);
diag.subdiagnostic(__binding_4);
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag
}
}
}
}
};Diagnostic)]
1155#[diag("the name `{$name}` is defined multiple times")]
1156#[note("`{$name}` must be defined only once in the {$descr} namespace of this {$container}")]
1157pub(crate) struct NameDefinedMultipleTime {
1158 #[primary_span]
1159 pub(crate) span: Span,
1160 pub(crate) name: Symbol,
1161 pub(crate) descr: &'static str,
1162 pub(crate) container: &'static str,
1163 #[subdiagnostic]
1164 pub(crate) label: NameDefinedMultipleTimeLabel,
1165 #[subdiagnostic]
1166 pub(crate) old_binding_label: Option<NameDefinedMultipleTimeOldBindingLabel>,
1167}
1168
1169#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NameDefinedMultipleTimeLabel {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
NameDefinedMultipleTimeLabel::Reimported {
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}` reimported here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
NameDefinedMultipleTimeLabel::Redefined {
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}` redefined here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1170pub(crate) enum NameDefinedMultipleTimeLabel {
1171 #[label("`{$name}` reimported here")]
1172 Reimported {
1173 #[primary_span]
1174 span: Span,
1175 name: Symbol,
1176 },
1177 #[label("`{$name}` redefined here")]
1178 Redefined {
1179 #[primary_span]
1180 span: Span,
1181 name: Symbol,
1182 },
1183}
1184
1185#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
NameDefinedMultipleTimeOldBindingLabel {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
NameDefinedMultipleTimeOldBindingLabel::Import {
span: __binding_0, old_kind: __binding_1, name: __binding_2
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("old_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("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("previous import of the {$old_kind} `{$name}` here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
NameDefinedMultipleTimeOldBindingLabel::Definition {
span: __binding_0, old_kind: __binding_1, name: __binding_2
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("old_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("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("previous definition of the {$old_kind} `{$name}` here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1186pub(crate) enum NameDefinedMultipleTimeOldBindingLabel {
1187 #[label("previous import of the {$old_kind} `{$name}` here")]
1188 Import {
1189 #[primary_span]
1190 span: Span,
1191 old_kind: &'static str,
1192 name: Symbol,
1193 },
1194 #[label("previous definition of the {$old_kind} `{$name}` here")]
1195 Definition {
1196 #[primary_span]
1197 span: Span,
1198 old_kind: &'static str,
1199 name: Symbol,
1200 },
1201}
1202
1203#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for IsPrivate<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IsPrivate {
span: __binding_0,
ident_descr: __binding_1,
ident: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$ident_descr} `{$ident}` is private")));
diag.code(E0603);
;
diag.arg("ident_descr", __binding_1);
diag.arg("ident", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("private {$ident_descr}")));
diag
}
}
}
}
};Diagnostic)]
1204#[diag("{$ident_descr} `{$ident}` is private", code = E0603)]
1205pub(crate) struct IsPrivate<'a> {
1206 #[primary_span]
1207 #[label("private {$ident_descr}")]
1208 pub(crate) span: Span,
1209 pub(crate) ident_descr: &'a str,
1210 pub(crate) ident: Ident,
1211}
1212
1213#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
GenericArgumentsInMacroPath {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
GenericArgumentsInMacroPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic arguments in macro path")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1214#[diag("generic arguments in macro path")]
1215pub(crate) struct GenericArgumentsInMacroPath {
1216 #[primary_span]
1217 pub(crate) span: Span,
1218}
1219
1220#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AttributesStartingWithRustcAreReserved {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AttributesStartingWithRustcAreReserved { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes starting with `rustc` are reserved for use by the `rustc` compiler")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1221#[diag("attributes starting with `rustc` are reserved for use by the `rustc` compiler")]
1222pub(crate) struct AttributesStartingWithRustcAreReserved {
1223 #[primary_span]
1224 pub(crate) span: Span,
1225}
1226
1227#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AttributesContainingRustcAreReserved {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AttributesContainingRustcAreReserved { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes containing a segment starting with `rustc` are reserved for use by the `rustc` compiler")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1228#[diag(
1229 "attributes containing a segment starting with `rustc` are reserved for use by the `rustc` compiler"
1230)]
1231pub(crate) struct AttributesContainingRustcAreReserved {
1232 #[primary_span]
1233 pub(crate) span: Span,
1234}
1235
1236#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotUseThroughAnImport {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotUseThroughAnImport {
span: __binding_0,
article: __binding_1,
descr: __binding_2,
binding_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use {$article} {$descr} through an import")));
;
diag.arg("article", __binding_1);
diag.arg("descr", __binding_2);
diag.span(__binding_0);
if let Some(__binding_3) = __binding_3 {
diag.span_note(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$descr} imported here")));
}
diag
}
}
}
}
};Diagnostic)]
1237#[diag("cannot use {$article} {$descr} through an import")]
1238pub(crate) struct CannotUseThroughAnImport {
1239 #[primary_span]
1240 pub(crate) span: Span,
1241 pub(crate) article: &'static str,
1242 pub(crate) descr: &'static str,
1243 #[note("the {$descr} imported here")]
1244 pub(crate) binding_span: Option<Span>,
1245}
1246
1247#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NameReservedInAttributeNamespace {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NameReservedInAttributeNamespace {
span: __binding_0, ident: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("name `{$ident}` is reserved in attribute namespace")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1248#[diag("name `{$ident}` is reserved in attribute namespace")]
1249pub(crate) struct NameReservedInAttributeNamespace {
1250 #[primary_span]
1251 pub(crate) span: Span,
1252 pub(crate) ident: Symbol,
1253}
1254
1255#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotFindBuiltinMacroWithName {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CannotFindBuiltinMacroWithName {
span: __binding_0, ident: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot find a built-in macro with name `{$ident}`")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1256#[diag("cannot find a built-in macro with name `{$ident}`")]
1257pub(crate) struct CannotFindBuiltinMacroWithName {
1258 #[primary_span]
1259 pub(crate) span: Span,
1260 pub(crate) ident: Ident,
1261}
1262
1263#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for DefinedHere {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
DefinedHere::SimilarlyNamed {
span: __binding_0,
candidate_descr: __binding_1,
candidate: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("candidate_descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("candidate".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("similarly named {$candidate_descr} `{$candidate}` defined here")),
&sub_args);
diag.span_note(__binding_0, __message);
}
DefinedHere::SingleItem {
span: __binding_0,
candidate_descr: __binding_1,
candidate: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("candidate_descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("candidate".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("{$candidate_descr} `{$candidate}` defined here")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1264pub(crate) enum DefinedHere {
1265 #[note("similarly named {$candidate_descr} `{$candidate}` defined here")]
1266 SimilarlyNamed {
1267 #[primary_span]
1268 span: Span,
1269 candidate_descr: &'static str,
1270 candidate: Symbol,
1271 },
1272 #[note("{$candidate_descr} `{$candidate}` defined here")]
1273 SingleItem {
1274 #[primary_span]
1275 span: Span,
1276 candidate_descr: &'static str,
1277 candidate: Symbol,
1278 },
1279}
1280
1281#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OuterIdentIsNotPubliclyReexported
{
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
OuterIdentIsNotPubliclyReexported {
span: __binding_0,
outer_ident_descr: __binding_1,
outer_ident: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("outer_ident_descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("outer_ident".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("{$outer_ident_descr} `{$outer_ident}` is not publicly re-exported")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1282#[label("{$outer_ident_descr} `{$outer_ident}` is not publicly re-exported")]
1283pub(crate) struct OuterIdentIsNotPubliclyReexported {
1284 #[primary_span]
1285 pub(crate) span: Span,
1286 pub(crate) outer_ident_descr: &'static str,
1287 pub(crate) outer_ident: Ident,
1288}
1289
1290#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ConstructorPrivateIfAnyFieldPrivate {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ConstructorPrivateIfAnyFieldPrivate { 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("a constructor is private if any of the fields is private")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1291#[label("a constructor is private if any of the fields is private")]
1292pub(crate) struct ConstructorPrivateIfAnyFieldPrivate {
1293 #[primary_span]
1294 pub(crate) span: Span,
1295}
1296
1297#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderMakingTheFieldPublic {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ConsiderMakingTheFieldPublic {
spans: __binding_0, number_of_fields: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_30 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub "))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_30.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("number_of_fields".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("{ $number_of_fields ->\n [one] consider making the field publicly accessible\n *[other] consider making the fields publicly accessible\n }")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1298#[multipart_suggestion(
1299 "{ $number_of_fields ->
1300 [one] consider making the field publicly accessible
1301 *[other] consider making the fields publicly accessible
1302 }",
1303 applicability = "maybe-incorrect",
1304 style = "verbose"
1305)]
1306pub(crate) struct ConsiderMakingTheFieldPublic {
1307 #[suggestion_part(code = "pub ")]
1308 pub(crate) spans: Vec<Span>,
1309 pub(crate) number_of_fields: usize,
1310}
1311
1312#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImportIdent {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ImportIdent::ThroughReExport {
span: __binding_0, ident: __binding_1, path: __binding_2 }
=> {
let __code_31 =
[::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("ident".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("import `{$ident}` through the re-export")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_31, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
ImportIdent::Directly {
span: __binding_0, ident: __binding_1, path: __binding_2 }
=> {
let __code_32 =
[::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("ident".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("import `{$ident}` directly")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_32, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1313pub(crate) enum ImportIdent {
1314 #[suggestion(
1315 "import `{$ident}` through the re-export",
1316 code = "{path}",
1317 applicability = "machine-applicable",
1318 style = "verbose"
1319 )]
1320 ThroughReExport {
1321 #[primary_span]
1322 span: Span,
1323 ident: Ident,
1324 path: String,
1325 },
1326 #[suggestion(
1327 "import `{$ident}` directly",
1328 code = "{path}",
1329 applicability = "machine-applicable",
1330 style = "verbose"
1331 )]
1332 Directly {
1333 #[primary_span]
1334 span: Span,
1335 ident: Ident,
1336 path: String,
1337 },
1338}
1339
1340#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
NoteAndRefersToTheItemDefinedHere<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
NoteAndRefersToTheItemDefinedHere {
span: __binding_0,
binding_descr: __binding_1,
binding_name: __binding_2,
first: __binding_3,
dots: __binding_4 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("binding_descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("binding_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("first".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("dots".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("{$first ->\n [true] {$dots ->\n [true] the {$binding_descr} `{$binding_name}` is defined here...\n *[false] the {$binding_descr} `{$binding_name}` is defined here\n }\n *[false] {$dots ->\n [true] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here...\n *[false] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here\n }\n }")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1341#[note(
1342 "{$first ->
1343 [true] {$dots ->
1344 [true] the {$binding_descr} `{$binding_name}` is defined here...
1345 *[false] the {$binding_descr} `{$binding_name}` is defined here
1346 }
1347 *[false] {$dots ->
1348 [true] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here...
1349 *[false] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here
1350 }
1351 }"
1352)]
1353pub(crate) struct NoteAndRefersToTheItemDefinedHere<'a> {
1354 #[primary_span]
1355 pub(crate) span: MultiSpan,
1356 pub(crate) binding_descr: &'a str,
1357 pub(crate) binding_name: Ident,
1358 pub(crate) first: bool,
1359 pub(crate) dots: bool,
1360}
1361
1362#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RemoveUnnecessaryImport {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
RemoveUnnecessaryImport { span: __binding_0 } => {
let __code_33 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove unnecessary import")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_33, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1363#[suggestion("remove unnecessary import", code = "", applicability = "maybe-incorrect")]
1364pub(crate) struct RemoveUnnecessaryImport {
1365 #[primary_span]
1366 pub(crate) span: Span,
1367}
1368
1369#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ToolOnlyRemoveUnnecessaryImport {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ToolOnlyRemoveUnnecessaryImport { span: __binding_0 } => {
let __code_34 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove unnecessary import")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_34, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
}
}
}
};Subdiagnostic)]
1370#[suggestion(
1371 "remove unnecessary import",
1372 code = "",
1373 applicability = "maybe-incorrect",
1374 style = "tool-only"
1375)]
1376pub(crate) struct ToolOnlyRemoveUnnecessaryImport {
1377 #[primary_span]
1378 pub(crate) span: Span,
1379}
1380
1381#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
IdentImporterHereButItIsDesc<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
IdentImporterHereButItIsDesc {
span: __binding_0,
imported_ident: __binding_1,
imported_ident_desc: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("imported_ident".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("imported_ident_desc".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("`{$imported_ident}` is imported here, but it is {$imported_ident_desc}")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1382#[note("`{$imported_ident}` is imported here, but it is {$imported_ident_desc}")]
1383pub(crate) struct IdentImporterHereButItIsDesc<'a> {
1384 #[primary_span]
1385 pub(crate) span: Span,
1386 pub(crate) imported_ident: Ident,
1387 pub(crate) imported_ident_desc: &'a str,
1388}
1389
1390#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for IdentInScopeButItIsDesc<'a> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
IdentInScopeButItIsDesc {
imported_ident: __binding_0,
imported_ident_desc: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("imported_ident".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("imported_ident_desc".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("`{$imported_ident}` is in scope, but it is {$imported_ident_desc}")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
1391#[note("`{$imported_ident}` is in scope, but it is {$imported_ident_desc}")]
1392pub(crate) struct IdentInScopeButItIsDesc<'a> {
1393 pub(crate) imported_ident: Ident,
1394 pub(crate) imported_ident_desc: &'a str,
1395}
1396
1397pub(crate) struct FoundItemConfigureOut {
1398 pub(crate) span: Span,
1399 pub(crate) item_was: ItemWas,
1400}
1401
1402pub(crate) enum ItemWas {
1403 BehindFeature { feature: Symbol, span: Span },
1404 CfgOut { span: Span },
1405}
1406
1407impl Subdiagnostic for FoundItemConfigureOut {
1408 fn add_to_diag(self, diag: &mut Diag<'_>) {
1409 let mut multispan: MultiSpan = self.span.into();
1410 match self.item_was {
1411 ItemWas::BehindFeature { feature, span } => {
1412 let value = feature.into_diag_arg(&mut None);
1413 let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the item is gated behind the `{$feature}` feature"))msg!("the item is gated behind the `{$feature}` feature")
1414 .arg("feature", value)
1415 .format();
1416 multispan.push_span_label(span, msg);
1417 }
1418 ItemWas::CfgOut { span } => {
1419 multispan.push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the item is gated here"))msg!("the item is gated here"));
1420 }
1421 }
1422 diag.span_note(multispan, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found an item that was configured out"))msg!("found an item that was configured out"));
1423 }
1424}
1425
1426#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TraitImplMismatch {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TraitImplMismatch {
span: __binding_0,
name: __binding_1,
kind: __binding_2,
trait_path: __binding_3,
trait_item_span: __binding_4,
trait_span: __binding_5,
impl_span: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item `{$name}` is an associated {$kind}, which doesn't match its trait `{$trait_path}`")));
;
diag.arg("name", __binding_1);
diag.arg("kind", __binding_2);
diag.arg("trait_path", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("does not match trait")));
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item in trait")));
diag.span_context(__binding_5);
diag.span_context(__binding_6);
diag
}
}
}
}
};Diagnostic)]
1427#[diag("item `{$name}` is an associated {$kind}, which doesn't match its trait `{$trait_path}`")]
1428pub(crate) struct TraitImplMismatch {
1429 #[primary_span]
1430 #[label("does not match trait")]
1431 pub(crate) span: Span,
1432 pub(crate) name: Ident,
1433 pub(crate) kind: &'static str,
1434 pub(crate) trait_path: String,
1435 #[label("item in trait")]
1436 pub(crate) trait_item_span: Span,
1437 #[context]
1438 pub(crate) trait_span: Span,
1439 #[context]
1440 pub(crate) impl_span: Span,
1441}
1442
1443#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for LegacyDeriveHelpers
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LegacyDeriveHelpers { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("derive helper attribute is used before it is introduced")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the attribute is introduced here")));
diag
}
}
}
}
};Diagnostic)]
1444#[diag("derive helper attribute is used before it is introduced")]
1445pub(crate) struct LegacyDeriveHelpers {
1446 #[label("the attribute is introduced here")]
1447 pub span: Span,
1448}
1449
1450#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnusedExternCrate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedExternCrate {
span: __binding_0, removal_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused extern crate")));
let __code_35 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused")));
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the unused `extern crate`")),
__code_35, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1451#[diag("unused extern crate")]
1452pub(crate) struct UnusedExternCrate {
1453 #[label("unused")]
1454 pub span: Span,
1455 #[suggestion(
1456 "remove the unused `extern crate`",
1457 code = "",
1458 applicability = "machine-applicable",
1459 style = "verbose"
1460 )]
1461 pub removal_span: Span,
1462}
1463
1464#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ReexportPrivateDependency {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReexportPrivateDependency {
name: __binding_0, kind: __binding_1, krate: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind} `{$name}` from private dependency '{$krate}' is re-exported")));
;
diag.arg("name", __binding_0);
diag.arg("kind", __binding_1);
diag.arg("krate", __binding_2);
diag
}
}
}
}
};Diagnostic)]
1465#[diag("{$kind} `{$name}` from private dependency '{$krate}' is re-exported")]
1466pub(crate) struct ReexportPrivateDependency {
1467 pub name: Symbol,
1468 pub kind: &'static str,
1469 pub krate: Symbol,
1470}
1471
1472#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnusedLabel {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedLabel => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused label")));
;
diag
}
}
}
}
};Diagnostic)]
1473#[diag("unused label")]
1474pub(crate) struct UnusedLabel;
1475
1476#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnusedMacroUse {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedMacroUse => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused `#[macro_use]` import")));
;
diag
}
}
}
}
};Diagnostic)]
1477#[diag("unused `#[macro_use]` import")]
1478pub(crate) struct UnusedMacroUse;
1479
1480#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MacroUseDeprecated {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroUseDeprecated => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("applying the `#[macro_use]` attribute to an `extern crate` item is deprecated")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove it and import macros at use sites with a `use` item instead")));
;
diag
}
}
}
}
};Diagnostic)]
1481#[diag("applying the `#[macro_use]` attribute to an `extern crate` item is deprecated")]
1482#[help("remove it and import macros at use sites with a `use` item instead")]
1483pub(crate) struct MacroUseDeprecated;
1484
1485#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MacroIsPrivate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroIsPrivate { ident: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro `{$ident}` is private")));
;
diag.arg("ident", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1486#[diag("macro `{$ident}` is private")]
1487pub(crate) struct MacroIsPrivate {
1488 pub ident: Ident,
1489}
1490
1491#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnusedMacroDefinition {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedMacroDefinition {
name: __binding_0,
unannotated_mod: __binding_1,
annotated_mod: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused macro definition: `{$name}`")));
let __code_36 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#[macro_use]\n"))
})].into_iter();
;
diag.arg("name", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider annotating the enclosing module with `#[macro_use]`")),
__code_36, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the macro is exported by its enclosing module")));
}
diag
}
}
}
}
};Diagnostic)]
1492#[diag("unused macro definition: `{$name}`")]
1493pub(crate) struct UnusedMacroDefinition {
1494 pub name: Symbol,
1495 #[suggestion(
1496 "consider annotating the enclosing module with `#[macro_use]`",
1497 code = "#[macro_use]\n",
1498 applicability = "machine-applicable"
1499 )]
1500 pub unannotated_mod: Option<Span>,
1501 #[label("the macro is exported by its enclosing module")]
1502 pub annotated_mod: Option<Span>,
1503}
1504
1505#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MacroRuleNeverUsed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MacroRuleNeverUsed { n: __binding_0, name: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rule #{$n} of macro `{$name}` is never used")));
;
diag.arg("n", __binding_0);
diag.arg("name", __binding_1);
diag
}
}
}
}
};Diagnostic)]
1506#[diag("rule #{$n} of macro `{$name}` is never used")]
1507pub(crate) struct MacroRuleNeverUsed {
1508 pub n: usize,
1509 pub name: Symbol,
1510}
1511
1512#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ExternCrateNotIdiomatic {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExternCrateNotIdiomatic {
span: __binding_0, code: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern crate` is not idiomatic in the new edition")));
let __code_37 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert it to a `use`")),
__code_37, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1513#[diag("`extern crate` is not idiomatic in the new edition")]
1514pub(crate) struct ExternCrateNotIdiomatic {
1515 #[suggestion(
1516 "convert it to a `use`",
1517 style = "verbose",
1518 code = "{code}",
1519 applicability = "machine-applicable"
1520 )]
1521 pub span: Span,
1522 pub code: &'static str,
1523}
1524
1525#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for OutOfScopeMacroCalls
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OutOfScopeMacroCalls {
span: __binding_0, path: __binding_1, location: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot find macro `{$path}` in the current scope when looking from {$location}")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("import `macro_rules` with `use` to make it callable above its definition")));
;
diag.arg("path", __binding_1);
diag.arg("location", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not found from {$location}")));
diag
}
}
}
}
};Diagnostic)]
1526#[diag("cannot find macro `{$path}` in the current scope when looking from {$location}")]
1527#[help("import `macro_rules` with `use` to make it callable above its definition")]
1528pub(crate) struct OutOfScopeMacroCalls {
1529 #[label("not found from {$location}")]
1530 pub span: Span,
1531 pub path: String,
1532 pub location: String,
1533}
1534
1535#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RedundantImportVisibility {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RedundantImportVisibility {
span: __binding_0,
help: __binding_1,
import_vis: __binding_2,
max_vis: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("glob import doesn't reexport anything with visibility `{$import_vis}` because no imported item is public enough")));
;
diag.arg("import_vis", __binding_2);
diag.arg("max_vis", __binding_3);
diag.span_note(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the most public imported item is `{$max_vis}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("reduce the glob import's visibility or increase visibility of imported items")));
diag
}
}
}
}
};Diagnostic)]
1536#[diag(
1537 "glob import doesn't reexport anything with visibility `{$import_vis}` because no imported item is public enough"
1538)]
1539pub(crate) struct RedundantImportVisibility {
1540 #[note("the most public imported item is `{$max_vis}`")]
1541 pub span: Span,
1542 #[help("reduce the glob import's visibility or increase visibility of imported items")]
1543 pub help: (),
1544 pub import_vis: String,
1545 pub max_vis: String,
1546}
1547
1548pub(crate) struct Ambiguity {
1550 pub ident: Ident,
1551 pub ambig_vis: Option<String>,
1552 pub kind: &'static str,
1553 pub help: Option<&'static [&'static str]>,
1554 pub b1_note: Spanned<String>,
1555 pub b1_help_msgs: Vec<String>,
1556 pub b2_note: Spanned<String>,
1557 pub b2_help_msgs: Vec<String>,
1558 pub is_error: bool,
1560}
1561
1562impl<'a> Diagnostic<'a> for Ambiguity {
1563 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> {
1564 let Self {
1565 ident,
1566 ambig_vis,
1567 kind,
1568 help,
1569 b1_note,
1570 b1_help_msgs,
1571 b2_note,
1572 b2_help_msgs,
1573 is_error,
1574 } = self;
1575
1576 let mut diag = Diag::new(dcx, level, "").with_span(ident.span);
1577 if is_error {
1578 diag.code(E0659);
1579 }
1580 if let Some(ambig_vis) = ambig_vis {
1581 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ambiguous import visibility: {0}",
ambig_vis))
})format!("ambiguous import visibility: {ambig_vis}"));
1582 } else {
1583 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}` is ambiguous", ident))
})format!("`{}` is ambiguous", ident));
1584 diag.span_label(ident.span, "ambiguous name");
1585 }
1586 diag.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ambiguous because of {0}", kind))
})format!("ambiguous because of {}", kind));
1587 diag.span_note(b1_note.span, b1_note.node);
1588 if let Some(help) = help {
1589 for help in help {
1590 diag.help(*help);
1591 }
1592 }
1593 for help_msg in b1_help_msgs {
1594 diag.help(help_msg);
1595 }
1596 diag.span_note(b2_note.span, b2_note.node);
1597 for help_msg in b2_help_msgs {
1598 diag.help(help_msg);
1599 }
1600 diag
1601 }
1602}
1603
1604#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnusedLifetime {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedLifetime {
deletion_span: __binding_0, ident: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameter `{$ident}` never used")));
let __code_38 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("ident", __binding_1);
if let Some(__binding_0) = __binding_0 {
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("elide the unused lifetime")),
__code_38, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
1605#[diag("lifetime parameter `{$ident}` never used")]
1606pub(crate) struct UnusedLifetime {
1607 #[suggestion("elide the unused lifetime", code = "", applicability = "machine-applicable")]
1608 pub deletion_span: Option<Span>,
1609
1610 pub ident: Ident,
1611}
1612
1613#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AmbiguousGlobReexports {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AmbiguousGlobReexports {
first_reexport: __binding_0,
duplicate_reexport: __binding_1,
name: __binding_2,
namespace: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous glob re-exports")));
;
diag.arg("name", __binding_2);
diag.arg("namespace", __binding_3);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the name `{$name}` in the {$namespace} namespace is first re-exported here")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("but the name `{$name}` in the {$namespace} namespace is also re-exported here")));
diag
}
}
}
}
};Diagnostic)]
1614#[diag("ambiguous glob re-exports")]
1615pub(crate) struct AmbiguousGlobReexports {
1616 #[label("the name `{$name}` in the {$namespace} namespace is first re-exported here")]
1617 pub first_reexport: Span,
1618 #[label("but the name `{$name}` in the {$namespace} namespace is also re-exported here")]
1619 pub duplicate_reexport: Span,
1620
1621 pub name: String,
1622 pub namespace: String,
1623}
1624
1625#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for HiddenGlobReexports
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
HiddenGlobReexports {
glob_reexport: __binding_0,
private_item: __binding_1,
name: __binding_2,
namespace: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("private item shadows public glob re-export")));
;
diag.arg("name", __binding_2);
diag.arg("namespace", __binding_3);
diag.span_note(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the name `{$name}` in the {$namespace} namespace is supposed to be publicly re-exported here")));
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("but the private item here shadows it")));
diag
}
}
}
}
};Diagnostic)]
1626#[diag("private item shadows public glob re-export")]
1627pub(crate) struct HiddenGlobReexports {
1628 #[note(
1629 "the name `{$name}` in the {$namespace} namespace is supposed to be publicly re-exported here"
1630 )]
1631 pub glob_reexport: Span,
1632 #[note("but the private item here shadows it")]
1633 pub private_item: Span,
1634
1635 pub name: String,
1636 pub namespace: String,
1637}
1638
1639#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for RedundantImport {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RedundantImport { subs: __binding_0, ident: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the item `{$ident}` is imported redundantly")));
;
diag.arg("ident", __binding_1);
for __binding_0 in __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
1640#[diag("the item `{$ident}` is imported redundantly")]
1641pub(crate) struct RedundantImport {
1642 #[subdiagnostic]
1643 pub subs: Vec<RedundantImportSub>,
1644 pub ident: Ident,
1645}
1646
1647#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RedundantImportSub {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
RedundantImportSub::ImportedHere {
span: __binding_0, ident: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("the item `{$ident}` is already imported here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
RedundantImportSub::DefinedHere {
span: __binding_0, ident: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("the item `{$ident}` is already defined here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
RedundantImportSub::ImportedPrelude {
span: __binding_0, ident: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("the item `{$ident}` is already imported by the extern prelude")),
&sub_args);
diag.span_label(__binding_0, __message);
}
RedundantImportSub::DefinedPrelude {
span: __binding_0, ident: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ident".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("the item `{$ident}` is already defined by the extern prelude")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1648pub(crate) enum RedundantImportSub {
1649 #[label("the item `{$ident}` is already imported here")]
1650 ImportedHere {
1651 #[primary_span]
1652 span: Span,
1653 ident: Ident,
1654 },
1655 #[label("the item `{$ident}` is already defined here")]
1656 DefinedHere {
1657 #[primary_span]
1658 span: Span,
1659 ident: Ident,
1660 },
1661 #[label("the item `{$ident}` is already imported by the extern prelude")]
1662 ImportedPrelude {
1663 #[primary_span]
1664 span: Span,
1665 ident: Ident,
1666 },
1667 #[label("the item `{$ident}` is already defined by the extern prelude")]
1668 DefinedPrelude {
1669 #[primary_span]
1670 span: Span,
1671 ident: Ident,
1672 },
1673}
1674
1675#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnusedQualifications
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedQualifications { removal_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary qualification")));
let __code_39 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the unnecessary path segments")),
__code_39, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1676#[diag("unnecessary qualification")]
1677pub(crate) struct UnusedQualifications {
1678 #[suggestion(
1679 "remove the unnecessary path segments",
1680 style = "verbose",
1681 code = "",
1682 applicability = "machine-applicable"
1683 )]
1684 pub removal_span: Span,
1685}
1686
1687#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for SingleUseLifetime {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SingleUseLifetime {
param_span: __binding_0,
use_span: __binding_1,
suggestion: __binding_2,
ident: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameter `{$ident}` only used once")));
;
diag.arg("ident", __binding_3);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this lifetime...")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...is used only here")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
1688#[diag("lifetime parameter `{$ident}` only used once")]
1689pub(crate) struct SingleUseLifetime {
1690 #[label("this lifetime...")]
1691 pub param_span: Span,
1692 #[label("...is used only here")]
1693 pub use_span: Span,
1694 #[subdiagnostic]
1695 pub suggestion: Option<SingleUseLifetimeSugg>,
1696
1697 pub ident: Ident,
1698}
1699
1700#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SingleUseLifetimeSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
SingleUseLifetimeSugg {
deletion_span: __binding_0,
use_span: __binding_1,
replace_lt: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_40 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_41 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
});
if let Some(__binding_0) = __binding_0 {
suggestions.push((__binding_0, __code_40));
}
suggestions.push((__binding_1, __code_41));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("elide the single-use lifetime")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1701#[multipart_suggestion("elide the single-use lifetime", applicability = "machine-applicable")]
1702pub(crate) struct SingleUseLifetimeSugg {
1703 #[suggestion_part(code = "")]
1704 pub deletion_span: Option<Span>,
1705 #[suggestion_part(code = "{replace_lt}")]
1706 pub use_span: Span,
1707
1708 pub replace_lt: String,
1709}
1710
1711#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AbsPathWithModule {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AbsPathWithModule { sugg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1712#[diag(
1713 "absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition"
1714)]
1715pub(crate) struct AbsPathWithModule {
1716 #[subdiagnostic]
1717 pub sugg: AbsPathWithModuleSugg,
1718}
1719
1720#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AbsPathWithModuleSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
AbsPathWithModuleSugg {
span: __binding_0,
applicability: __binding_1,
replacement: __binding_2 } => {
let __code_42 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `crate`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_42, __binding_1,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1721#[suggestion("use `crate`", code = "{replacement}")]
1722pub(crate) struct AbsPathWithModuleSugg {
1723 #[primary_span]
1724 pub span: Span,
1725 #[applicability]
1726 pub applicability: Applicability,
1727 pub replacement: String,
1728}
1729
1730#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ElidedLifetimesInPaths {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ElidedLifetimesInPaths { subdiag: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hidden lifetime parameters in types are deprecated")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1731#[diag("hidden lifetime parameters in types are deprecated")]
1732pub(crate) struct ElidedLifetimesInPaths {
1733 #[subdiagnostic]
1734 pub subdiag: rustc_errors::ElidedLifetimeInPathSubdiag,
1735}
1736
1737#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnusedImports {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedImports {
sugg: __binding_0,
test_module_span: __binding_1,
span_snippets: __binding_2,
num_snippets: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_snippets ->\n [one] unused import: {$span_snippets}\n *[other] unused imports: {$span_snippets}\n }")));
;
diag.arg("span_snippets", __binding_2);
diag.arg("num_snippets", __binding_3);
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
if let Some(__binding_1) = __binding_1 {
diag.span_help(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if this is a test module, consider adding a `#[cfg(test)]` to the containing module")));
}
diag
}
}
}
}
};Diagnostic)]
1738#[diag(
1739 "{$num_snippets ->
1740 [one] unused import: {$span_snippets}
1741 *[other] unused imports: {$span_snippets}
1742 }"
1743)]
1744pub(crate) struct UnusedImports {
1745 #[subdiagnostic]
1746 pub sugg: Option<UnusedImportsSugg>,
1747 #[help("if this is a test module, consider adding a `#[cfg(test)]` to the containing module")]
1748 pub test_module_span: Option<Span>,
1749
1750 pub span_snippets: DiagArgValue,
1751 pub num_snippets: usize,
1752}
1753
1754#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedImportsSugg {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnusedImportsSugg::RemoveWholeUse { span: __binding_0 } => {
let __code_43 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the whole `use` item")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_43, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
UnusedImportsSugg::RemoveImports {
remove_spans: __binding_0, num_to_remove: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_44 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_44.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("num_to_remove".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("{$num_to_remove ->\n [one] remove the unused import\n *[other] remove the unused imports\n }")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
}
}
}
};Subdiagnostic)]
1755pub(crate) enum UnusedImportsSugg {
1756 #[suggestion(
1757 "remove the whole `use` item",
1758 applicability = "machine-applicable",
1759 code = "",
1760 style = "tool-only"
1761 )]
1762 RemoveWholeUse {
1763 #[primary_span]
1764 span: Span,
1765 },
1766 #[multipart_suggestion(
1767 "{$num_to_remove ->
1768 [one] remove the unused import
1769 *[other] remove the unused imports
1770 }",
1771 applicability = "machine-applicable",
1772 style = "tool-only"
1773 )]
1774 RemoveImports {
1775 #[suggestion_part(code = "")]
1776 remove_spans: Vec<Span>,
1777 num_to_remove: usize,
1778 },
1779}
1780
1781#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ToolAttrAmbiguity {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ToolAttrAmbiguity {
path_span: __binding_0,
attr_path: __binding_1,
tool: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute macro `{$attr_path}` is ambiguous")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous because of a name conflict with a tool namespace")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$tool}` could refer to a tool namespace")));
;
diag.arg("attr_path", __binding_1);
diag.arg("tool", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1782#[diag("attribute macro `{$attr_path}` is ambiguous")]
1783#[note("ambiguous because of a name conflict with a tool namespace")]
1784#[note("`{$tool}` could refer to a tool namespace")]
1785pub(crate) struct ToolAttrAmbiguity {
1786 #[primary_span]
1787 pub path_span: Span,
1788 pub attr_path: String,
1789 pub tool: Symbol,
1790}
1791
1792pub(crate) struct DuplicateLangItem {
1793 pub local_span: Option<Span>,
1794 pub lang_item_name: Symbol,
1795 pub crate_name: Symbol,
1796 pub dependency_of: Option<Symbol>,
1797 pub is_local: bool,
1798 pub path: String,
1799 pub first_defined_span: Option<Span>,
1800 pub orig_crate_name: Option<Symbol>,
1801 pub orig_dependency_of: Option<Symbol>,
1802 pub orig_is_local: bool,
1803 pub orig_path: String,
1804 pub(crate) duplicate: Duplicate,
1805}
1806
1807impl Diagnostic<'_> for DuplicateLangItem {
1808 #[track_caller]
1809 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
1810 let mut diag = Diag::new(
1811 dcx,
1812 level,
1813 match self.duplicate {
1814 Duplicate::Plain => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found duplicate lang item `{$lang_item_name}`"))msg!("found duplicate lang item `{$lang_item_name}`"),
1815 Duplicate::Crate => {
1816 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate lang item in crate `{$crate_name}`: `{$lang_item_name}`"))msg!("duplicate lang item in crate `{$crate_name}`: `{$lang_item_name}`")
1817 }
1818 Duplicate::CrateDepends => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate lang item in crate `{$crate_name}` (which `{$dependency_of}` depends on): `{$lang_item_name}`"))msg!(
1819 "duplicate lang item in crate `{$crate_name}` (which `{$dependency_of}` depends on): `{$lang_item_name}`"
1820 ),
1821 },
1822 );
1823 diag.code(E0152);
1824 diag.arg("lang_item_name", self.lang_item_name);
1825 diag.arg("crate_name", self.crate_name);
1826 if let Some(dependency_of) = self.dependency_of {
1827 diag.arg("dependency_of", dependency_of);
1828 }
1829 diag.arg("path", self.path);
1830 if let Some(orig_crate_name) = self.orig_crate_name {
1831 diag.arg("orig_crate_name", orig_crate_name);
1832 }
1833 if let Some(orig_dependency_of) = self.orig_dependency_of {
1834 diag.arg("orig_dependency_of", orig_dependency_of);
1835 }
1836 diag.arg("orig_path", self.orig_path);
1837 if let Some(span) = self.local_span {
1838 diag.span(span);
1839 }
1840 if let Some(span) = self.first_defined_span {
1841 diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined here"))msg!("the lang item is first defined here"));
1842 } else {
1843 if self.orig_dependency_of.is_none() {
1844 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined in crate `{$orig_crate_name}`"))msg!("the lang item is first defined in crate `{$orig_crate_name}`"));
1845 } else {
1846 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined in crate `{$orig_crate_name}` (which `{$orig_dependency_of}` depends on)"))msg!("the lang item is first defined in crate `{$orig_crate_name}` (which `{$orig_dependency_of}` depends on)"));
1847 }
1848
1849 if self.orig_is_local {
1850 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first definition in the local crate (`{$orig_crate_name}`)"))msg!("first definition in the local crate (`{$orig_crate_name}`)"));
1851 } else {
1852 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first definition in `{$orig_crate_name}` loaded from {$orig_path}"))msg!(
1853 "first definition in `{$orig_crate_name}` loaded from {$orig_path}"
1854 ));
1855 }
1856
1857 if self.is_local {
1858 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second definition in the local crate (`{$crate_name}`)"))msg!("second definition in the local crate (`{$crate_name}`)"));
1859 } else {
1860 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second definition in `{$crate_name}` loaded from {$path}"))msg!("second definition in `{$crate_name}` loaded from {$path}"));
1861 }
1862 }
1863 diag
1864 }
1865}
1866
1867#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MissingPanicHandler
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MissingPanicHandler => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[panic_handler]` function required, but not found")));
;
diag
}
}
}
}
};Diagnostic)]
1868#[diag("`#[panic_handler]` function required, but not found")]
1869pub(crate) struct MissingPanicHandler;
1870
1871#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PanicUnwindWithoutStd {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
PanicUnwindWithoutStd => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unwinding panics are not supported without std")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using nightly cargo, use -Zbuild-std with panic=\"abort\" to avoid unwinding")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("since the core library is usually precompiled with panic=\"unwind\", rebuilding your crate with panic=\"abort\" may not be enough to fix the problem")));
;
diag
}
}
}
}
};Diagnostic)]
1872#[diag("unwinding panics are not supported without std")]
1873#[help("using nightly cargo, use -Zbuild-std with panic=\"abort\" to avoid unwinding")]
1874#[note(
1875 "since the core library is usually precompiled with panic=\"unwind\", rebuilding your crate with panic=\"abort\" may not be enough to fix the problem"
1876)]
1877pub(crate) struct PanicUnwindWithoutStd;
1878
1879#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for IncorrectCrateType {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IncorrectCrateType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lang items are not allowed in stable dylibs")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1880#[diag("lang items are not allowed in stable dylibs")]
1881pub(crate) struct IncorrectCrateType {
1882 #[primary_span]
1883 pub span: Span,
1884}
1885
1886#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
IncorrectTarget<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IncorrectTarget {
span: __binding_0,
generics_span: __binding_1,
name: __binding_2,
kind: __binding_3,
num: __binding_4,
actual_num: __binding_5,
at_least: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` lang item must be applied to a {$kind} with {$at_least ->\n [true] at least {$num}\n *[false] {$num}\n } generic {$num ->\n [one] argument\n *[other] arguments\n }")));
diag.code(E0718);
;
diag.arg("name", __binding_2);
diag.arg("kind", __binding_3);
diag.arg("num", __binding_4);
diag.arg("actual_num", __binding_5);
diag.arg("at_least", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this {$kind} has {$actual_num} generic {$actual_num ->\n [one] argument\n *[other] arguments\n }")));
diag
}
}
}
}
};Diagnostic)]
1887#[diag("`{$name}` lang item must be applied to a {$kind} with {$at_least ->
1888 [true] at least {$num}
1889 *[false] {$num}
1890 } generic {$num ->
1891 [one] argument
1892 *[other] arguments
1893 }", code = E0718)]
1894pub(crate) struct IncorrectTarget<'a> {
1895 #[primary_span]
1896 pub span: Span,
1897 #[label(
1898 "this {$kind} has {$actual_num} generic {$actual_num ->
1899 [one] argument
1900 *[other] arguments
1901 }"
1902 )]
1903 pub generics_span: Span,
1904 pub name: &'a str, pub kind: &'static str,
1906 pub num: usize,
1907 pub actual_num: usize,
1908 pub at_least: bool,
1909}
1910
1911#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MissingLangItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MissingLangItem { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lang item required, but not found: `{$name}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this can occur when a binary crate with `#![no_std]` is compiled for a target where `{$name}` is defined in the standard library")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you may be able to compile for a target that doesn't need `{$name}`, specify a target with `--target` or in `.cargo/config`")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1912#[diag("lang item required, but not found: `{$name}`")]
1913#[note(
1914 "this can occur when a binary crate with `#![no_std]` is compiled for a target where `{$name}` is defined in the standard library"
1915)]
1916#[help(
1917 "you may be able to compile for a target that doesn't need `{$name}`, specify a target with `--target` or in `.cargo/config`"
1918)]
1919pub(crate) struct MissingLangItem {
1920 pub name: Symbol,
1921}