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 __binding_3 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(generic_const_exprs)]` to allow generic const expressions")));
}
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 #[help("add `#![feature(generic_const_exprs)]` to allow generic const expressions")]
433 pub(crate) help: bool,
434}
435
436#[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)]
437#[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)]
438pub(crate) enum ParamKindInNonTrivialAnonConst {
439 #[note("type parameters may not be used in const expressions")]
440 Type,
441 #[help("const parameters may only be used as standalone arguments here, i.e. `{$name}`")]
442 Const { name: Symbol },
443 #[note("lifetime parameters may not be used in const expressions")]
444 Lifetime,
445}
446
447#[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)]
448#[diag("use of unreachable label `{$name}`", code = E0767)]
449#[note("labels are unreachable through functions, closures, async blocks and modules")]
450pub(crate) struct UnreachableLabel {
451 #[primary_span]
452 #[label("unreachable label `{$name}`")]
453 pub(crate) span: Span,
454 pub(crate) name: Symbol,
455 #[label("unreachable label defined here")]
456 pub(crate) definition_span: Span,
457 #[subdiagnostic]
458 pub(crate) sub_suggestion: Option<UnreachableLabelSubSuggestion>,
459 #[subdiagnostic]
460 pub(crate) sub_suggestion_label: Option<UnreachableLabelSubLabel>,
461 #[subdiagnostic]
462 pub(crate) sub_unreachable_label: Option<UnreachableLabelSubLabelUnreachable>,
463}
464
465#[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)]
466#[suggestion(
467 "try using similarly named label",
468 code = "{ident_name}",
469 applicability = "maybe-incorrect"
470)]
471pub(crate) struct UnreachableLabelSubSuggestion {
472 #[primary_span]
473 pub(crate) span: Span,
474 pub(crate) ident_name: Symbol,
475}
476
477#[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)]
478#[label("a label with a similar name is reachable")]
479pub(crate) struct UnreachableLabelSubLabel {
480 #[primary_span]
481 pub(crate) ident_span: Span,
482}
483
484#[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)]
485#[label("a label with a similar name exists but is also unreachable")]
486pub(crate) struct UnreachableLabelSubLabelUnreachable {
487 #[primary_span]
488 pub(crate) ident_span: Span,
489}
490
491#[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)]
492#[diag("invalid `sym` operand")]
493#[help("`sym` operands must refer to either a function or a static")]
494pub(crate) struct InvalidAsmSym {
495 #[primary_span]
496 #[label("is a local variable")]
497 pub(crate) span: Span,
498}
499
500#[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)]
501#[diag("attempt to use a non-constant value in a constant")]
502pub(crate) struct LowercaseSelf {
503 #[primary_span]
504 #[suggestion(
505 "try using `Self`",
506 code = "Self",
507 applicability = "maybe-incorrect",
508 style = "short"
509 )]
510 pub(crate) span: Span,
511}
512
513#[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)]
514#[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)]
515#[diag("never patterns cannot contain variable bindings")]
516pub(crate) struct BindingInNeverPattern {
517 #[primary_span]
518 #[suggestion(
519 "use a wildcard `_` instead",
520 code = "_",
521 applicability = "machine-applicable",
522 style = "short"
523 )]
524 pub(crate) span: Span,
525}
526
527#[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)]
528#[diag("duplicate definitions with name `{$name}`:", code = E0201)]
529pub(crate) struct TraitImplDuplicate {
530 #[primary_span]
531 #[label("duplicate definition")]
532 pub(crate) span: Span,
533 #[label("previous definition here")]
534 pub(crate) old_span: Span,
535 #[label("item in trait")]
536 pub(crate) trait_item_span: Span,
537 pub(crate) name: Ident,
538}
539
540#[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)]
541#[diag("relative paths are not supported in visibilities in 2018 edition or later")]
542pub(crate) struct Relative2018 {
543 #[primary_span]
544 pub(crate) span: Span,
545 #[suggestion("try", code = "crate::{path_str}", applicability = "maybe-incorrect")]
546 pub(crate) path_span: Span,
547 pub(crate) path_str: String,
548}
549
550#[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)]
551#[diag("visibilities can only be restricted to ancestor modules", code = E0742)]
552pub(crate) struct AncestorOnly(#[primary_span] pub(crate) Span);
553
554#[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)]
555#[diag("expected module, found {$res} `{$path_str}`", code = E0577)]
556pub(crate) struct ExpectedModuleFound {
557 #[primary_span]
558 #[label("not a module")]
559 pub(crate) span: Span,
560 pub(crate) res: Res,
561 pub(crate) path_str: String,
562}
563
564#[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)]
565#[diag("cannot determine resolution for the visibility", code = E0578)]
566pub(crate) struct Indeterminate(#[primary_span] pub(crate) Span);
567
568#[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)]
569#[diag("cannot use a tool module through an import")]
570pub(crate) struct ToolModuleImported {
571 #[primary_span]
572 pub(crate) span: Span,
573 #[note("the tool module imported here")]
574 pub(crate) import: Span,
575}
576
577#[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)]
578#[diag("visibility must resolve to a module")]
579pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span);
580
581#[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)]
582#[diag("expected {$expected}, found {$found} `{$macro_path}`")]
583pub(crate) struct MacroExpectedFound<'a> {
584 #[primary_span]
585 #[label("not {$article} {$expected}")]
586 pub(crate) span: Span,
587 pub(crate) found: &'a str,
588 pub(crate) article: &'static str,
589 pub(crate) expected: &'a str,
590 pub(crate) macro_path: &'a str,
591 #[subdiagnostic]
592 pub(crate) remove_surrounding_derive: Option<RemoveSurroundingDerive>,
593 #[subdiagnostic]
594 pub(crate) add_as_non_derive: Option<AddAsNonDerive<'a>>,
595}
596
597#[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)]
598#[help("remove from the surrounding `derive()`")]
599pub(crate) struct RemoveSurroundingDerive {
600 #[primary_span]
601 pub(crate) span: Span,
602}
603
604#[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)]
605#[help(
606 "
607 add as non-Derive macro
608 `#[{$macro_path}]`"
609)]
610pub(crate) struct AddAsNonDerive<'a> {
611 pub(crate) macro_path: &'a str,
612}
613
614#[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)]
615#[diag("can't use a procedural macro from the same crate that defines it")]
616pub(crate) struct ProcMacroSameCrate {
617 #[primary_span]
618 pub(crate) span: Span,
619 #[help("you can define integration tests in a directory named `tests`")]
620 pub(crate) is_test: bool,
621}
622
623#[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)]
624#[diag("cannot find {$ns_descr} `{$ident}` in this scope")]
625pub(crate) struct ProcMacroDeriveResolutionFallback {
626 #[label("names from parent modules are not accessible without an explicit import")]
627 pub span: Span,
628 pub ns_descr: &'static str,
629 pub ident: Symbol,
630}
631
632#[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)]
633#[diag(
634 "macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"
635)]
636pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths {
637 #[note("the macro is defined here")]
638 pub definition: Span,
639}
640
641#[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)]
642#[diag("`$crate` may not be imported")]
643pub(crate) struct CrateImported {
644 #[primary_span]
645 pub(crate) span: Span,
646}
647
648#[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)]
649#[diag("`#[macro_use]` is not supported on `extern crate self`")]
650pub(crate) struct MacroUseExternCrateSelf {
651 #[primary_span]
652 pub(crate) span: Span,
653}
654
655#[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)]
656#[diag("not sure whether the path is accessible or not")]
657#[note("the type may have associated items, but we are currently not checking them")]
658pub(crate) struct CfgAccessibleUnsure {
659 #[primary_span]
660 pub(crate) span: Span,
661}
662
663#[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)]
664#[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)]
665#[diag("generic parameters may not be used in enum discriminant values")]
666pub(crate) struct ParamInEnumDiscriminant {
667 #[primary_span]
668 #[label("cannot perform const operation using `{$name}`")]
669 pub(crate) span: Span,
670 pub(crate) name: Symbol,
671 #[subdiagnostic]
672 pub(crate) param_kind: ParamKindInEnumDiscriminant,
673}
674
675#[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)]
676#[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)]
677pub(crate) enum ParamKindInEnumDiscriminant {
678 #[note("type parameters may not be used in enum discriminant values")]
679 Type,
680 #[note("const parameters may not be used in enum discriminant values")]
681 Const,
682 #[note("lifetime parameters may not be used in enum discriminant values")]
683 Lifetime,
684}
685
686#[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)]
687#[label("you can use `as` to change the binding name of the import")]
688pub(crate) struct ChangeImportBinding {
689 #[primary_span]
690 pub(crate) span: Span,
691}
692
693#[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)]
694#[suggestion(
695 "you can use `as` to change the binding name of the import",
696 code = "{suggestion}",
697 applicability = "maybe-incorrect"
698)]
699pub(crate) struct ChangeImportBindingSuggestion {
700 #[primary_span]
701 pub(crate) span: Span,
702 pub(crate) suggestion: String,
703}
704
705#[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)]
706#[diag("imports cannot refer to {$what}")]
707pub(crate) struct ImportsCannotReferTo<'a> {
708 #[primary_span]
709 pub(crate) span: Span,
710 pub(crate) what: &'a str,
711}
712
713#[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)]
714#[diag("cannot find {$expected} `{$ident}` in this scope")]
715pub(crate) struct CannotFindIdentInThisScope<'a> {
716 #[primary_span]
717 pub(crate) span: Span,
718 pub(crate) expected: &'a str,
719 pub(crate) ident: Ident,
720}
721
722#[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)]
723#[note("unsafe traits like `{$ident}` should be implemented explicitly")]
724pub(crate) struct ExplicitUnsafeTraits {
725 #[primary_span]
726 pub(crate) span: Span,
727 pub(crate) ident: Ident,
728}
729
730#[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)]
731#[note("a macro with the same name exists, but it appears later")]
732pub(crate) struct MacroDefinedLater {
733 #[primary_span]
734 pub(crate) span: Span,
735}
736
737#[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)]
738#[label("consider moving the definition of `{$ident}` before this call")]
739pub(crate) struct MacroSuggMovePosition {
740 #[primary_span]
741 pub(crate) span: Span,
742 pub(crate) ident: Ident,
743}
744
745#[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)]
746pub(crate) enum MacroRulesNot {
747 #[label("`{$ident}` exists, but has no rules for function-like invocation")]
748 Func {
749 #[primary_span]
750 span: Span,
751 ident: Ident,
752 },
753 #[label("`{$ident}` exists, but has no `attr` rules")]
754 Attr {
755 #[primary_span]
756 span: Span,
757 ident: Ident,
758 },
759 #[label("`{$ident}` exists, but has no `derive` rules")]
760 Derive {
761 #[primary_span]
762 span: Span,
763 ident: Ident,
764 },
765}
766
767#[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)]
768#[note("maybe you have forgotten to define a name for this `macro_rules!`")]
769pub(crate) struct MaybeMissingMacroRulesName {
770 #[primary_span]
771 pub(crate) spans: MultiSpan,
772}
773
774#[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)]
775#[help("have you added the `#[macro_use]` on the module/import?")]
776pub(crate) struct AddedMacroUse;
777
778#[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)]
779#[suggestion("consider adding a derive", code = "{suggestion}", applicability = "maybe-incorrect")]
780pub(crate) struct ConsiderAddingADerive {
781 #[primary_span]
782 pub(crate) span: Span,
783 pub(crate) suggestion: String,
784}
785
786#[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)]
787#[diag("cannot determine resolution for the import")]
788pub(crate) struct CannotDetermineImportResolution {
789 #[primary_span]
790 pub(crate) span: Span,
791}
792
793#[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)]
794#[diag("cannot determine resolution for the {$kind} `{$path}`")]
795#[note("import resolution is stuck, try simplifying macro imports")]
796pub(crate) struct CannotDetermineMacroResolution {
797 #[primary_span]
798 pub(crate) span: Span,
799 pub(crate) kind: &'static str,
800 pub(crate) path: String,
801}
802
803#[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)]
804#[diag("`{$ident}` is private, and cannot be re-exported", code = E0364)]
805pub(crate) struct CannotBeReexportedPrivate {
806 #[primary_span]
807 pub(crate) span: Span,
808 pub(crate) ident: Ident,
809}
810
811#[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)]
812#[diag("`{$ident}` is only public within the crate, and cannot be re-exported outside", code = E0364)]
813pub(crate) struct CannotBeReexportedCratePublic {
814 #[primary_span]
815 pub(crate) span: Span,
816 pub(crate) ident: Ident,
817}
818
819#[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)]
820#[diag("`{$ident}` is private, and cannot be re-exported", code = E0365)]
821#[note("consider declaring type or module `{$ident}` with `pub`")]
822pub(crate) struct CannotBeReexportedPrivateNS {
823 #[primary_span]
824 #[label("re-export of private `{$ident}`")]
825 pub(crate) span: Span,
826 pub(crate) ident: Ident,
827}
828
829#[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)]
830#[diag("`{$ident}` is only public within the crate, and cannot be re-exported outside", code = E0365)]
831#[note("consider declaring type or module `{$ident}` with `pub`")]
832pub(crate) struct CannotBeReexportedCratePublicNS {
833 #[primary_span]
834 #[label("re-export of crate public `{$ident}`")]
835 pub(crate) span: Span,
836 pub(crate) ident: Ident,
837}
838
839#[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)]
840#[diag("extern crate `{$ident}` is private and cannot be re-exported", code = E0365)]
841pub(crate) struct PrivateExternCrateReexport {
842 pub ident: Ident,
843 #[suggestion(
844 "consider making the `extern crate` item publicly accessible",
845 code = "pub ",
846 style = "verbose",
847 applicability = "maybe-incorrect"
848 )]
849 pub sugg: Span,
850}
851
852#[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)]
853#[help("consider adding a `#[macro_export]` to the macro in the imported module")]
854pub(crate) struct ConsiderAddingMacroExport {
855 #[primary_span]
856 pub(crate) span: Span,
857}
858
859#[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)]
860#[suggestion(
861 "in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)`",
862 code = "pub(crate)",
863 applicability = "maybe-incorrect"
864)]
865pub(crate) struct ConsiderMarkingAsPubCrate {
866 #[primary_span]
867 pub(crate) vis_span: Span,
868}
869
870#[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)]
871#[note("consider marking `{$ident}` as `pub` in the imported module")]
872pub(crate) struct ConsiderMarkingAsPub {
873 #[primary_span]
874 pub(crate) span: Span,
875 pub(crate) ident: Ident,
876}
877
878#[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)]
879#[diag("cannot glob-import all possible crates")]
880pub(crate) struct CannotGlobImportAllCrates {
881 #[primary_span]
882 pub(crate) span: Span,
883}
884
885#[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)]
886#[suggestion(
887 "you might have meant to write a const parameter here",
888 code = "const ",
889 style = "verbose"
890)]
891pub(crate) struct UnexpectedResChangeTyToConstParamSugg {
892 #[primary_span]
893 pub span: Span,
894 #[applicability]
895 pub applicability: Applicability,
896}
897
898#[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)]
899#[multipart_suggestion(
900 "you might have meant to write a const parameter here",
901 applicability = "has-placeholders",
902 style = "verbose"
903)]
904pub(crate) struct UnexpectedResChangeTyParamToConstParamSugg {
905 #[suggestion_part(code = "const ")]
906 pub before: Span,
907 #[suggestion_part(code = ": /* Type */")]
908 pub after: Span,
909}
910
911#[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)]
912#[suggestion(
913 "if you meant to collect the rest of the slice in `{$ident}`, use the at operator",
914 code = "{snippet}",
915 applicability = "maybe-incorrect",
916 style = "verbose"
917)]
918pub(crate) struct UnexpectedResUseAtOpInSlicePatWithRangeSugg {
919 #[primary_span]
920 pub span: Span,
921 pub ident: Ident,
922 pub snippet: String,
923}
924
925#[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)]
926#[diag("an `extern crate` loading macros must be at the crate root", code = E0468)]
927pub(crate) struct ExternCrateLoadingMacroNotAtCrateRoot {
928 #[primary_span]
929 pub(crate) span: Span,
930}
931
932#[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)]
933#[diag("`extern crate self;` requires renaming")]
934pub(crate) struct ExternCrateSelfRequiresRenaming {
935 #[primary_span]
936 #[suggestion(
937 "rename the `self` crate to be able to import it",
938 code = "extern crate self as name;",
939 applicability = "has-placeholders"
940 )]
941 pub(crate) span: Span,
942}
943
944#[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)]
945#[diag("`{$name}` is already in scope")]
946#[note("macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)")]
947pub(crate) struct MacroUseNameAlreadyInUse {
948 #[primary_span]
949 pub(crate) span: Span,
950 pub(crate) name: Symbol,
951}
952
953#[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)]
954#[diag("imported macro not found", code = E0469)]
955pub(crate) struct ImportedMacroNotFound {
956 #[primary_span]
957 pub(crate) span: Span,
958}
959
960#[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)]
961#[diag("`#[macro_escape]` is a deprecated synonym for `#[macro_use]`")]
962pub(crate) struct MacroExternDeprecated {
963 #[primary_span]
964 pub(crate) span: Span,
965 #[help("try an outer attribute: `#[macro_use]`")]
966 pub inner_attribute: bool,
967}
968
969#[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)]
970#[diag("arguments to `macro_use` are not allowed here")]
971pub(crate) struct ArgumentsMacroUseNotAllowed {
972 #[primary_span]
973 pub(crate) span: Span,
974}
975
976#[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)]
977#[diag("crate root imports need to be explicitly named: `use crate as name;`")]
978pub(crate) struct UnnamedCrateRootImport {
979 #[primary_span]
980 pub(crate) span: Span,
981}
982
983#[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)]
984#[diag("macro-expanded `extern crate` items cannot shadow names passed with `--extern`")]
985pub(crate) struct MacroExpandedExternCrateCannotShadowExternArguments {
986 #[primary_span]
987 pub(crate) span: Span,
988}
989
990#[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)]
991#[diag("`&` without an explicit lifetime name cannot be used here", code = E0637)]
992pub(crate) struct ElidedAnonymousLifetimeReportError {
993 #[primary_span]
994 #[label("explicit lifetime name needed here")]
995 pub(crate) span: Span,
996 #[subdiagnostic]
997 pub(crate) suggestion: Option<ElidedAnonymousLifetimeReportErrorSuggestion>,
998}
999
1000#[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)]
1001#[diag(
1002 "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"
1003)]
1004pub(crate) struct LendingIteratorReportError {
1005 #[primary_span]
1006 pub(crate) lifetime: Span,
1007 #[note(
1008 "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"
1009 )]
1010 pub(crate) ty: Span,
1011}
1012
1013#[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)]
1014#[diag("missing lifetime in associated type")]
1015pub(crate) struct AnonymousLifetimeNonGatReportError {
1016 #[primary_span]
1017 #[label("this lifetime must come from the implemented type")]
1018 pub(crate) lifetime: Span,
1019 #[note(
1020 "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"
1021 )]
1022 pub(crate) decl: MultiSpan,
1023}
1024
1025#[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)]
1026#[multipart_suggestion(
1027 "consider introducing a higher-ranked lifetime here",
1028 applicability = "machine-applicable"
1029)]
1030pub(crate) struct ElidedAnonymousLifetimeReportErrorSuggestion {
1031 #[suggestion_part(code = "for<'a> ")]
1032 pub(crate) lo: Span,
1033 #[suggestion_part(code = "'a ")]
1034 pub(crate) hi: Span,
1035}
1036
1037#[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)]
1038#[diag("`'_` cannot be used here", code = E0637)]
1039pub(crate) struct ExplicitAnonymousLifetimeReportError {
1040 #[primary_span]
1041 #[label("`'_` is a reserved lifetime name")]
1042 pub(crate) span: Span,
1043}
1044
1045#[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)]
1046#[diag("implicit elided lifetime not allowed here", code = E0726)]
1047pub(crate) struct ImplicitElidedLifetimeNotAllowedHere {
1048 #[primary_span]
1049 pub(crate) span: Span,
1050 #[subdiagnostic]
1051 pub(crate) subdiag: ElidedLifetimeInPathSubdiag,
1052}
1053
1054#[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)]
1055#[diag("`'_` cannot be used here", code = E0637)]
1056#[help("use another lifetime specifier")]
1057pub(crate) struct UnderscoreLifetimeIsReserved {
1058 #[primary_span]
1059 #[label("`'_` is a reserved lifetime name")]
1060 pub(crate) span: Span,
1061}
1062
1063#[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)]
1064#[diag("invalid lifetime parameter name: `{$lifetime}`", code = E0262)]
1065pub(crate) struct StaticLifetimeIsReserved {
1066 #[primary_span]
1067 #[label("'static is a reserved lifetime name")]
1068 pub(crate) span: Span,
1069 pub(crate) lifetime: Ident,
1070}
1071
1072#[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)]
1073#[diag("variable `{$name}` is not bound in all patterns", code = E0408)]
1074pub(crate) struct VariableIsNotBoundInAllPatterns {
1075 #[primary_span]
1076 pub(crate) multispan: MultiSpan,
1077 pub(crate) name: Ident,
1078}
1079
1080#[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)]
1081#[label("pattern doesn't bind `{$name}`")]
1082pub(crate) struct PatternDoesntBindName {
1083 #[primary_span]
1084 pub(crate) span: Span,
1085 pub(crate) name: Ident,
1086}
1087
1088#[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)]
1089#[label("variable not in all patterns")]
1090pub(crate) struct VariableNotInAllPatterns {
1091 #[primary_span]
1092 pub(crate) span: Span,
1093}
1094
1095#[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)]
1096#[multipart_suggestion(
1097 "you might have meant to use the similarly named previously used binding `{$typo}`",
1098 applicability = "maybe-incorrect",
1099 style = "verbose"
1100)]
1101pub(crate) struct PatternBindingTypo {
1102 #[suggestion_part(code = "{typo}")]
1103 pub(crate) spans: Vec<Span>,
1104 pub(crate) typo: Symbol,
1105}
1106
1107#[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)]
1108#[diag("the name `{$name}` is defined multiple times")]
1109#[note("`{$name}` must be defined only once in the {$descr} namespace of this {$container}")]
1110pub(crate) struct NameDefinedMultipleTime {
1111 #[primary_span]
1112 pub(crate) span: Span,
1113 pub(crate) name: Symbol,
1114 pub(crate) descr: &'static str,
1115 pub(crate) container: &'static str,
1116 #[subdiagnostic]
1117 pub(crate) label: NameDefinedMultipleTimeLabel,
1118 #[subdiagnostic]
1119 pub(crate) old_binding_label: Option<NameDefinedMultipleTimeOldBindingLabel>,
1120}
1121
1122#[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)]
1123pub(crate) enum NameDefinedMultipleTimeLabel {
1124 #[label("`{$name}` reimported here")]
1125 Reimported {
1126 #[primary_span]
1127 span: Span,
1128 },
1129 #[label("`{$name}` redefined here")]
1130 Redefined {
1131 #[primary_span]
1132 span: Span,
1133 },
1134}
1135
1136#[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)]
1137pub(crate) enum NameDefinedMultipleTimeOldBindingLabel {
1138 #[label("previous import of the {$old_kind} `{$name}` here")]
1139 Import {
1140 #[primary_span]
1141 span: Span,
1142 old_kind: &'static str,
1143 },
1144 #[label("previous definition of the {$old_kind} `{$name}` here")]
1145 Definition {
1146 #[primary_span]
1147 span: Span,
1148 old_kind: &'static str,
1149 },
1150}
1151
1152#[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)]
1153#[diag("{$ident_descr} `{$ident}` is private", code = E0603)]
1154pub(crate) struct IsPrivate<'a> {
1155 #[primary_span]
1156 #[label("private {$ident_descr}")]
1157 pub(crate) span: Span,
1158 pub(crate) ident_descr: &'a str,
1159 pub(crate) ident: Ident,
1160}
1161
1162#[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)]
1163#[diag("generic arguments in macro path")]
1164pub(crate) struct GenericArgumentsInMacroPath {
1165 #[primary_span]
1166 pub(crate) span: Span,
1167}
1168
1169#[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)]
1170#[diag("attributes starting with `rustc` are reserved for use by the `rustc` compiler")]
1171pub(crate) struct AttributesStartingWithRustcAreReserved {
1172 #[primary_span]
1173 pub(crate) span: Span,
1174}
1175
1176#[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)]
1177#[diag("cannot use {$article} {$descr} through an import")]
1178pub(crate) struct CannotUseThroughAnImport {
1179 #[primary_span]
1180 pub(crate) span: Span,
1181 pub(crate) article: &'static str,
1182 pub(crate) descr: &'static str,
1183 #[note("the {$descr} imported here")]
1184 pub(crate) binding_span: Option<Span>,
1185}
1186
1187#[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)]
1188#[diag("name `{$ident}` is reserved in attribute namespace")]
1189pub(crate) struct NameReservedInAttributeNamespace {
1190 #[primary_span]
1191 pub(crate) span: Span,
1192 pub(crate) ident: Symbol,
1193}
1194
1195#[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)]
1196#[diag("cannot find a built-in macro with name `{$ident}`")]
1197pub(crate) struct CannotFindBuiltinMacroWithName {
1198 #[primary_span]
1199 pub(crate) span: Span,
1200 pub(crate) ident: Ident,
1201}
1202
1203#[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)]
1204#[diag("tool `{$tool}` was already registered")]
1205pub(crate) struct ToolWasAlreadyRegistered {
1206 #[primary_span]
1207 pub(crate) span: Span,
1208 pub(crate) tool: Ident,
1209 #[label("already registered here")]
1210 pub(crate) old_ident_span: Span,
1211}
1212
1213#[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)]
1214#[diag("`{$tool}` only accepts identifiers")]
1215pub(crate) struct ToolOnlyAcceptsIdentifiers {
1216 #[primary_span]
1217 #[label("not an identifier")]
1218 pub(crate) span: Span,
1219 pub(crate) tool: Symbol,
1220}
1221
1222#[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)]
1223pub(crate) enum DefinedHere {
1224 #[label("similarly named {$candidate_descr} `{$candidate}` defined here")]
1225 SimilarlyNamed {
1226 #[primary_span]
1227 span: Span,
1228 candidate_descr: &'static str,
1229 candidate: Symbol,
1230 },
1231 #[label("{$candidate_descr} `{$candidate}` defined here")]
1232 SingleItem {
1233 #[primary_span]
1234 span: Span,
1235 candidate_descr: &'static str,
1236 candidate: Symbol,
1237 },
1238}
1239
1240#[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)]
1241#[label("{$outer_ident_descr} `{$outer_ident}` is not publicly re-exported")]
1242pub(crate) struct OuterIdentIsNotPubliclyReexported {
1243 #[primary_span]
1244 pub(crate) span: Span,
1245 pub(crate) outer_ident_descr: &'static str,
1246 pub(crate) outer_ident: Ident,
1247}
1248
1249#[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)]
1250#[label("a constructor is private if any of the fields is private")]
1251pub(crate) struct ConstructorPrivateIfAnyFieldPrivate {
1252 #[primary_span]
1253 pub(crate) span: Span,
1254}
1255
1256#[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)]
1257#[multipart_suggestion(
1258 "{ $number_of_fields ->
1259 [one] consider making the field publicly accessible
1260 *[other] consider making the fields publicly accessible
1261 }",
1262 applicability = "maybe-incorrect",
1263 style = "verbose"
1264)]
1265pub(crate) struct ConsiderMakingTheFieldPublic {
1266 #[suggestion_part(code = "pub ")]
1267 pub(crate) spans: Vec<Span>,
1268 pub(crate) number_of_fields: usize,
1269}
1270
1271#[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)]
1272pub(crate) enum ImportIdent {
1273 #[suggestion(
1274 "import `{$ident}` through the re-export",
1275 code = "{path}",
1276 applicability = "machine-applicable",
1277 style = "verbose"
1278 )]
1279 ThroughReExport {
1280 #[primary_span]
1281 span: Span,
1282 ident: Ident,
1283 path: String,
1284 },
1285 #[suggestion(
1286 "import `{$ident}` directly",
1287 code = "{path}",
1288 applicability = "machine-applicable",
1289 style = "verbose"
1290 )]
1291 Directly {
1292 #[primary_span]
1293 span: Span,
1294 ident: Ident,
1295 path: String,
1296 },
1297}
1298
1299#[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)]
1300#[note(
1301 "{$first ->
1302 [true] {$dots ->
1303 [true] the {$binding_descr} `{$binding_name}` is defined here...
1304 *[false] the {$binding_descr} `{$binding_name}` is defined here
1305 }
1306 *[false] {$dots ->
1307 [true] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here...
1308 *[false] ...and refers to the {$binding_descr} `{$binding_name}` which is defined here
1309 }
1310 }"
1311)]
1312pub(crate) struct NoteAndRefersToTheItemDefinedHere<'a> {
1313 #[primary_span]
1314 pub(crate) span: MultiSpan,
1315 pub(crate) binding_descr: &'a str,
1316 pub(crate) binding_name: Ident,
1317 pub(crate) first: bool,
1318 pub(crate) dots: bool,
1319}
1320
1321#[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)]
1322#[suggestion("remove unnecessary import", code = "", applicability = "maybe-incorrect")]
1323pub(crate) struct RemoveUnnecessaryImport {
1324 #[primary_span]
1325 pub(crate) span: Span,
1326}
1327
1328#[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)]
1329#[suggestion(
1330 "remove unnecessary import",
1331 code = "",
1332 applicability = "maybe-incorrect",
1333 style = "tool-only"
1334)]
1335pub(crate) struct ToolOnlyRemoveUnnecessaryImport {
1336 #[primary_span]
1337 pub(crate) span: Span,
1338}
1339
1340#[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)]
1341#[note("`{$imported_ident}` is imported here, but it is {$imported_ident_desc}")]
1342pub(crate) struct IdentImporterHereButItIsDesc<'a> {
1343 #[primary_span]
1344 pub(crate) span: Span,
1345 pub(crate) imported_ident: Ident,
1346 pub(crate) imported_ident_desc: &'a str,
1347}
1348
1349#[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)]
1350#[note("`{$imported_ident}` is in scope, but it is {$imported_ident_desc}")]
1351pub(crate) struct IdentInScopeButItIsDesc<'a> {
1352 pub(crate) imported_ident: Ident,
1353 pub(crate) imported_ident_desc: &'a str,
1354}
1355
1356pub(crate) struct FoundItemConfigureOut {
1357 pub(crate) span: Span,
1358 pub(crate) item_was: ItemWas,
1359}
1360
1361pub(crate) enum ItemWas {
1362 BehindFeature { feature: Symbol, span: Span },
1363 CfgOut { span: Span },
1364}
1365
1366impl Subdiagnostic for FoundItemConfigureOut {
1367 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1368 let mut multispan: MultiSpan = self.span.into();
1369 match self.item_was {
1370 ItemWas::BehindFeature { feature, span } => {
1371 let key = "feature".into();
1372 let value = feature.into_diag_arg(&mut None);
1373 let msg = diag.dcx.eagerly_translate_to_string(
1374 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"),
1375 [(&key, &value)].into_iter(),
1376 );
1377 multispan.push_span_label(span, msg);
1378 }
1379 ItemWas::CfgOut { span } => {
1380 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"));
1381 }
1382 }
1383 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"));
1384 }
1385}
1386
1387#[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)]
1388#[diag("item `{$name}` is an associated {$kind}, which doesn't match its trait `{$trait_path}`")]
1389pub(crate) struct TraitImplMismatch {
1390 #[primary_span]
1391 #[label("does not match trait")]
1392 pub(crate) span: Span,
1393 pub(crate) name: Ident,
1394 pub(crate) kind: &'static str,
1395 pub(crate) trait_path: String,
1396 #[label("item in trait")]
1397 pub(crate) trait_item_span: Span,
1398}
1399
1400#[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)]
1401#[diag("derive helper attribute is used before it is introduced")]
1402pub(crate) struct LegacyDeriveHelpers {
1403 #[label("the attribute is introduced here")]
1404 pub span: Span,
1405}
1406
1407#[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)]
1408#[diag("unused extern crate")]
1409pub(crate) struct UnusedExternCrate {
1410 #[label("unused")]
1411 pub span: Span,
1412 #[suggestion(
1413 "remove the unused `extern crate`",
1414 code = "",
1415 applicability = "machine-applicable",
1416 style = "verbose"
1417 )]
1418 pub removal_span: Span,
1419}
1420
1421#[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)]
1422#[diag("{$kind} `{$name}` from private dependency '{$krate}' is re-exported")]
1423pub(crate) struct ReexportPrivateDependency {
1424 pub name: Symbol,
1425 pub kind: &'static str,
1426 pub krate: Symbol,
1427}
1428
1429#[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)]
1430#[diag("unused label")]
1431pub(crate) struct UnusedLabel;
1432
1433#[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)]
1434#[diag("unused `#[macro_use]` import")]
1435pub(crate) struct UnusedMacroUse;
1436
1437#[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)]
1438#[diag("applying the `#[macro_use]` attribute to an `extern crate` item is deprecated")]
1439#[help("remove it and import macros at use sites with a `use` item instead")]
1440pub(crate) struct MacroUseDeprecated;
1441
1442#[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)]
1443#[diag("macro `{$ident}` is private")]
1444pub(crate) struct MacroIsPrivate {
1445 pub ident: Ident,
1446}
1447
1448#[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)]
1449#[diag("unused macro definition: `{$name}`")]
1450pub(crate) struct UnusedMacroDefinition {
1451 pub name: Symbol,
1452}
1453
1454#[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)]
1455#[diag("rule #{$n} of macro `{$name}` is never used")]
1456pub(crate) struct MacroRuleNeverUsed {
1457 pub n: usize,
1458 pub name: Symbol,
1459}
1460
1461pub(crate) struct UnstableFeature {
1462 pub msg: DiagMessage,
1463}
1464
1465impl<'a> LintDiagnostic<'a, ()> for UnstableFeature {
1466 fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
1467 diag.primary_message(self.msg);
1468 }
1469}
1470
1471#[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)]
1472#[diag("`extern crate` is not idiomatic in the new edition")]
1473pub(crate) struct ExternCrateNotIdiomatic {
1474 #[suggestion(
1475 "convert it to a `use`",
1476 style = "verbose",
1477 code = "{code}",
1478 applicability = "machine-applicable"
1479 )]
1480 pub span: Span,
1481 pub code: &'static str,
1482}
1483
1484#[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)]
1485#[diag("cannot find macro `{$path}` in the current scope when looking from {$location}")]
1486#[help("import `macro_rules` with `use` to make it callable above its definition")]
1487pub(crate) struct OutOfScopeMacroCalls {
1488 #[label("not found from {$location}")]
1489 pub span: Span,
1490 pub path: String,
1491 pub location: String,
1492}
1493
1494#[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)]
1495#[diag(
1496 "glob import doesn't reexport anything with visibility `{$import_vis}` because no imported item is public enough"
1497)]
1498pub(crate) struct RedundantImportVisibility {
1499 #[note("the most public imported item is `{$max_vis}`")]
1500 pub span: Span,
1501 #[help("reduce the glob import's visibility or increase visibility of imported items")]
1502 pub help: (),
1503 pub import_vis: String,
1504 pub max_vis: String,
1505}
1506
1507#[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)]
1508#[diag("unknown diagnostic attribute")]
1509pub(crate) struct UnknownDiagnosticAttribute {
1510 #[subdiagnostic]
1511 pub typo: Option<UnknownDiagnosticAttributeTypoSugg>,
1512}
1513
1514#[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)]
1515#[suggestion(
1516 "an attribute with a similar name exists",
1517 style = "verbose",
1518 code = "{typo_name}",
1519 applicability = "machine-applicable"
1520)]
1521pub(crate) struct UnknownDiagnosticAttributeTypoSugg {
1522 #[primary_span]
1523 pub span: Span,
1524 pub typo_name: Symbol,
1525}
1526
1527pub(crate) struct Ambiguity {
1529 pub ident: Ident,
1530 pub ambig_vis: Option<String>,
1531 pub kind: &'static str,
1532 pub help: Option<&'static [&'static str]>,
1533 pub b1_note: Spanned<String>,
1534 pub b1_help_msgs: Vec<String>,
1535 pub b2_note: Spanned<String>,
1536 pub b2_help_msgs: Vec<String>,
1537}
1538
1539impl Ambiguity {
1540 fn decorate<'a>(self, diag: &mut Diag<'a, impl EmissionGuarantee>) {
1541 if let Some(ambig_vis) = self.ambig_vis {
1542 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ambiguous import visibility: {0}",
ambig_vis))
})format!("ambiguous import visibility: {ambig_vis}"));
1543 } else {
1544 diag.primary_message(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}` is ambiguous", self.ident))
})format!("`{}` is ambiguous", self.ident));
1545 diag.span_label(self.ident.span, "ambiguous name");
1546 }
1547 diag.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ambiguous because of {0}",
self.kind))
})format!("ambiguous because of {}", self.kind));
1548 diag.span_note(self.b1_note.span, self.b1_note.node);
1549 if let Some(help) = self.help {
1550 for help in help {
1551 diag.help(*help);
1552 }
1553 }
1554 for help_msg in self.b1_help_msgs {
1555 diag.help(help_msg);
1556 }
1557 diag.span_note(self.b2_note.span, self.b2_note.node);
1558 for help_msg in self.b2_help_msgs {
1559 diag.help(help_msg);
1560 }
1561 }
1562}
1563
1564impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for Ambiguity {
1565 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
1566 let mut diag = Diag::new(dcx, level, "").with_span(self.ident.span).with_code(E0659);
1567 self.decorate(&mut diag);
1568 diag
1569 }
1570}
1571
1572impl<'a> LintDiagnostic<'a, ()> for Ambiguity {
1573 fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
1574 self.decorate(diag);
1575 }
1576}