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