1use rustc_errors::codes::*;
2use rustc_errors::{
3 Applicability, Diag, DiagCtxtHandle, DiagMessage, Diagnostic, ElidedLifetimeInPathSubdiag,
4 EmissionGuarantee, IntoDiagArg, Level, LintDiagnostic, MultiSpan, Subdiagnostic, inline_fluent,
5};
6use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
7use rustc_span::source_map::Spanned;
8use rustc_span::{Ident, Span, Symbol};
9
10use crate::Res;
11use crate::late::PatternSource;
12
13#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericParamsFromOuterItem where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GenericParamsFromOuterItem {
span: __binding_0,
label: __binding_1,
refer_to_type_directly: __binding_2,
sugg: __binding_3,
static_or_const: __binding_4,
is_self: __binding_5,
item: __binding_6 } => {
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_5);
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_6) = __binding_6 {
diag.subdiagnostic(__binding_6);
}
diag
}
}
}
}
};Diagnostic)]
14#[diag("can't use {$is_self ->
15 [true] `Self`
16 *[false] generic parameters
17 } from outer item", code = E0401)]
18#[note(
19 "nested items are independent from their parent item for everything except for privacy and name resolution"
20)]
21pub(crate) struct GenericParamsFromOuterItem {
22 #[primary_span]
23 #[label(
24 "use of {$is_self ->
25 [true] `Self`
26 *[false] generic parameter
27 } from outer item"
28 )]
29 pub(crate) span: Span,
30 #[subdiagnostic]
31 pub(crate) label: Option<GenericParamsFromOuterItemLabel>,
32 #[subdiagnostic]
33 pub(crate) refer_to_type_directly: Option<UseTypeDirectly>,
34 #[subdiagnostic]
35 pub(crate) sugg: Option<GenericParamsFromOuterItemSugg>,
36 #[subdiagnostic]
37 pub(crate) static_or_const: Option<GenericParamsFromOuterItemStaticOrConst>,
38 pub(crate) is_self: bool,
39 #[subdiagnostic]
40 pub(crate) item: Option<GenericParamsFromOuterItemInnerItem>,
41}
42
43#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
GenericParamsFromOuterItemInnerItem {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
GenericParamsFromOuterItemInnerItem {
span: __binding_0, descr: __binding_1 } => {
diag.store_args();
diag.arg("descr", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_self ->\n [true] `Self`\n *[false] generic parameter\n } used in this inner {$descr}")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
44#[label(
45 "{$is_self ->
46 [true] `Self`
47 *[false] generic parameter
48 } used in this inner {$descr}"
49)]
50pub(crate) struct GenericParamsFromOuterItemInnerItem {
51 #[primary_span]
52 pub(crate) span: Span,
53 pub(crate) descr: String,
54}
55
56#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
GenericParamsFromOuterItemStaticOrConst {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
GenericParamsFromOuterItemStaticOrConst::Static => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `static` is a separate item from the item that contains it")));
diag.note(__message);
diag.restore_args();
}
GenericParamsFromOuterItemStaticOrConst::Const => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `const` is a separate item from the item that contains it")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
57pub(crate) enum GenericParamsFromOuterItemStaticOrConst {
58 #[note("a `static` is a separate item from the item that contains it")]
59 Static,
60 #[note("a `const` is a separate item from the item that contains it")]
61 Const,
62}
63
64#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for GenericParamsFromOuterItemLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
GenericParamsFromOuterItemLabel::SelfTyParam(__binding_0) =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't use `Self` here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
GenericParamsFromOuterItemLabel::SelfTyAlias(__binding_0) =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Self` type implicitly declared here, by this `impl`")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
GenericParamsFromOuterItemLabel::TyParam(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameter from outer item")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
GenericParamsFromOuterItemLabel::ConstParam(__binding_0) =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameter from outer item")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
65pub(crate) enum GenericParamsFromOuterItemLabel {
66 #[label("can't use `Self` here")]
67 SelfTyParam(#[primary_span] Span),
68 #[label("`Self` type implicitly declared here, by this `impl`")]
69 SelfTyAlias(#[primary_span] Span),
70 #[label("type parameter from outer item")]
71 TyParam(#[primary_span] Span),
72 #[label("const parameter from outer item")]
73 ConstParam(#[primary_span] Span),
74}
75
76#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for GenericParamsFromOuterItemSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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();
diag.store_args();
diag.arg("snippet", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try introducing a local generic parameter here")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_0, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
77#[suggestion(
78 "try introducing a local generic parameter here",
79 code = "{snippet}",
80 applicability = "maybe-incorrect",
81 style = "verbose"
82)]
83pub(crate) struct GenericParamsFromOuterItemSugg {
84 #[primary_span]
85 pub(crate) span: Span,
86 pub(crate) snippet: String,
87}
88#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UseTypeDirectly {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UseTypeDirectly { span: __binding_0, snippet: __binding_1 }
=> {
let __code_1 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("snippet", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("refer to the type directly here instead")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_1, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
89#[suggestion(
90 "refer to the type directly here instead",
91 code = "{snippet}",
92 applicability = "maybe-incorrect",
93 style = "verbose"
94)]
95pub(crate) struct UseTypeDirectly {
96 #[primary_span]
97 pub(crate) span: Span,
98 pub(crate) snippet: String,
99}
100
101#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NameAlreadyUsedInParameterList where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
102#[diag("the name `{$name}` is already used for a generic parameter in this item's generic parameters", code = E0403)]
103pub(crate) struct NameAlreadyUsedInParameterList {
104 #[primary_span]
105 #[label("already used")]
106 pub(crate) span: Span,
107 #[label("first use of `{$name}`")]
108 pub(crate) first_use_span: Span,
109 pub(crate) name: Ident,
110}
111
112#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MethodNotMemberOfTrait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
113#[diag("method `{$method}` is not a member of trait `{$trait_}`", code = E0407)]
114pub(crate) struct MethodNotMemberOfTrait {
115 #[primary_span]
116 #[label("not a member of trait `{$trait_}`")]
117 pub(crate) span: Span,
118 pub(crate) method: Ident,
119 pub(crate) trait_: String,
120 #[subdiagnostic]
121 pub(crate) sub: Option<AssociatedFnWithSimilarNameExists>,
122}
123
124#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AssociatedFnWithSimilarNameExists
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AssociatedFnWithSimilarNameExists {
span: __binding_0, candidate: __binding_1 } => {
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("candidate", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated function with a similar name")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
125#[suggestion(
126 "there is an associated function with a similar name",
127 code = "{candidate}",
128 applicability = "maybe-incorrect"
129)]
130pub(crate) struct AssociatedFnWithSimilarNameExists {
131 #[primary_span]
132 pub(crate) span: Span,
133 pub(crate) candidate: Symbol,
134}
135
136#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TypeNotMemberOfTrait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
137#[diag("type `{$type_}` is not a member of trait `{$trait_}`", code = E0437)]
138pub(crate) struct TypeNotMemberOfTrait {
139 #[primary_span]
140 #[label("not a member of trait `{$trait_}`")]
141 pub(crate) span: Span,
142 pub(crate) type_: Ident,
143 pub(crate) trait_: String,
144 #[subdiagnostic]
145 pub(crate) sub: Option<AssociatedTypeWithSimilarNameExists>,
146}
147
148#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AssociatedTypeWithSimilarNameExists {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AssociatedTypeWithSimilarNameExists {
span: __binding_0, candidate: __binding_1 } => {
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("candidate", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated type with a similar name")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_3, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
149#[suggestion(
150 "there is an associated type with a similar name",
151 code = "{candidate}",
152 applicability = "maybe-incorrect"
153)]
154pub(crate) struct AssociatedTypeWithSimilarNameExists {
155 #[primary_span]
156 pub(crate) span: Span,
157 pub(crate) candidate: Symbol,
158}
159
160#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstNotMemberOfTrait where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
161#[diag("const `{$const_}` is not a member of trait `{$trait_}`", code = E0438)]
162pub(crate) struct ConstNotMemberOfTrait {
163 #[primary_span]
164 #[label("not a member of trait `{$trait_}`")]
165 pub(crate) span: Span,
166 pub(crate) const_: Ident,
167 pub(crate) trait_: String,
168 #[subdiagnostic]
169 pub(crate) sub: Option<AssociatedConstWithSimilarNameExists>,
170}
171
172#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AssociatedConstWithSimilarNameExists {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AssociatedConstWithSimilarNameExists {
span: __binding_0, candidate: __binding_1 } => {
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("candidate", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is an associated constant with a similar name")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_4, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
173#[suggestion(
174 "there is an associated constant with a similar name",
175 code = "{candidate}",
176 applicability = "maybe-incorrect"
177)]
178pub(crate) struct AssociatedConstWithSimilarNameExists {
179 #[primary_span]
180 pub(crate) span: Span,
181 pub(crate) candidate: Symbol,
182}
183
184#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
VariableBoundWithDifferentMode where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
185#[diag("variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`", code = E0409)]
186pub(crate) struct VariableBoundWithDifferentMode {
187 #[primary_span]
188 #[label("bound in different ways")]
189 pub(crate) span: Span,
190 #[label("first binding")]
191 pub(crate) first_binding_span: Span,
192 pub(crate) variable_name: Ident,
193}
194
195#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IdentifierBoundMoreThanOnceInParameterList where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
196#[diag("identifier `{$identifier}` is bound more than once in this parameter list", code = E0415)]
197pub(crate) struct IdentifierBoundMoreThanOnceInParameterList {
198 #[primary_span]
199 #[label("used as parameter more than once")]
200 pub(crate) span: Span,
201 pub(crate) identifier: Ident,
202}
203
204#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IdentifierBoundMoreThanOnceInSamePattern where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
205#[diag("identifier `{$identifier}` is bound more than once in the same pattern", code = E0416)]
206pub(crate) struct IdentifierBoundMoreThanOnceInSamePattern {
207 #[primary_span]
208 #[label("used in a pattern more than once")]
209 pub(crate) span: Span,
210 pub(crate) identifier: Ident,
211}
212
213#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UndeclaredLabel where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
214#[diag("use of undeclared label `{$name}`", code = E0426)]
215pub(crate) struct UndeclaredLabel {
216 #[primary_span]
217 #[label("undeclared label `{$name}`")]
218 pub(crate) span: Span,
219 pub(crate) name: Symbol,
220 #[subdiagnostic]
221 pub(crate) sub_reachable: Option<LabelWithSimilarNameReachable>,
222 #[subdiagnostic]
223 pub(crate) sub_reachable_suggestion: Option<TryUsingSimilarlyNamedLabel>,
224 #[subdiagnostic]
225 pub(crate) sub_unreachable: Option<UnreachableLabelWithSimilarNameExists>,
226}
227
228#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for LabelWithSimilarNameReachable {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
LabelWithSimilarNameReachable(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a label with a similar name is reachable")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
229#[label("a label with a similar name is reachable")]
230pub(crate) struct LabelWithSimilarNameReachable(#[primary_span] pub(crate) Span);
231
232#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TryUsingSimilarlyNamedLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TryUsingSimilarlyNamedLabel {
span: __binding_0, ident_name: __binding_1 } => {
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("ident_name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using similarly named label")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_5, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
233#[suggestion(
234 "try using similarly named label",
235 code = "{ident_name}",
236 applicability = "maybe-incorrect"
237)]
238pub(crate) struct TryUsingSimilarlyNamedLabel {
239 #[primary_span]
240 pub(crate) span: Span,
241 pub(crate) ident_name: Symbol,
242}
243
244#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnreachableLabelWithSimilarNameExists {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnreachableLabelWithSimilarNameExists {
ident_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a label with a similar name exists but is unreachable")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
245#[label("a label with a similar name exists but is unreachable")]
246pub(crate) struct UnreachableLabelWithSimilarNameExists {
247 #[primary_span]
248 pub(crate) ident_span: Span,
249}
250
251#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfImportCanOnlyAppearOnceInTheList where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfImportCanOnlyAppearOnceInTheList { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`self` import can only appear once in an import list")));
diag.code(E0430);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can only appear once in an import list")));
diag
}
}
}
}
};Diagnostic)]
252#[diag("`self` import can only appear once in an import list", code = E0430)]
253pub(crate) struct SelfImportCanOnlyAppearOnceInTheList {
254 #[primary_span]
255 #[label("can only appear once in an import list")]
256 pub(crate) span: Span,
257}
258
259#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfImportOnlyInImportListWithNonEmptyPrefix where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfImportOnlyInImportListWithNonEmptyPrefix {
span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`self` import can only appear in an import list with a non-empty prefix")));
diag.code(E0431);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can only appear in an import list with a non-empty prefix")));
diag
}
}
}
}
};Diagnostic)]
260#[diag("`self` import can only appear in an import list with a non-empty prefix", code = E0431)]
261pub(crate) struct SelfImportOnlyInImportListWithNonEmptyPrefix {
262 #[primary_span]
263 #[label("can only appear in an import list with a non-empty prefix")]
264 pub(crate) span: Span,
265}
266
267#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotCaptureDynamicEnvironmentInFnItem where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CannotCaptureDynamicEnvironmentInFnItem { span: __binding_0
} => {
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.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use the `|| {\"{\"} ... {\"}\"}` closure form instead")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
268#[diag("can't capture dynamic environment in a fn item", code = E0434)]
269#[help("use the `|| {\"{\"} ... {\"}\"}` closure form instead")]
270pub(crate) struct CannotCaptureDynamicEnvironmentInFnItem {
271 #[primary_span]
272 pub(crate) span: Span,
273}
274
275#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
AttemptToUseNonConstantValueInConstant<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
276#[diag("attempt to use a non-constant value in a constant", code = E0435)]
277pub(crate) struct AttemptToUseNonConstantValueInConstant<'a> {
278 #[primary_span]
279 pub(crate) span: Span,
280 #[subdiagnostic]
281 pub(crate) with: Option<AttemptToUseNonConstantValueInConstantWithSuggestion<'a>>,
282 #[subdiagnostic]
283 pub(crate) with_label: Option<AttemptToUseNonConstantValueInConstantLabelWithSuggestion>,
284 #[subdiagnostic]
285 pub(crate) without: Option<AttemptToUseNonConstantValueInConstantWithoutSuggestion<'a>>,
286}
287
288#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AttemptToUseNonConstantValueInConstantWithSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AttemptToUseNonConstantValueInConstantWithSuggestion {
span: __binding_0,
suggestion: __binding_1,
type_span: __binding_2,
current: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_6 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", __binding_1))
});
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": /* Type */"))
});
suggestions.push((__binding_0, __code_6));
if let Some(__binding_2) = __binding_2 {
suggestions.push((__binding_2, __code_7));
}
diag.store_args();
diag.arg("suggestion", __binding_1);
diag.arg("current", __binding_3);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `{$suggestion}` instead of `{$current}`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
289#[multipart_suggestion(
290 "consider using `{$suggestion}` instead of `{$current}`",
291 style = "verbose",
292 applicability = "has-placeholders"
293)]
294pub(crate) struct AttemptToUseNonConstantValueInConstantWithSuggestion<'a> {
295 #[suggestion_part(code = "{suggestion} ")]
297 pub(crate) span: Span,
298 pub(crate) suggestion: &'a str,
299 #[suggestion_part(code = ": /* Type */")]
300 pub(crate) type_span: Option<Span>,
301 pub(crate) current: &'a str,
302}
303
304#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AttemptToUseNonConstantValueInConstantLabelWithSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AttemptToUseNonConstantValueInConstantLabelWithSuggestion {
span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-constant value")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
305#[label("non-constant value")]
306pub(crate) struct AttemptToUseNonConstantValueInConstantLabelWithSuggestion {
307 #[primary_span]
308 pub(crate) span: Span,
309}
310
311#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AttemptToUseNonConstantValueInConstantWithoutSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AttemptToUseNonConstantValueInConstantWithoutSuggestion {
ident_span: __binding_0, suggestion: __binding_1 } => {
diag.store_args();
diag.arg("suggestion", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this would need to be a `{$suggestion}`")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
312#[label("this would need to be a `{$suggestion}`")]
313pub(crate) struct AttemptToUseNonConstantValueInConstantWithoutSuggestion<'a> {
314 #[primary_span]
315 pub(crate) ident_span: Span,
316 pub(crate) suggestion: &'a str,
317}
318
319#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfImportsOnlyAllowedWithin where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfImportsOnlyAllowedWithin {
span: __binding_0,
suggestion: __binding_1,
mpart_suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`self` imports are only allowed within a {\"{\"} {\"}\"} list")));
diag.code(E0429);
;
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);
}
diag
}
}
}
}
};Diagnostic)]
320#[diag("`self` imports are only allowed within a {\"{\"} {\"}\"} list", code = E0429)]
321pub(crate) struct SelfImportsOnlyAllowedWithin {
322 #[primary_span]
323 pub(crate) span: Span,
324 #[subdiagnostic]
325 pub(crate) suggestion: Option<SelfImportsOnlyAllowedWithinSuggestion>,
326 #[subdiagnostic]
327 pub(crate) mpart_suggestion: Option<SelfImportsOnlyAllowedWithinMultipartSuggestion>,
328}
329
330#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
SelfImportsOnlyAllowedWithinSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SelfImportsOnlyAllowedWithinSuggestion { span: __binding_0 }
=> {
let __code_8 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider importing the module directly")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_8, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
331#[suggestion(
332 "consider importing the module directly",
333 code = "",
334 applicability = "machine-applicable"
335)]
336pub(crate) struct SelfImportsOnlyAllowedWithinSuggestion {
337 #[primary_span]
338 pub(crate) span: Span,
339}
340
341#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
SelfImportsOnlyAllowedWithinMultipartSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SelfImportsOnlyAllowedWithinMultipartSuggestion {
multipart_start: __binding_0, multipart_end: __binding_1 }
=> {
let mut suggestions = Vec::new();
let __code_9 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{"))
});
let __code_10 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("}}"))
});
suggestions.push((__binding_0, __code_9));
suggestions.push((__binding_1, __code_10));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatively, use the multi-path `use` syntax to import `self`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
342#[multipart_suggestion(
343 "alternatively, use the multi-path `use` syntax to import `self`",
344 applicability = "machine-applicable"
345)]
346pub(crate) struct SelfImportsOnlyAllowedWithinMultipartSuggestion {
347 #[suggestion_part(code = "{{")]
348 pub(crate) multipart_start: Span,
349 #[suggestion_part(code = "}}")]
350 pub(crate) multipart_end: Span,
351}
352
353#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BindingShadowsSomethingUnacceptable<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
354#[diag("{$shadowing_binding}s cannot shadow {$shadowed_binding}s", code = E0530)]
355pub(crate) struct BindingShadowsSomethingUnacceptable<'a> {
356 #[primary_span]
357 #[label("cannot be named the same as {$article} {$shadowed_binding}")]
358 pub(crate) span: Span,
359 pub(crate) shadowing_binding: PatternSource,
360 pub(crate) shadowed_binding: Res,
361 pub(crate) article: &'a str,
362 #[subdiagnostic]
363 pub(crate) sub_suggestion: Option<BindingShadowsSomethingUnacceptableSuggestion>,
364 #[label("the {$shadowed_binding} `{$name}` is {$participle} here")]
365 pub(crate) shadowed_binding_span: Span,
366 pub(crate) participle: &'a str,
367 pub(crate) name: Symbol,
368}
369
370#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
BindingShadowsSomethingUnacceptableSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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();
diag.store_args();
diag.arg("name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try specify the pattern arguments")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_11, rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
371#[suggestion(
372 "try specify the pattern arguments",
373 code = "{name}(..)",
374 applicability = "unspecified"
375)]
376pub(crate) struct BindingShadowsSomethingUnacceptableSuggestion {
377 #[primary_span]
378 pub(crate) span: Span,
379 pub(crate) name: Symbol,
380}
381
382#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ForwardDeclaredGenericParam where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
383#[diag("generic parameter defaults cannot reference parameters before they are declared", code = E0128)]
384pub(crate) struct ForwardDeclaredGenericParam {
385 #[primary_span]
386 #[label("cannot reference `{$param}` before it is declared")]
387 pub(crate) span: Span,
388 pub(crate) param: Symbol,
389}
390
391#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ForwardDeclaredGenericInConstParamTy where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
392#[diag("const parameter types cannot reference parameters before they are declared")]
393pub(crate) struct ForwardDeclaredGenericInConstParamTy {
394 #[primary_span]
395 #[label("const parameter type cannot reference `{$param}` before it is declared")]
396 pub(crate) span: Span,
397 pub(crate) param: Symbol,
398}
399
400#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParamInTyOfConstParam where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
401#[diag("the type of const parameters must not depend on other generic parameters", code = E0770)]
402pub(crate) struct ParamInTyOfConstParam {
403 #[primary_span]
404 #[label("the type must not depend on the parameter `{$name}`")]
405 pub(crate) span: Span,
406 pub(crate) name: Symbol,
407}
408
409#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfInGenericParamDefault where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
410#[diag("generic parameters cannot use `Self` in their defaults", code = E0735)]
411pub(crate) struct SelfInGenericParamDefault {
412 #[primary_span]
413 pub(crate) span: Span,
414}
415
416#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SelfInConstGenericTy where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SelfInConstGenericTy { span: __binding_0 } => {
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);
diag
}
}
}
}
};Diagnostic)]
417#[diag("cannot use `Self` in const parameter type")]
418pub(crate) struct SelfInConstGenericTy {
419 #[primary_span]
420 pub(crate) span: Span,
421}
422
423#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParamInNonTrivialAnonConst where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ParamInNonTrivialAnonConst {
span: __binding_0,
name: __binding_1,
param_kind: __binding_2,
help: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters may not be used in const operations")));
;
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);
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
424#[diag("generic parameters may not be used in const operations")]
425pub(crate) struct ParamInNonTrivialAnonConst {
426 #[primary_span]
427 #[label("cannot perform const operation using `{$name}`")]
428 pub(crate) span: Span,
429 pub(crate) name: Symbol,
430 #[subdiagnostic]
431 pub(crate) param_kind: ParamKindInNonTrivialAnonConst,
432 #[subdiagnostic]
433 pub(crate) help: Option<ParamInNonTrivialAnonConstHelp>,
434}
435
436#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParamInNonTrivialAnonConstHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParamInNonTrivialAnonConstHelp => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(generic_const_exprs)]` to allow generic const expressions")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
437#[help("add `#![feature(generic_const_exprs)]` to allow generic const expressions")]
438pub(crate) struct ParamInNonTrivialAnonConstHelp;
439
440#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParamKindInNonTrivialAnonConst {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ParamKindInNonTrivialAnonConst::Type =>
::core::fmt::Formatter::write_str(f, "Type"),
ParamKindInNonTrivialAnonConst::Const { name: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
"name", &__self_0),
ParamKindInNonTrivialAnonConst::Lifetime =>
::core::fmt::Formatter::write_str(f, "Lifetime"),
}
}
}Debug)]
441#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParamKindInNonTrivialAnonConst {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParamKindInNonTrivialAnonConst::Type => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameters may not be used in const expressions")));
diag.note(__message);
diag.restore_args();
}
ParamKindInNonTrivialAnonConst::Const { name: __binding_0 }
=> {
diag.store_args();
diag.arg("name", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameters may only be used as standalone arguments here, i.e. `{$name}`")));
diag.help(__message);
diag.restore_args();
}
ParamKindInNonTrivialAnonConst::Lifetime => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters may not be used in const expressions")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
442pub(crate) enum ParamKindInNonTrivialAnonConst {
443 #[note("type parameters may not be used in const expressions")]
444 Type,
445 #[help("const parameters may only be used as standalone arguments here, i.e. `{$name}`")]
446 Const { name: Symbol },
447 #[note("lifetime parameters may not be used in const expressions")]
448 Lifetime,
449}
450
451#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnreachableLabel where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
452#[diag("use of unreachable label `{$name}`", code = E0767)]
453#[note("labels are unreachable through functions, closures, async blocks and modules")]
454pub(crate) struct UnreachableLabel {
455 #[primary_span]
456 #[label("unreachable label `{$name}`")]
457 pub(crate) span: Span,
458 pub(crate) name: Symbol,
459 #[label("unreachable label defined here")]
460 pub(crate) definition_span: Span,
461 #[subdiagnostic]
462 pub(crate) sub_suggestion: Option<UnreachableLabelSubSuggestion>,
463 #[subdiagnostic]
464 pub(crate) sub_suggestion_label: Option<UnreachableLabelSubLabel>,
465 #[subdiagnostic]
466 pub(crate) sub_unreachable_label: Option<UnreachableLabelSubLabelUnreachable>,
467}
468
469#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnreachableLabelSubSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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();
diag.store_args();
diag.arg("ident_name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using similarly named label")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_12, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
470#[suggestion(
471 "try using similarly named label",
472 code = "{ident_name}",
473 applicability = "maybe-incorrect"
474)]
475pub(crate) struct UnreachableLabelSubSuggestion {
476 #[primary_span]
477 pub(crate) span: Span,
478 pub(crate) ident_name: Symbol,
479}
480
481#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnreachableLabelSubLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnreachableLabelSubLabel { ident_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a label with a similar name is reachable")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
482#[label("a label with a similar name is reachable")]
483pub(crate) struct UnreachableLabelSubLabel {
484 #[primary_span]
485 pub(crate) ident_span: Span,
486}
487
488#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnreachableLabelSubLabelUnreachable {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnreachableLabelSubLabelUnreachable {
ident_span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a label with a similar name exists but is also unreachable")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
489#[label("a label with a similar name exists but is also unreachable")]
490pub(crate) struct UnreachableLabelSubLabelUnreachable {
491 #[primary_span]
492 pub(crate) ident_span: Span,
493}
494
495#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InvalidAsmSym
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
496#[diag("invalid `sym` operand")]
497#[help("`sym` operands must refer to either a function or a static")]
498pub(crate) struct InvalidAsmSym {
499 #[primary_span]
500 #[label("is a local variable")]
501 pub(crate) span: Span,
502}
503
504#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LowercaseSelf
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
505#[diag("attempt to use a non-constant value in a constant")]
506pub(crate) struct LowercaseSelf {
507 #[primary_span]
508 #[suggestion(
509 "try using `Self`",
510 code = "Self",
511 applicability = "maybe-incorrect",
512 style = "short"
513 )]
514 pub(crate) span: Span,
515}
516
517#[derive(#[automatically_derived]
impl ::core::fmt::Debug for BindingInNeverPattern {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"BindingInNeverPattern", "span", &&self.span)
}
}Debug)]
518#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BindingInNeverPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
519#[diag("never patterns cannot contain variable bindings")]
520pub(crate) struct BindingInNeverPattern {
521 #[primary_span]
522 #[suggestion(
523 "use a wildcard `_` instead",
524 code = "_",
525 applicability = "machine-applicable",
526 style = "short"
527 )]
528 pub(crate) span: Span,
529}
530
531#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitImplDuplicate where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitImplDuplicate {
span: __binding_0,
old_span: __binding_1,
trait_item_span: __binding_2,
name: __binding_3 } => {
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_3);
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
}
}
}
}
};Diagnostic)]
532#[diag("duplicate definitions with name `{$name}`:", code = E0201)]
533pub(crate) struct TraitImplDuplicate {
534 #[primary_span]
535 #[label("duplicate definition")]
536 pub(crate) span: Span,
537 #[label("previous definition here")]
538 pub(crate) old_span: Span,
539 #[label("item in trait")]
540 pub(crate) trait_item_span: Span,
541 pub(crate) name: Ident,
542}
543
544#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for Relative2018
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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.arg("path_str", __binding_2);
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)]
545#[diag("relative paths are not supported in visibilities in 2018 edition or later")]
546pub(crate) struct Relative2018 {
547 #[primary_span]
548 pub(crate) span: Span,
549 #[suggestion("try", code = "crate::{path_str}", applicability = "maybe-incorrect")]
550 pub(crate) path_span: Span,
551 pub(crate) path_str: String,
552}
553
554#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AncestorOnly
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
555#[diag("visibilities can only be restricted to ancestor modules", code = E0742)]
556pub(crate) struct AncestorOnly(#[primary_span] pub(crate) Span);
557
558#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedModuleFound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
559#[diag("expected module, found {$res} `{$path_str}`", code = E0577)]
560pub(crate) struct ExpectedModuleFound {
561 #[primary_span]
562 #[label("not a module")]
563 pub(crate) span: Span,
564 pub(crate) res: Res,
565 pub(crate) path_str: String,
566}
567
568#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for Indeterminate
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
569#[diag("cannot determine resolution for the visibility", code = E0578)]
570pub(crate) struct Indeterminate(#[primary_span] pub(crate) Span);
571
572#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ToolModuleImported where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
573#[diag("cannot use a tool module through an import")]
574pub(crate) struct ToolModuleImported {
575 #[primary_span]
576 pub(crate) span: Span,
577 #[note("the tool module imported here")]
578 pub(crate) import: Span,
579}
580
581#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ModuleOnly
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
582#[diag("visibility must resolve to a module")]
583pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span);
584
585#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MacroExpectedFound<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
586#[diag("expected {$expected}, found {$found} `{$macro_path}`")]
587pub(crate) struct MacroExpectedFound<'a> {
588 #[primary_span]
589 #[label("not {$article} {$expected}")]
590 pub(crate) span: Span,
591 pub(crate) found: &'a str,
592 pub(crate) article: &'static str,
593 pub(crate) expected: &'a str,
594 pub(crate) macro_path: &'a str,
595 #[subdiagnostic]
596 pub(crate) remove_surrounding_derive: Option<RemoveSurroundingDerive>,
597 #[subdiagnostic]
598 pub(crate) add_as_non_derive: Option<AddAsNonDerive<'a>>,
599}
600
601#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RemoveSurroundingDerive {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RemoveSurroundingDerive { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove from the surrounding `derive()`")));
diag.span_help(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
602#[help("remove from the surrounding `derive()`")]
603pub(crate) struct RemoveSurroundingDerive {
604 #[primary_span]
605 pub(crate) span: Span,
606}
607
608#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for AddAsNonDerive<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AddAsNonDerive { macro_path: __binding_0 } => {
diag.store_args();
diag.arg("macro_path", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("\n add as non-Derive macro\n `#[{$macro_path}]`")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
609#[help(
610 "
611 add as non-Derive macro
612 `#[{$macro_path}]`"
613)]
614pub(crate) struct AddAsNonDerive<'a> {
615 pub(crate) macro_path: &'a str,
616}
617
618#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ProcMacroSameCrate where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
619#[diag("can't use a procedural macro from the same crate that defines it")]
620pub(crate) struct ProcMacroSameCrate {
621 #[primary_span]
622 pub(crate) span: Span,
623 #[help("you can define integration tests in a directory named `tests`")]
624 pub(crate) is_test: bool,
625}
626
627#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
ProcMacroDeriveResolutionFallback {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
ProcMacroDeriveResolutionFallback {
span: __binding_0, ns_descr: __binding_1, ident: __binding_2
} => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
628#[diag("cannot find {$ns_descr} `{$ident}` in this scope")]
629pub(crate) struct ProcMacroDeriveResolutionFallback {
630 #[label("names from parent modules are not accessible without an explicit import")]
631 pub span: Span,
632 pub ns_descr: &'static str,
633 pub ident: Symbol,
634}
635
636#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
MacroExpandedMacroExportsAccessedByAbsolutePaths {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MacroExpandedMacroExportsAccessedByAbsolutePaths {
definition: __binding_0 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
637#[diag(
638 "macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"
639)]
640pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths {
641 #[note("the macro is defined here")]
642 pub definition: Span,
643}
644
645#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CrateImported
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CrateImported { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`$crate` may not be imported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
646#[diag("`$crate` may not be imported")]
647pub(crate) struct CrateImported {
648 #[primary_span]
649 pub(crate) span: Span,
650}
651
652#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroUseExternCrateSelf where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
653#[diag("`#[macro_use]` is not supported on `extern crate self`")]
654pub(crate) struct MacroUseExternCrateSelf {
655 #[primary_span]
656 pub(crate) span: Span,
657}
658
659#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CfgAccessibleUnsure where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
660#[diag("not sure whether the path is accessible or not")]
661#[note("the type may have associated items, but we are currently not checking them")]
662pub(crate) struct CfgAccessibleUnsure {
663 #[primary_span]
664 pub(crate) span: Span,
665}
666
667#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParamInEnumDiscriminant {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"ParamInEnumDiscriminant", "span", &self.span, "name", &self.name,
"param_kind", &&self.param_kind)
}
}Debug)]
668#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ParamInEnumDiscriminant where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
669#[diag("generic parameters may not be used in enum discriminant values")]
670pub(crate) struct ParamInEnumDiscriminant {
671 #[primary_span]
672 #[label("cannot perform const operation using `{$name}`")]
673 pub(crate) span: Span,
674 pub(crate) name: Symbol,
675 #[subdiagnostic]
676 pub(crate) param_kind: ParamKindInEnumDiscriminant,
677}
678
679#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParamKindInEnumDiscriminant {
#[inline]
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)]
680#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ParamKindInEnumDiscriminant {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParamKindInEnumDiscriminant::Type => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type parameters may not be used in enum discriminant values")));
diag.note(__message);
diag.restore_args();
}
ParamKindInEnumDiscriminant::Const => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const parameters may not be used in enum discriminant values")));
diag.note(__message);
diag.restore_args();
}
ParamKindInEnumDiscriminant::Lifetime => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime parameters may not be used in enum discriminant values")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
681pub(crate) enum ParamKindInEnumDiscriminant {
682 #[note("type parameters may not be used in enum discriminant values")]
683 Type,
684 #[note("const parameters may not be used in enum discriminant values")]
685 Const,
686 #[note("lifetime parameters may not be used in enum discriminant values")]
687 Lifetime,
688}
689
690#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeImportBinding {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ChangeImportBinding { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can use `as` to change the binding name of the import")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
691#[label("you can use `as` to change the binding name of the import")]
692pub(crate) struct ChangeImportBinding {
693 #[primary_span]
694 pub(crate) span: Span,
695}
696
697#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeImportBindingSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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();
diag.store_args();
diag.arg("suggestion", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can use `as` to change the binding name of the import")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_16, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
698#[suggestion(
699 "you can use `as` to change the binding name of the import",
700 code = "{suggestion}",
701 applicability = "maybe-incorrect"
702)]
703pub(crate) struct ChangeImportBindingSuggestion {
704 #[primary_span]
705 pub(crate) span: Span,
706 pub(crate) suggestion: String,
707}
708
709#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ImportsCannotReferTo<'a> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
710#[diag("imports cannot refer to {$what}")]
711pub(crate) struct ImportsCannotReferTo<'a> {
712 #[primary_span]
713 pub(crate) span: Span,
714 pub(crate) what: &'a str,
715}
716
717#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
CannotFindIdentInThisScope<'a> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
718#[diag("cannot find {$expected} `{$ident}` in this scope")]
719pub(crate) struct CannotFindIdentInThisScope<'a> {
720 #[primary_span]
721 pub(crate) span: Span,
722 pub(crate) expected: &'a str,
723 pub(crate) ident: Ident,
724}
725
726#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExplicitUnsafeTraits {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExplicitUnsafeTraits { span: __binding_0, ident: __binding_1
} => {
diag.store_args();
diag.arg("ident", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe traits like `{$ident}` should be implemented explicitly")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
727#[note("unsafe traits like `{$ident}` should be implemented explicitly")]
728pub(crate) struct ExplicitUnsafeTraits {
729 #[primary_span]
730 pub(crate) span: Span,
731 pub(crate) ident: Ident,
732}
733
734#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MacroDefinedLater {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MacroDefinedLater { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a macro with the same name exists, but it appears later")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
735#[note("a macro with the same name exists, but it appears later")]
736pub(crate) struct MacroDefinedLater {
737 #[primary_span]
738 pub(crate) span: Span,
739}
740
741#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MacroSuggMovePosition {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MacroSuggMovePosition {
span: __binding_0, ident: __binding_1 } => {
diag.store_args();
diag.arg("ident", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the definition of `{$ident}` before this call")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
742#[label("consider moving the definition of `{$ident}` before this call")]
743pub(crate) struct MacroSuggMovePosition {
744 #[primary_span]
745 pub(crate) span: Span,
746 pub(crate) ident: Ident,
747}
748
749#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MacroRulesNot {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MacroRulesNot::Func { span: __binding_0, ident: __binding_1
} => {
diag.store_args();
diag.arg("ident", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` exists, but has no rules for function-like invocation")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
MacroRulesNot::Attr { span: __binding_0, ident: __binding_1
} => {
diag.store_args();
diag.arg("ident", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` exists, but has no `attr` rules")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
MacroRulesNot::Derive {
span: __binding_0, ident: __binding_1 } => {
diag.store_args();
diag.arg("ident", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` exists, but has no `derive` rules")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
750pub(crate) enum MacroRulesNot {
751 #[label("`{$ident}` exists, but has no rules for function-like invocation")]
752 Func {
753 #[primary_span]
754 span: Span,
755 ident: Ident,
756 },
757 #[label("`{$ident}` exists, but has no `attr` rules")]
758 Attr {
759 #[primary_span]
760 span: Span,
761 ident: Ident,
762 },
763 #[label("`{$ident}` exists, but has no `derive` rules")]
764 Derive {
765 #[primary_span]
766 span: Span,
767 ident: Ident,
768 },
769}
770
771#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MaybeMissingMacroRulesName {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MaybeMissingMacroRulesName { spans: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("maybe you have forgotten to define a name for this `macro_rules!`")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
772#[note("maybe you have forgotten to define a name for this `macro_rules!`")]
773pub(crate) struct MaybeMissingMacroRulesName {
774 #[primary_span]
775 pub(crate) spans: MultiSpan,
776}
777
778#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for AddedMacroUse {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AddedMacroUse => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("have you added the `#[macro_use]` on the module/import?")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
779#[help("have you added the `#[macro_use]` on the module/import?")]
780pub(crate) struct AddedMacroUse;
781
782#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderAddingADerive {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
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();
diag.store_args();
diag.arg("suggestion", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a derive")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_17, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
783#[suggestion("consider adding a derive", code = "{suggestion}", applicability = "maybe-incorrect")]
784pub(crate) struct ConsiderAddingADerive {
785 #[primary_span]
786 pub(crate) span: Span,
787 pub(crate) suggestion: String,
788}
789
790#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotDetermineImportResolution where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
791#[diag("cannot determine resolution for the import")]
792pub(crate) struct CannotDetermineImportResolution {
793 #[primary_span]
794 pub(crate) span: Span,
795}
796
797#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotDetermineMacroResolution where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
798#[diag("cannot determine resolution for the {$kind} `{$path}`")]
799#[note("import resolution is stuck, try simplifying macro imports")]
800pub(crate) struct CannotDetermineMacroResolution {
801 #[primary_span]
802 pub(crate) span: Span,
803 pub(crate) kind: &'static str,
804 pub(crate) path: String,
805}
806
807#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeReexportedPrivate where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
808#[diag("`{$ident}` is private, and cannot be re-exported", code = E0364)]
809pub(crate) struct CannotBeReexportedPrivate {
810 #[primary_span]
811 pub(crate) span: Span,
812 pub(crate) ident: Ident,
813}
814
815#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeReexportedCratePublic where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
816#[diag("`{$ident}` is only public within the crate, and cannot be re-exported outside", code = E0364)]
817pub(crate) struct CannotBeReexportedCratePublic {
818 #[primary_span]
819 pub(crate) span: Span,
820 pub(crate) ident: Ident,
821}
822
823#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeReexportedPrivateNS where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CannotBeReexportedPrivateNS {
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(E0365);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider declaring type or module `{$ident}` with `pub`")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("re-export of private `{$ident}`")));
diag
}
}
}
}
};Diagnostic)]
824#[diag("`{$ident}` is private, and cannot be re-exported", code = E0365)]
825#[note("consider declaring type or module `{$ident}` with `pub`")]
826pub(crate) struct CannotBeReexportedPrivateNS {
827 #[primary_span]
828 #[label("re-export of private `{$ident}`")]
829 pub(crate) span: Span,
830 pub(crate) ident: Ident,
831}
832
833#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotBeReexportedCratePublicNS where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CannotBeReexportedCratePublicNS {
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(E0365);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider declaring type or module `{$ident}` with `pub`")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("re-export of crate public `{$ident}`")));
diag
}
}
}
}
};Diagnostic)]
834#[diag("`{$ident}` is only public within the crate, and cannot be re-exported outside", code = E0365)]
835#[note("consider declaring type or module `{$ident}` with `pub`")]
836pub(crate) struct CannotBeReexportedCratePublicNS {
837 #[primary_span]
838 #[label("re-export of crate public `{$ident}`")]
839 pub(crate) span: Span,
840 pub(crate) ident: Ident,
841}
842
843#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
PrivateExternCrateReexport {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
PrivateExternCrateReexport {
ident: __binding_0, sugg: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern crate `{$ident}` is private and cannot be re-exported")));
diag.code(E0365);
;
let __code_18 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub "))
})].into_iter();
diag.arg("ident", __binding_0);
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
}
};
}
}
};LintDiagnostic)]
844#[diag("extern crate `{$ident}` is private and cannot be re-exported", code = E0365)]
845pub(crate) struct PrivateExternCrateReexport {
846 pub ident: Ident,
847 #[suggestion(
848 "consider making the `extern crate` item publicly accessible",
849 code = "pub ",
850 style = "verbose",
851 applicability = "maybe-incorrect"
852 )]
853 pub sugg: Span,
854}
855
856#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderAddingMacroExport {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConsiderAddingMacroExport { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a `#[macro_export]` to the macro in the imported module")));
diag.span_help(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
857#[help("consider adding a `#[macro_export]` to the macro in the imported module")]
858pub(crate) struct ConsiderAddingMacroExport {
859 #[primary_span]
860 pub(crate) span: Span,
861}
862
863#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderMarkingAsPubCrate {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConsiderMarkingAsPubCrate { vis_span: __binding_0 } => {
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub(crate)"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(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)`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_19, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
864#[suggestion(
865 "in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)`",
866 code = "pub(crate)",
867 applicability = "maybe-incorrect"
868)]
869pub(crate) struct ConsiderMarkingAsPubCrate {
870 #[primary_span]
871 pub(crate) vis_span: Span,
872}
873
874#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderMarkingAsPub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConsiderMarkingAsPub { span: __binding_0, ident: __binding_1
} => {
diag.store_args();
diag.arg("ident", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider marking `{$ident}` as `pub` in the imported module")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
875#[note("consider marking `{$ident}` as `pub` in the imported module")]
876pub(crate) struct ConsiderMarkingAsPub {
877 #[primary_span]
878 pub(crate) span: Span,
879 pub(crate) ident: Ident,
880}
881
882#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotGlobImportAllCrates where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
883#[diag("cannot glob-import all possible crates")]
884pub(crate) struct CannotGlobImportAllCrates {
885 #[primary_span]
886 pub(crate) span: Span,
887}
888
889#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedResChangeTyToConstParamSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedResChangeTyToConstParamSugg {
span: __binding_0, applicability: __binding_1 } => {
let __code_20 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write a const parameter here")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_20, __binding_1,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
890#[suggestion(
891 "you might have meant to write a const parameter here",
892 code = "const ",
893 style = "verbose"
894)]
895pub(crate) struct UnexpectedResChangeTyToConstParamSugg {
896 #[primary_span]
897 pub span: Span,
898 #[applicability]
899 pub applicability: Applicability,
900}
901
902#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedResChangeTyParamToConstParamSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedResChangeTyParamToConstParamSugg {
before: __binding_0, after: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_21 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("const "))
});
let __code_22 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(": /* Type */"))
});
suggestions.push((__binding_0, __code_21));
suggestions.push((__binding_1, __code_22));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to write a const parameter here")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
903#[multipart_suggestion(
904 "you might have meant to write a const parameter here",
905 applicability = "has-placeholders",
906 style = "verbose"
907)]
908pub(crate) struct UnexpectedResChangeTyParamToConstParamSugg {
909 #[suggestion_part(code = "const ")]
910 pub before: Span,
911 #[suggestion_part(code = ": /* Type */")]
912 pub after: Span,
913}
914
915#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnexpectedResUseAtOpInSlicePatWithRangeSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedResUseAtOpInSlicePatWithRangeSugg {
span: __binding_0, ident: __binding_1, snippet: __binding_2
} => {
let __code_23 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.store_args();
diag.arg("ident", __binding_1);
diag.arg("snippet", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to collect the rest of the slice in `{$ident}`, use the at operator")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_23, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
916#[suggestion(
917 "if you meant to collect the rest of the slice in `{$ident}`, use the at operator",
918 code = "{snippet}",
919 applicability = "maybe-incorrect",
920 style = "verbose"
921)]
922pub(crate) struct UnexpectedResUseAtOpInSlicePatWithRangeSugg {
923 #[primary_span]
924 pub span: Span,
925 pub ident: Ident,
926 pub snippet: String,
927}
928
929#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExternCrateLoadingMacroNotAtCrateRoot where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
930#[diag("an `extern crate` loading macros must be at the crate root", code = E0468)]
931pub(crate) struct ExternCrateLoadingMacroNotAtCrateRoot {
932 #[primary_span]
933 pub(crate) span: Span,
934}
935
936#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExternCrateSelfRequiresRenaming where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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_24 =
[::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_24, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
937#[diag("`extern crate self;` requires renaming")]
938pub(crate) struct ExternCrateSelfRequiresRenaming {
939 #[primary_span]
940 #[suggestion(
941 "rename the `self` crate to be able to import it",
942 code = "extern crate self as name;",
943 applicability = "has-placeholders"
944 )]
945 pub(crate) span: Span,
946}
947
948#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroUseNameAlreadyInUse where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
949#[diag("`{$name}` is already in scope")]
950#[note("macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)")]
951pub(crate) struct MacroUseNameAlreadyInUse {
952 #[primary_span]
953 pub(crate) span: Span,
954 pub(crate) name: Symbol,
955}
956
957#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ImportedMacroNotFound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
958#[diag("imported macro not found", code = E0469)]
959pub(crate) struct ImportedMacroNotFound {
960 #[primary_span]
961 pub(crate) span: Span,
962}
963
964#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroExternDeprecated where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
965#[diag("`#[macro_escape]` is a deprecated synonym for `#[macro_use]`")]
966pub(crate) struct MacroExternDeprecated {
967 #[primary_span]
968 pub(crate) span: Span,
969 #[help("try an outer attribute: `#[macro_use]`")]
970 pub inner_attribute: bool,
971}
972
973#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ArgumentsMacroUseNotAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
974#[diag("arguments to `macro_use` are not allowed here")]
975pub(crate) struct ArgumentsMacroUseNotAllowed {
976 #[primary_span]
977 pub(crate) span: Span,
978}
979
980#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnnamedCrateRootImport where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnnamedCrateRootImport { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate root imports need to be explicitly named: `use crate as name;`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
981#[diag("crate root imports need to be explicitly named: `use crate as name;`")]
982pub(crate) struct UnnamedCrateRootImport {
983 #[primary_span]
984 pub(crate) span: Span,
985}
986
987#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroExpandedExternCrateCannotShadowExternArguments where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
988#[diag("macro-expanded `extern crate` items cannot shadow names passed with `--extern`")]
989pub(crate) struct MacroExpandedExternCrateCannotShadowExternArguments {
990 #[primary_span]
991 pub(crate) span: Span,
992}
993
994#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ElidedAnonymousLifetimeReportError where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
995#[diag("`&` without an explicit lifetime name cannot be used here", code = E0637)]
996pub(crate) struct ElidedAnonymousLifetimeReportError {
997 #[primary_span]
998 #[label("explicit lifetime name needed here")]
999 pub(crate) span: Span,
1000 #[subdiagnostic]
1001 pub(crate) suggestion: Option<ElidedAnonymousLifetimeReportErrorSuggestion>,
1002}
1003
1004#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LendingIteratorReportError where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1005#[diag(
1006 "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"
1007)]
1008pub(crate) struct LendingIteratorReportError {
1009 #[primary_span]
1010 pub(crate) lifetime: Span,
1011 #[note(
1012 "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"
1013 )]
1014 pub(crate) ty: Span,
1015}
1016
1017#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AnonymousLifetimeNonGatReportError where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1018#[diag("missing lifetime in associated type")]
1019pub(crate) struct AnonymousLifetimeNonGatReportError {
1020 #[primary_span]
1021 #[label("this lifetime must come from the implemented type")]
1022 pub(crate) lifetime: Span,
1023 #[note(
1024 "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"
1025 )]
1026 pub(crate) decl: MultiSpan,
1027}
1028
1029#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ElidedAnonymousLifetimeReportErrorSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ElidedAnonymousLifetimeReportErrorSuggestion {
lo: __binding_0, hi: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_25 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("for<\'a> "))
});
let __code_26 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\'a "))
});
suggestions.push((__binding_0, __code_25));
suggestions.push((__binding_1, __code_26));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider introducing a higher-ranked lifetime here")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1030#[multipart_suggestion(
1031 "consider introducing a higher-ranked lifetime here",
1032 applicability = "machine-applicable"
1033)]
1034pub(crate) struct ElidedAnonymousLifetimeReportErrorSuggestion {
1035 #[suggestion_part(code = "for<'a> ")]
1036 pub(crate) lo: Span,
1037 #[suggestion_part(code = "'a ")]
1038 pub(crate) hi: Span,
1039}
1040
1041#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExplicitAnonymousLifetimeReportError where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1042#[diag("`'_` cannot be used here", code = E0637)]
1043pub(crate) struct ExplicitAnonymousLifetimeReportError {
1044 #[primary_span]
1045 #[label("`'_` is a reserved lifetime name")]
1046 pub(crate) span: Span,
1047}
1048
1049#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ImplicitElidedLifetimeNotAllowedHere where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1050#[diag("implicit elided lifetime not allowed here", code = E0726)]
1051pub(crate) struct ImplicitElidedLifetimeNotAllowedHere {
1052 #[primary_span]
1053 pub(crate) span: Span,
1054 #[subdiagnostic]
1055 pub(crate) subdiag: ElidedLifetimeInPathSubdiag,
1056}
1057
1058#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnderscoreLifetimeIsReserved where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1059#[diag("`'_` cannot be used here", code = E0637)]
1060#[help("use another lifetime specifier")]
1061pub(crate) struct UnderscoreLifetimeIsReserved {
1062 #[primary_span]
1063 #[label("`'_` is a reserved lifetime name")]
1064 pub(crate) span: Span,
1065}
1066
1067#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StaticLifetimeIsReserved where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1068#[diag("invalid lifetime parameter name: `{$lifetime}`", code = E0262)]
1069pub(crate) struct StaticLifetimeIsReserved {
1070 #[primary_span]
1071 #[label("'static is a reserved lifetime name")]
1072 pub(crate) span: Span,
1073 pub(crate) lifetime: Ident,
1074}
1075
1076#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
VariableIsNotBoundInAllPatterns where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1077#[diag("variable `{$name}` is not bound in all patterns", code = E0408)]
1078pub(crate) struct VariableIsNotBoundInAllPatterns {
1079 #[primary_span]
1080 pub(crate) multispan: MultiSpan,
1081 pub(crate) name: Ident,
1082}
1083
1084#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for PatternDoesntBindName {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
PatternDoesntBindName { span: __binding_0, name: __binding_1
} => {
diag.store_args();
diag.arg("name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern doesn't bind `{$name}`")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::fmt::Debug for PatternDoesntBindName {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"PatternDoesntBindName", "span", &self.span, "name", &&self.name)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for PatternDoesntBindName {
#[inline]
fn clone(&self) -> PatternDoesntBindName {
PatternDoesntBindName {
span: ::core::clone::Clone::clone(&self.span),
name: ::core::clone::Clone::clone(&self.name),
}
}
}Clone)]
1085#[label("pattern doesn't bind `{$name}`")]
1086pub(crate) struct PatternDoesntBindName {
1087 #[primary_span]
1088 pub(crate) span: Span,
1089 pub(crate) name: Ident,
1090}
1091
1092#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for VariableNotInAllPatterns {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
VariableNotInAllPatterns { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable not in all patterns")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::fmt::Debug for VariableNotInAllPatterns {
#[inline]
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]
fn clone(&self) -> VariableNotInAllPatterns {
VariableNotInAllPatterns {
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone)]
1093#[label("variable not in all patterns")]
1094pub(crate) struct VariableNotInAllPatterns {
1095 #[primary_span]
1096 pub(crate) span: Span,
1097}
1098
1099#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for PatternBindingTypo {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
PatternBindingTypo { spans: __binding_0, typo: __binding_1 }
=> {
let mut suggestions = Vec::new();
let __code_27 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_27.clone()));
}
diag.store_args();
diag.arg("typo", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to use the similarly named previously used binding `{$typo}`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1100#[multipart_suggestion(
1101 "you might have meant to use the similarly named previously used binding `{$typo}`",
1102 applicability = "maybe-incorrect",
1103 style = "verbose"
1104)]
1105pub(crate) struct PatternBindingTypo {
1106 #[suggestion_part(code = "{typo}")]
1107 pub(crate) spans: Vec<Span>,
1108 pub(crate) typo: Symbol,
1109}
1110
1111#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NameDefinedMultipleTime where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1112#[diag("the name `{$name}` is defined multiple times")]
1113#[note("`{$name}` must be defined only once in the {$descr} namespace of this {$container}")]
1114pub(crate) struct NameDefinedMultipleTime {
1115 #[primary_span]
1116 pub(crate) span: Span,
1117 pub(crate) name: Symbol,
1118 pub(crate) descr: &'static str,
1119 pub(crate) container: &'static str,
1120 #[subdiagnostic]
1121 pub(crate) label: NameDefinedMultipleTimeLabel,
1122 #[subdiagnostic]
1123 pub(crate) old_binding_label: Option<NameDefinedMultipleTimeOldBindingLabel>,
1124}
1125
1126#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NameDefinedMultipleTimeLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NameDefinedMultipleTimeLabel::Reimported { span: __binding_0
} => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` reimported here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
NameDefinedMultipleTimeLabel::Redefined { span: __binding_0
} => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` redefined here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1127pub(crate) enum NameDefinedMultipleTimeLabel {
1128 #[label("`{$name}` reimported here")]
1129 Reimported {
1130 #[primary_span]
1131 span: Span,
1132 },
1133 #[label("`{$name}` redefined here")]
1134 Redefined {
1135 #[primary_span]
1136 span: Span,
1137 },
1138}
1139
1140#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
NameDefinedMultipleTimeOldBindingLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NameDefinedMultipleTimeOldBindingLabel::Import {
span: __binding_0, old_kind: __binding_1 } => {
diag.store_args();
diag.arg("old_kind", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous import of the {$old_kind} `{$name}` here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
NameDefinedMultipleTimeOldBindingLabel::Definition {
span: __binding_0, old_kind: __binding_1 } => {
diag.store_args();
diag.arg("old_kind", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous definition of the {$old_kind} `{$name}` here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1141pub(crate) enum NameDefinedMultipleTimeOldBindingLabel {
1142 #[label("previous import of the {$old_kind} `{$name}` here")]
1143 Import {
1144 #[primary_span]
1145 span: Span,
1146 old_kind: &'static str,
1147 },
1148 #[label("previous definition of the {$old_kind} `{$name}` here")]
1149 Definition {
1150 #[primary_span]
1151 span: Span,
1152 old_kind: &'static str,
1153 },
1154}
1155
1156#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
IsPrivate<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
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)]
1157#[diag("{$ident_descr} `{$ident}` is private", code = E0603)]
1158pub(crate) struct IsPrivate<'a> {
1159 #[primary_span]
1160 #[label("private {$ident_descr}")]
1161 pub(crate) span: Span,
1162 pub(crate) ident_descr: &'a str,
1163 pub(crate) ident: Ident,
1164}
1165
1166#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GenericArgumentsInMacroPath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1167#[diag("generic arguments in macro path")]
1168pub(crate) struct GenericArgumentsInMacroPath {
1169 #[primary_span]
1170 pub(crate) span: Span,
1171}
1172
1173#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributesStartingWithRustcAreReserved where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1174#[diag("attributes starting with `rustc` are reserved for use by the `rustc` compiler")]
1175pub(crate) struct AttributesStartingWithRustcAreReserved {
1176 #[primary_span]
1177 pub(crate) span: Span,
1178}
1179
1180#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotUseThroughAnImport where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1181#[diag("cannot use {$article} {$descr} through an import")]
1182pub(crate) struct CannotUseThroughAnImport {
1183 #[primary_span]
1184 pub(crate) span: Span,
1185 pub(crate) article: &'static str,
1186 pub(crate) descr: &'static str,
1187 #[note("the {$descr} imported here")]
1188 pub(crate) binding_span: Option<Span>,
1189}
1190
1191#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NameReservedInAttributeNamespace where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1192#[diag("name `{$ident}` is reserved in attribute namespace")]
1193pub(crate) struct NameReservedInAttributeNamespace {
1194 #[primary_span]
1195 pub(crate) span: Span,
1196 pub(crate) ident: Symbol,
1197}
1198
1199#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotFindBuiltinMacroWithName where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
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)]
1200#[diag("cannot find a built-in macro with name `{$ident}`")]
1201pub(crate) struct CannotFindBuiltinMacroWithName {
1202 #[primary_span]
1203 pub(crate) span: Span,
1204 pub(crate) ident: Ident,
1205}
1206
1207#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ToolWasAlreadyRegistered where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ToolWasAlreadyRegistered {
span: __binding_0,
tool: __binding_1,
old_ident_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("tool `{$tool}` was already registered")));
;
diag.arg("tool", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("already registered here")));
diag
}
}
}
}
};Diagnostic)]
1208#[diag("tool `{$tool}` was already registered")]
1209pub(crate) struct ToolWasAlreadyRegistered {
1210 #[primary_span]
1211 pub(crate) span: Span,
1212 pub(crate) tool: Ident,
1213 #[label("already registered here")]
1214 pub(crate) old_ident_span: Span,
1215}
1216
1217#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ToolOnlyAcceptsIdentifiers where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ToolOnlyAcceptsIdentifiers {
span: __binding_0, tool: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$tool}` only accepts identifiers")));
;
diag.arg("tool", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not an identifier")));
diag
}
}
}
}
};Diagnostic)]
1218#[diag("`{$tool}` only accepts identifiers")]
1219pub(crate) struct ToolOnlyAcceptsIdentifiers {
1220 #[primary_span]
1221 #[label("not an identifier")]
1222 pub(crate) span: Span,
1223 pub(crate) tool: Symbol,
1224}
1225
1226#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for DefinedHere {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
DefinedHere::SimilarlyNamed {
span: __binding_0,
candidate_descr: __binding_1,
candidate: __binding_2 } => {
diag.store_args();
diag.arg("candidate_descr", __binding_1);
diag.arg("candidate", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("similarly named {$candidate_descr} `{$candidate}` defined here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
DefinedHere::SingleItem {
span: __binding_0,
candidate_descr: __binding_1,
candidate: __binding_2 } => {
diag.store_args();
diag.arg("candidate_descr", __binding_1);
diag.arg("candidate", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$candidate_descr} `{$candidate}` defined here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1227pub(crate) enum DefinedHere {
1228 #[label("similarly named {$candidate_descr} `{$candidate}` defined here")]
1229 SimilarlyNamed {
1230 #[primary_span]
1231 span: Span,
1232 candidate_descr: &'static str,
1233 candidate: Symbol,
1234 },
1235 #[label("{$candidate_descr} `{$candidate}` defined here")]
1236 SingleItem {
1237 #[primary_span]
1238 span: Span,
1239 candidate_descr: &'static str,
1240 candidate: Symbol,
1241 },
1242}
1243
1244#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OuterIdentIsNotPubliclyReexported
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OuterIdentIsNotPubliclyReexported {
span: __binding_0,
outer_ident_descr: __binding_1,
outer_ident: __binding_2 } => {
diag.store_args();
diag.arg("outer_ident_descr", __binding_1);
diag.arg("outer_ident", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$outer_ident_descr} `{$outer_ident}` is not publicly re-exported")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1245#[label("{$outer_ident_descr} `{$outer_ident}` is not publicly re-exported")]
1246pub(crate) struct OuterIdentIsNotPubliclyReexported {
1247 #[primary_span]
1248 pub(crate) span: Span,
1249 pub(crate) outer_ident_descr: &'static str,
1250 pub(crate) outer_ident: Ident,
1251}
1252
1253#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ConstructorPrivateIfAnyFieldPrivate {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConstructorPrivateIfAnyFieldPrivate { span: __binding_0 } =>
{
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a constructor is private if any of the fields is private")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1254#[label("a constructor is private if any of the fields is private")]
1255pub(crate) struct ConstructorPrivateIfAnyFieldPrivate {
1256 #[primary_span]
1257 pub(crate) span: Span,
1258}
1259
1260#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ConsiderMakingTheFieldPublic {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConsiderMakingTheFieldPublic {
spans: __binding_0, number_of_fields: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_28 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub "))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_28.clone()));
}
diag.store_args();
diag.arg("number_of_fields", __binding_1);
let __message =
diag.eagerly_translate(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 }")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1261#[multipart_suggestion(
1262 "{ $number_of_fields ->
1263 [one] consider making the field publicly accessible
1264 *[other] consider making the fields publicly accessible
1265 }",
1266 applicability = "maybe-incorrect",
1267 style = "verbose"
1268)]
1269pub(crate) struct ConsiderMakingTheFieldPublic {
1270 #[suggestion_part(code = "pub ")]
1271 pub(crate) spans: Vec<Span>,
1272 pub(crate) number_of_fields: usize,
1273}
1274
1275#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImportIdent {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ImportIdent::ThroughReExport {
span: __binding_0, ident: __binding_1, path: __binding_2 }
=> {
let __code_29 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.store_args();
diag.arg("ident", __binding_1);
diag.arg("path", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("import `{$ident}` through the re-export")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_29, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
ImportIdent::Directly {
span: __binding_0, ident: __binding_1, path: __binding_2 }
=> {
let __code_30 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.store_args();
diag.arg("ident", __binding_1);
diag.arg("path", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("import `{$ident}` directly")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_30, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1276pub(crate) enum ImportIdent {
1277 #[suggestion(
1278 "import `{$ident}` through the re-export",
1279 code = "{path}",
1280 applicability = "machine-applicable",
1281 style = "verbose"
1282 )]
1283 ThroughReExport {
1284 #[primary_span]
1285 span: Span,
1286 ident: Ident,
1287 path: String,
1288 },
1289 #[suggestion(
1290 "import `{$ident}` directly",
1291 code = "{path}",
1292 applicability = "machine-applicable",
1293 style = "verbose"
1294 )]
1295 Directly {
1296 #[primary_span]
1297 span: Span,
1298 ident: Ident,
1299 path: String,
1300 },
1301}
1302
1303#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
NoteAndRefersToTheItemDefinedHere<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NoteAndRefersToTheItemDefinedHere {
span: __binding_0,
binding_descr: __binding_1,
binding_name: __binding_2,
first: __binding_3,
dots: __binding_4 } => {
diag.store_args();
diag.arg("binding_descr", __binding_1);
diag.arg("binding_name", __binding_2);
diag.arg("first", __binding_3);
diag.arg("dots", __binding_4);
let __message =
diag.eagerly_translate(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 }")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1304#[note(
1305 "{$first ->
1306 [true] {$dots ->
1307 [true] the {$binding_descr} `{$binding_name}` is defined here...
1308 *[false] the {$binding_descr} `{$binding_name}` is defined here
1309 }
1310 *[false] {$dots ->
1311 [true] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here...
1312 *[false] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here
1313 }
1314 }"
1315)]
1316pub(crate) struct NoteAndRefersToTheItemDefinedHere<'a> {
1317 #[primary_span]
1318 pub(crate) span: MultiSpan,
1319 pub(crate) binding_descr: &'a str,
1320 pub(crate) binding_name: Ident,
1321 pub(crate) first: bool,
1322 pub(crate) dots: bool,
1323}
1324
1325#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RemoveUnnecessaryImport {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RemoveUnnecessaryImport { span: __binding_0 } => {
let __code_31 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove unnecessary import")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_31, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1326#[suggestion("remove unnecessary import", code = "", applicability = "maybe-incorrect")]
1327pub(crate) struct RemoveUnnecessaryImport {
1328 #[primary_span]
1329 pub(crate) span: Span,
1330}
1331
1332#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ToolOnlyRemoveUnnecessaryImport {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ToolOnlyRemoveUnnecessaryImport { span: __binding_0 } => {
let __code_32 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove unnecessary import")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_32, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1333#[suggestion(
1334 "remove unnecessary import",
1335 code = "",
1336 applicability = "maybe-incorrect",
1337 style = "tool-only"
1338)]
1339pub(crate) struct ToolOnlyRemoveUnnecessaryImport {
1340 #[primary_span]
1341 pub(crate) span: Span,
1342}
1343
1344#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
IdentImporterHereButItIsDesc<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IdentImporterHereButItIsDesc {
span: __binding_0,
imported_ident: __binding_1,
imported_ident_desc: __binding_2 } => {
diag.store_args();
diag.arg("imported_ident", __binding_1);
diag.arg("imported_ident_desc", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$imported_ident}` is imported here, but it is {$imported_ident_desc}")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1345#[note("`{$imported_ident}` is imported here, but it is {$imported_ident_desc}")]
1346pub(crate) struct IdentImporterHereButItIsDesc<'a> {
1347 #[primary_span]
1348 pub(crate) span: Span,
1349 pub(crate) imported_ident: Ident,
1350 pub(crate) imported_ident_desc: &'a str,
1351}
1352
1353#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for IdentInScopeButItIsDesc<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IdentInScopeButItIsDesc {
imported_ident: __binding_0,
imported_ident_desc: __binding_1 } => {
diag.store_args();
diag.arg("imported_ident", __binding_0);
diag.arg("imported_ident_desc", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$imported_ident}` is in scope, but it is {$imported_ident_desc}")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1354#[note("`{$imported_ident}` is in scope, but it is {$imported_ident_desc}")]
1355pub(crate) struct IdentInScopeButItIsDesc<'a> {
1356 pub(crate) imported_ident: Ident,
1357 pub(crate) imported_ident_desc: &'a str,
1358}
1359
1360pub(crate) struct FoundItemConfigureOut {
1361 pub(crate) span: Span,
1362 pub(crate) item_was: ItemWas,
1363}
1364
1365pub(crate) enum ItemWas {
1366 BehindFeature { feature: Symbol, span: Span },
1367 CfgOut { span: Span },
1368}
1369
1370impl Subdiagnostic for FoundItemConfigureOut {
1371 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1372 let mut multispan: MultiSpan = self.span.into();
1373 match self.item_was {
1374 ItemWas::BehindFeature { feature, span } => {
1375 let key = "feature".into();
1376 let value = feature.into_diag_arg(&mut None);
1377 let msg = diag.dcx.eagerly_translate_to_string(
1378 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the item is gated behind the `{$feature}` feature"))inline_fluent!("the item is gated behind the `{$feature}` feature"),
1379 [(&key, &value)].into_iter(),
1380 );
1381 multispan.push_span_label(span, msg);
1382 }
1383 ItemWas::CfgOut { span } => {
1384 multispan.push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the item is gated here"))inline_fluent!("the item is gated here"));
1385 }
1386 }
1387 diag.span_note(multispan, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found an item that was configured out"))inline_fluent!("found an item that was configured out"));
1388 }
1389}
1390
1391#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitImplMismatch where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraitImplMismatch {
span: __binding_0,
name: __binding_1,
kind: __binding_2,
trait_path: __binding_3,
trait_item_span: __binding_4 } => {
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
}
}
}
}
};Diagnostic)]
1392#[diag("item `{$name}` is an associated {$kind}, which doesn't match its trait `{$trait_path}`")]
1393pub(crate) struct TraitImplMismatch {
1394 #[primary_span]
1395 #[label("does not match trait")]
1396 pub(crate) span: Span,
1397 pub(crate) name: Ident,
1398 pub(crate) kind: &'static str,
1399 pub(crate) trait_path: String,
1400 #[label("item in trait")]
1401 pub(crate) trait_item_span: Span,
1402}
1403
1404#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
LegacyDeriveHelpers {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
LegacyDeriveHelpers { span: __binding_0 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
1405#[diag("derive helper attribute is used before it is introduced")]
1406pub(crate) struct LegacyDeriveHelpers {
1407 #[label("the attribute is introduced here")]
1408 pub span: Span,
1409}
1410
1411#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnusedExternCrate {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnusedExternCrate {
span: __binding_0, removal_span: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused extern crate")));
;
let __code_33 =
[::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_33, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
};
}
}
};LintDiagnostic)]
1412#[diag("unused extern crate")]
1413pub(crate) struct UnusedExternCrate {
1414 #[label("unused")]
1415 pub span: Span,
1416 #[suggestion(
1417 "remove the unused `extern crate`",
1418 code = "",
1419 applicability = "machine-applicable",
1420 style = "verbose"
1421 )]
1422 pub removal_span: Span,
1423}
1424
1425#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
ReexportPrivateDependency {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
ReexportPrivateDependency {
name: __binding_0, kind: __binding_1, krate: __binding_2 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
1426#[diag("{$kind} `{$name}` from private dependency '{$krate}' is re-exported")]
1427pub(crate) struct ReexportPrivateDependency {
1428 pub name: Symbol,
1429 pub kind: &'static str,
1430 pub krate: Symbol,
1431}
1432
1433#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for UnusedLabel {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnusedLabel => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused label")));
;
diag
}
};
}
}
};LintDiagnostic)]
1434#[diag("unused label")]
1435pub(crate) struct UnusedLabel;
1436
1437#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for UnusedMacroUse {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnusedMacroUse => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused `#[macro_use]` import")));
;
diag
}
};
}
}
};LintDiagnostic)]
1438#[diag("unused `#[macro_use]` import")]
1439pub(crate) struct UnusedMacroUse;
1440
1441#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
MacroUseDeprecated {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MacroUseDeprecated => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
1442#[diag("applying the `#[macro_use]` attribute to an `extern crate` item is deprecated")]
1443#[help("remove it and import macros at use sites with a `use` item instead")]
1444pub(crate) struct MacroUseDeprecated;
1445
1446#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for MacroIsPrivate {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MacroIsPrivate { ident: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro `{$ident}` is private")));
;
diag.arg("ident", __binding_0);
diag
}
};
}
}
};LintDiagnostic)]
1447#[diag("macro `{$ident}` is private")]
1448pub(crate) struct MacroIsPrivate {
1449 pub ident: Ident,
1450}
1451
1452#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnusedMacroDefinition {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnusedMacroDefinition { name: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused macro definition: `{$name}`")));
;
diag.arg("name", __binding_0);
diag
}
};
}
}
};LintDiagnostic)]
1453#[diag("unused macro definition: `{$name}`")]
1454pub(crate) struct UnusedMacroDefinition {
1455 pub name: Symbol,
1456}
1457
1458#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
MacroRuleNeverUsed {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MacroRuleNeverUsed { n: __binding_0, name: __binding_1 } =>
{
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
1459#[diag("rule #{$n} of macro `{$name}` is never used")]
1460pub(crate) struct MacroRuleNeverUsed {
1461 pub n: usize,
1462 pub name: Symbol,
1463}
1464
1465pub(crate) struct UnstableFeature {
1466 pub msg: DiagMessage,
1467}
1468
1469impl<'a> LintDiagnostic<'a, ()> for UnstableFeature {
1470 fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
1471 diag.primary_message(self.msg);
1472 }
1473}
1474
1475#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
ExternCrateNotIdiomatic {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
ExternCrateNotIdiomatic {
span: __binding_0, code: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern crate` is not idiomatic in the new edition")));
;
let __code_34 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.arg("code", __binding_1);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert it to a `use`")),
__code_34, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
};
}
}
};LintDiagnostic)]
1476#[diag("`extern crate` is not idiomatic in the new edition")]
1477pub(crate) struct ExternCrateNotIdiomatic {
1478 #[suggestion(
1479 "convert it to a `use`",
1480 style = "verbose",
1481 code = "{code}",
1482 applicability = "machine-applicable"
1483 )]
1484 pub span: Span,
1485 pub code: &'static str,
1486}
1487
1488#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
OutOfScopeMacroCalls {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
OutOfScopeMacroCalls {
span: __binding_0, path: __binding_1, location: __binding_2
} => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
1489#[diag("cannot find macro `{$path}` in the current scope when looking from {$location}")]
1490#[help("import `macro_rules` with `use` to make it callable above its definition")]
1491pub(crate) struct OutOfScopeMacroCalls {
1492 #[label("not found from {$location}")]
1493 pub span: Span,
1494 pub path: String,
1495 pub location: String,
1496}
1497
1498#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
RedundantImportVisibility {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
RedundantImportVisibility {
span: __binding_0,
help: __binding_1,
import_vis: __binding_2,
max_vis: __binding_3 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
1499#[diag(
1500 "glob import doesn't reexport anything with visibility `{$import_vis}` because no imported item is public enough"
1501)]
1502pub(crate) struct RedundantImportVisibility {
1503 #[note("the most public imported item is `{$max_vis}`")]
1504 pub span: Span,
1505 #[help("reduce the glob import's visibility or increase visibility of imported items")]
1506 pub help: (),
1507 pub import_vis: String,
1508 pub max_vis: String,
1509}
1510
1511#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnknownDiagnosticAttribute {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnknownDiagnosticAttribute { typo: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown diagnostic attribute")));
;
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag
}
};
}
}
};LintDiagnostic)]
1512#[diag("unknown diagnostic attribute")]
1513pub(crate) struct UnknownDiagnosticAttribute {
1514 #[subdiagnostic]
1515 pub typo: Option<UnknownDiagnosticAttributeTypoSugg>,
1516}
1517
1518#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
UnknownDiagnosticAttributeTypoSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownDiagnosticAttributeTypoSugg {
span: __binding_0, typo_name: __binding_1 } => {
let __code_35 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("typo_name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an attribute with a similar name exists")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_35, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1519#[suggestion(
1520 "an attribute with a similar name exists",
1521 style = "verbose",
1522 code = "{typo_name}",
1523 applicability = "machine-applicable"
1524)]
1525pub(crate) struct UnknownDiagnosticAttributeTypoSugg {
1526 #[primary_span]
1527 pub span: Span,
1528 pub typo_name: Symbol,
1529}
1530
1531pub(crate) struct Ambiguity {
1533 pub ident: Ident,
1534 pub ambig_vis: Option<String>,
1535 pub kind: &'static str,
1536 pub help: Option<&'static [&'static str]>,
1537 pub b1_note: Spanned<String>,
1538 pub b1_help_msgs: Vec<String>,
1539 pub b2_note: Spanned<String>,
1540 pub b2_help_msgs: Vec<String>,
1541}
1542
1543impl Ambiguity {
1544 fn decorate<'a>(self, diag: &mut Diag<'a, impl EmissionGuarantee>) {
1545 if let Some(ambig_vis) = self.ambig_vis {
1546 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ambiguous import visibility: {0}",
ambig_vis))
})format!("ambiguous import visibility: {ambig_vis}"));
1547 } else {
1548 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}` is ambiguous", self.ident))
})format!("`{}` is ambiguous", self.ident));
1549 diag.span_label(self.ident.span, "ambiguous name");
1550 }
1551 diag.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ambiguous because of {0}",
self.kind))
})format!("ambiguous because of {}", self.kind));
1552 diag.span_note(self.b1_note.span, self.b1_note.node);
1553 if let Some(help) = self.help {
1554 for help in help {
1555 diag.help(*help);
1556 }
1557 }
1558 for help_msg in self.b1_help_msgs {
1559 diag.help(help_msg);
1560 }
1561 diag.span_note(self.b2_note.span, self.b2_note.node);
1562 for help_msg in self.b2_help_msgs {
1563 diag.help(help_msg);
1564 }
1565 }
1566}
1567
1568impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for Ambiguity {
1569 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1570 let mut diag = Diag::new(dcx, level, "").with_span(self.ident.span).with_code(E0659);
1571 self.decorate(&mut diag);
1572 diag
1573 }
1574}
1575
1576impl<'a> LintDiagnostic<'a, ()> for Ambiguity {
1577 fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
1578 self.decorate(diag);
1579 }
1580}