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