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