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