1use std::borrow::Cow;
2
3use rustc_data_structures::Limit;
4use rustc_errors::codes::*;
5use rustc_macros::{Diagnostic, Subdiagnostic};
6use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol};
7
8#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CfgAttrNoAttributes where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CfgAttrNoAttributes => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[cfg_attr]` does not expand to any attributes")));
;
diag
}
}
}
}
};Diagnostic)]
9#[diag("`#[cfg_attr]` does not expand to any attributes")]
10pub(crate) struct CfgAttrNoAttributes;
11
12#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NoSyntaxVarsExprRepeat where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NoSyntaxVarsExprRepeat {
span: __binding_0,
typo_repeatable: __binding_1,
typo_unrepeatable: __binding_2,
typo_unrepeatable_label: __binding_3,
var_no_typo: __binding_4,
no_repeatable_var: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attempted to repeat an expression containing no syntax variables matched as repeating at this depth")));
;
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);
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag
}
}
}
}
};Diagnostic)]
13#[diag(
14 "attempted to repeat an expression containing no syntax variables matched as repeating at this depth"
15)]
16pub(crate) struct NoSyntaxVarsExprRepeat {
17 #[primary_span]
18 pub span: Span,
19 #[subdiagnostic]
20 pub typo_repeatable: Option<VarTypoSuggestionRepeatable>,
21 #[subdiagnostic]
22 pub typo_unrepeatable: Option<VarTypoSuggestionUnrepeatable>,
23 #[subdiagnostic]
24 pub typo_unrepeatable_label: Option<VarTypoSuggestionUnrepeatableLabel>,
25 #[subdiagnostic]
26 pub var_no_typo: Option<VarNoTypo>,
27 #[subdiagnostic]
28 pub no_repeatable_var: Option<NoRepeatableVar>,
29}
30
31#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for VarTypoSuggestionRepeatable {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
VarTypoSuggestionRepeatable {
span: __binding_0, name: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_0 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
suggestions.push((__binding_0, __code_0));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there's a macro metavariable with a similar name")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
32#[multipart_suggestion(
33 "there's a macro metavariable with a similar name",
34 applicability = "maybe-incorrect",
35 style = "verbose"
36)]
37pub(crate) struct VarTypoSuggestionRepeatable {
38 #[suggestion_part(code = "{name}")]
39 pub span: Span,
40 pub name: Symbol,
41}
42
43#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for VarTypoSuggestionUnrepeatable {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
VarTypoSuggestionUnrepeatable { 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("argument not found")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
44#[label("argument not found")]
45pub(crate) struct VarTypoSuggestionUnrepeatable {
46 #[primary_span]
47 pub span: Span,
48}
49
50#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
VarTypoSuggestionUnrepeatableLabel {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
VarTypoSuggestionUnrepeatableLabel { 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("this similarly named macro metavariable is unrepeatable")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
51#[label("this similarly named macro metavariable is unrepeatable")]
52pub(crate) struct VarTypoSuggestionUnrepeatableLabel {
53 #[primary_span]
54 pub span: Span,
55}
56
57#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for VarNoTypo {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
VarNoTypo { span: __binding_0, msg: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("msg".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("expected a repeatable metavariable: {$msg}")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
58#[label("expected a repeatable metavariable: {$msg}")]
59pub(crate) struct VarNoTypo {
60 #[primary_span]
61 pub span: Span,
62 pub msg: String,
63}
64
65#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NoRepeatableVar {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NoRepeatableVar { 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("this macro metavariable is not repeatable and there are no other repeatable metavariables")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
66#[label(
67 "this macro metavariable is not repeatable and there are no other repeatable metavariables"
68)]
69pub(crate) struct NoRepeatableVar {
70 #[primary_span]
71 pub span: Span,
72}
73
74#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MustRepeatOnce
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MustRepeatOnce { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this must repeat at least once")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
75#[diag("this must repeat at least once")]
76pub(crate) struct MustRepeatOnce {
77 #[primary_span]
78 pub span: Span,
79}
80
81#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CountRepetitionMisplaced where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CountRepetitionMisplaced { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`count` can not be placed inside the innermost repetition")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
82#[diag("`count` can not be placed inside the innermost repetition")]
83pub(crate) struct CountRepetitionMisplaced {
84 #[primary_span]
85 pub span: Span,
86}
87
88#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroVarStillRepeating where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroVarStillRepeating {
span: __binding_0, ident: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable `{$ident}` is still repeating at this depth")));
;
diag.arg("ident", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
89#[diag("variable `{$ident}` is still repeating at this depth")]
90pub(crate) struct MacroVarStillRepeating {
91 #[primary_span]
92 pub span: Span,
93 pub ident: MacroRulesNormalizedIdent,
94}
95
96#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MetaVarStillRepeatingLint where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MetaVarStillRepeatingLint {
label: __binding_0, ident: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable `{$ident}` is still repeating at this depth")));
;
diag.arg("ident", __binding_1);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected repetition")));
diag
}
}
}
}
};Diagnostic)]
97#[diag("variable `{$ident}` is still repeating at this depth")]
98pub(crate) struct MetaVarStillRepeatingLint {
99 #[label("expected repetition")]
100 pub label: Span,
101 pub ident: MacroRulesNormalizedIdent,
102}
103
104#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MetaVariableWrongOperator where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MetaVariableWrongOperator {
binder: __binding_0, occurrence: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("meta-variable repeats with different Kleene operator")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected repetition")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("conflicting repetition")));
diag
}
}
}
}
};Diagnostic)]
105#[diag("meta-variable repeats with different Kleene operator")]
106pub(crate) struct MetaVariableWrongOperator {
107 #[label("expected repetition")]
108 pub binder: Span,
109 #[label("conflicting repetition")]
110 pub occurrence: Span,
111}
112
113#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MetaVarsDifSeqMatchers where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MetaVarsDifSeqMatchers { span: __binding_0, msg: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$msg}")));
;
diag.arg("msg", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
114#[diag("{$msg}")]
115pub(crate) struct MetaVarsDifSeqMatchers {
116 #[primary_span]
117 pub span: Span,
118 pub msg: String,
119}
120
121#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownMacroVariable where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownMacroVariable { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown macro variable `{$name}`")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
122#[diag("unknown macro variable `{$name}`")]
123pub(crate) struct UnknownMacroVariable {
124 pub name: MacroRulesNormalizedIdent,
125}
126
127#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroBodyStability where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroBodyStability {
span: __binding_0, head_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macros cannot have body stability attributes")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid body stability attribute")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("body stability attribute affects this macro")));
diag
}
}
}
}
};Diagnostic)]
128#[diag("macros cannot have body stability attributes")]
129pub(crate) struct MacroBodyStability {
130 #[primary_span]
131 #[label("invalid body stability attribute")]
132 pub span: Span,
133 #[label("body stability attribute affects this macro")]
134 pub head_span: Span,
135}
136
137#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
FeatureRemoved<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FeatureRemoved {
span: __binding_0,
reason: __binding_1,
removed_rustc_version: __binding_2,
pull_note: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature has been removed")));
diag.code(E0557);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("removed in {$removed_rustc_version}{$pull_note}")));
;
diag.arg("removed_rustc_version", __binding_2);
diag.arg("pull_note", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature has been removed")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
138#[diag("feature has been removed", code = E0557)]
139#[note("removed in {$removed_rustc_version}{$pull_note}")]
140pub(crate) struct FeatureRemoved<'a> {
141 #[primary_span]
142 #[label("feature has been removed")]
143 pub span: Span,
144 #[subdiagnostic]
145 pub reason: Option<FeatureRemovedReason<'a>>,
146 pub removed_rustc_version: &'a str,
147 pub pull_note: String,
148}
149
150#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for FeatureRemovedReason<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FeatureRemovedReason { reason: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("reason".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("{$reason}")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
151#[note("{$reason}")]
152pub(crate) struct FeatureRemovedReason<'a> {
153 pub reason: &'a str,
154}
155
156#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FeatureNotAllowed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
FeatureNotAllowed { span: __binding_0, name: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$name}` is not in the list of allowed features")));
diag.code(E0725);
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
157#[diag("the feature `{$name}` is not in the list of allowed features", code = E0725)]
158pub(crate) struct FeatureNotAllowed {
159 #[primary_span]
160 pub span: Span,
161 pub name: Symbol,
162}
163
164#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RecursionLimitReached where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RecursionLimitReached {
span: __binding_0,
descr: __binding_1,
suggested_limit: __binding_2,
crate_name: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("recursion limit reached while expanding `{$descr}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)")));
;
diag.arg("descr", __binding_1);
diag.arg("suggested_limit", __binding_2);
diag.arg("crate_name", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
165#[diag("recursion limit reached while expanding `{$descr}`")]
166#[help(
167 "consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
168)]
169pub(crate) struct RecursionLimitReached {
170 #[primary_span]
171 pub span: Span,
172 pub descr: String,
173 pub suggested_limit: Limit,
174 pub crate_name: Symbol,
175}
176
177#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RemoveExprNotSupported where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RemoveExprNotSupported { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("removing an expression is not supported in this position")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
178#[diag("removing an expression is not supported in this position")]
179pub(crate) struct RemoveExprNotSupported {
180 #[primary_span]
181 pub span: Span,
182}
183
184#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
WrongFragmentKind<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
WrongFragmentKind {
span: __binding_0, kind: __binding_1, name: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-{$kind} macro in {$kind} position: {$name}")));
;
diag.arg("kind", __binding_1);
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
185#[diag("non-{$kind} macro in {$kind} position: {$name}")]
186pub(crate) struct WrongFragmentKind<'a> {
187 #[primary_span]
188 pub span: Span,
189 pub kind: &'a str,
190 pub name: String,
191}
192
193#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedKeyValue where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsupportedKeyValue { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("key-value macro attributes are not supported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
194#[diag("key-value macro attributes are not supported")]
195pub(crate) struct UnsupportedKeyValue {
196 #[primary_span]
197 pub span: Span,
198}
199
200#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
IncompleteParse<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IncompleteParse {
span: __binding_0,
descr: __binding_1,
label_span: __binding_2,
macro_path: __binding_3,
kind_name: __binding_4,
expands_to_match_arm: __binding_5,
add_semicolon: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro expansion ignores {$descr} and any tokens following")));
let __code_1 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the usage of `{$macro_path}!` is likely invalid in {$kind_name} context")));
;
diag.arg("descr", __binding_1);
diag.arg("macro_path", __binding_3);
diag.arg("kind_name", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("caused by the macro expansion here")));
if __binding_5 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macros cannot expand to match arms")));
}
if let Some(__binding_6) = __binding_6 {
diag.span_suggestions_with_style(__binding_6,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might be missing a semicolon here")),
__code_1, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
201#[diag("macro expansion ignores {$descr} and any tokens following")]
202#[note("the usage of `{$macro_path}!` is likely invalid in {$kind_name} context")]
203pub(crate) struct IncompleteParse<'a> {
204 #[primary_span]
205 pub span: Span,
206 pub descr: String,
207 #[label("caused by the macro expansion here")]
208 pub label_span: Span,
209 pub macro_path: String,
210 pub kind_name: &'a str,
211 #[note("macros cannot expand to match arms")]
212 pub expands_to_match_arm: bool,
213
214 #[suggestion(
215 "you might be missing a semicolon here",
216 style = "verbose",
217 code = ";",
218 applicability = "maybe-incorrect"
219 )]
220 pub add_semicolon: Option<Span>,
221}
222
223#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RemoveNodeNotSupported where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RemoveNodeNotSupported {
span: __binding_0, descr: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("removing {$descr} is not supported in this position")));
;
diag.arg("descr", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
224#[diag("removing {$descr} is not supported in this position")]
225pub(crate) struct RemoveNodeNotSupported {
226 #[primary_span]
227 pub span: Span,
228 pub descr: &'static str,
229}
230
231#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ModuleCircular
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ModuleCircular { span: __binding_0, modules: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("circular modules: {$modules}")));
;
diag.arg("modules", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
232#[diag("circular modules: {$modules}")]
233pub(crate) struct ModuleCircular {
234 #[primary_span]
235 pub span: Span,
236 pub modules: String,
237}
238
239#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ModuleInBlock
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ModuleInBlock { span: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot declare a file module inside a block unless it has a path attribute")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file modules are usually placed outside of blocks, at the top level of the file")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
240#[diag("cannot declare a file module inside a block unless it has a path attribute")]
241#[note("file modules are usually placed outside of blocks, at the top level of the file")]
242pub(crate) struct ModuleInBlock {
243 #[primary_span]
244 pub span: Span,
245 #[subdiagnostic]
246 pub name: Option<ModuleInBlockName>,
247}
248
249#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ModuleInBlockName {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ModuleInBlockName { 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("maybe `use` the module `{$name}` instead of redeclaring it")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
250#[help("maybe `use` the module `{$name}` instead of redeclaring it")]
251pub(crate) struct ModuleInBlockName {
252 #[primary_span]
253 pub span: Span,
254 pub name: Ident,
255}
256
257#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ModuleFileNotFound where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ModuleFileNotFound {
span: __binding_0,
name: __binding_1,
default_path: __binding_2,
secondary_path: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file not found for module `{$name}`")));
diag.code(E0583);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to create the module `{$name}`, create file \"{$default_path}\" or \"{$secondary_path}\"")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if there is a `mod {$name}` elsewhere in the crate already, import it with `use crate::...` instead")));
;
diag.arg("name", __binding_1);
diag.arg("default_path", __binding_2);
diag.arg("secondary_path", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
258#[diag("file not found for module `{$name}`", code = E0583)]
259#[help("to create the module `{$name}`, create file \"{$default_path}\" or \"{$secondary_path}\"")]
260#[note(
261 "if there is a `mod {$name}` elsewhere in the crate already, import it with `use crate::...` instead"
262)]
263pub(crate) struct ModuleFileNotFound {
264 #[primary_span]
265 pub span: Span,
266 pub name: Ident,
267 pub default_path: String,
268 pub secondary_path: String,
269}
270
271#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ModuleMultipleCandidates where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ModuleMultipleCandidates {
span: __binding_0,
name: __binding_1,
default_path: __binding_2,
secondary_path: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file for module `{$name}` found at both \"{$default_path}\" and \"{$secondary_path}\"")));
diag.code(E0761);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("delete or rename one of them to remove the ambiguity")));
;
diag.arg("name", __binding_1);
diag.arg("default_path", __binding_2);
diag.arg("secondary_path", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
272#[diag("file for module `{$name}` found at both \"{$default_path}\" and \"{$secondary_path}\"", code = E0761)]
273#[help("delete or rename one of them to remove the ambiguity")]
274pub(crate) struct ModuleMultipleCandidates {
275 #[primary_span]
276 pub span: Span,
277 pub name: Ident,
278 pub default_path: String,
279 pub secondary_path: String,
280}
281
282#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TraceMacro
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TraceMacro { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trace_macro")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
283#[diag("trace_macro")]
284pub(crate) struct TraceMacro {
285 #[primary_span]
286 pub span: Span,
287}
288
289#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ProcMacroPanicked where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ProcMacroPanicked { span: __binding_0, message: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("proc macro panicked")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
290#[diag("proc macro panicked")]
291pub(crate) struct ProcMacroPanicked {
292 #[primary_span]
293 pub span: Span,
294 #[subdiagnostic]
295 pub message: Option<ProcMacroPanickedHelp>,
296}
297
298#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ProcMacroPanickedHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ProcMacroPanickedHelp { message: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("message".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("message: {$message}")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
299#[help("message: {$message}")]
300pub(crate) struct ProcMacroPanickedHelp {
301 pub message: String,
302}
303
304#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ProcMacroDerivePanicked where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ProcMacroDerivePanicked {
span: __binding_0, message: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("proc-macro derive panicked")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
305#[diag("proc-macro derive panicked")]
306pub(crate) struct ProcMacroDerivePanicked {
307 #[primary_span]
308 pub span: Span,
309 #[subdiagnostic]
310 pub message: Option<ProcMacroDerivePanickedHelp>,
311}
312
313#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ProcMacroDerivePanickedHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ProcMacroDerivePanickedHelp { message: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("message".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("message: {$message}")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
314#[help("message: {$message}")]
315pub(crate) struct ProcMacroDerivePanickedHelp {
316 pub message: String,
317}
318
319#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CustomAttributePanicked where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CustomAttributePanicked {
span: __binding_0, message: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("custom attribute panicked")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
320#[diag("custom attribute panicked")]
321pub(crate) struct CustomAttributePanicked {
322 #[primary_span]
323 pub span: Span,
324 #[subdiagnostic]
325 pub message: Option<CustomAttributePanickedHelp>,
326}
327
328#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CustomAttributePanickedHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CustomAttributePanickedHelp { message: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("message".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("message: {$message}")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
329#[help("message: {$message}")]
330pub(crate) struct CustomAttributePanickedHelp {
331 pub message: String,
332}
333
334#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ProcMacroDeriveTokens where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ProcMacroDeriveTokens { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("proc-macro derive produced unparsable tokens")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
335#[diag("proc-macro derive produced unparsable tokens")]
336pub(crate) struct ProcMacroDeriveTokens {
337 #[primary_span]
338 pub span: Span,
339}
340
341#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DuplicateMatcherBinding where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DuplicateMatcherBinding {
span: __binding_0, prev: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate matcher binding")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate binding")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous binding")));
diag
}
}
}
}
};Diagnostic)]
342#[diag("duplicate matcher binding")]
343pub(crate) struct DuplicateMatcherBinding {
344 #[primary_span]
345 #[label("duplicate binding")]
346 pub span: Span,
347 #[label("previous binding")]
348 pub prev: Span,
349}
350
351#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DuplicateMatcherBindingLint where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DuplicateMatcherBindingLint {
span: __binding_0, prev: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate matcher binding")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate binding")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous binding")));
diag
}
}
}
}
};Diagnostic)]
352#[diag("duplicate matcher binding")]
353pub(crate) struct DuplicateMatcherBindingLint {
354 #[label("duplicate binding")]
355 pub span: Span,
356 #[label("previous binding")]
357 pub prev: Span,
358}
359
360#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingFragmentSpecifier where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingFragmentSpecifier {
span: __binding_0, add_span: __binding_1, valid: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing fragment specifier")));
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(":spec"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fragment specifiers must be provided")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$valid}")));
;
diag.arg("valid", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding a specifier here")),
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
361#[diag("missing fragment specifier")]
362#[note("fragment specifiers must be provided")]
363#[help("{$valid}")]
364pub(crate) struct MissingFragmentSpecifier {
365 #[primary_span]
366 pub span: Span,
367 #[suggestion(
368 "try adding a specifier here",
369 style = "verbose",
370 code = ":spec",
371 applicability = "maybe-incorrect"
372 )]
373 pub add_span: Span,
374 pub valid: &'static str,
375}
376
377#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidFragmentSpecifier where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidFragmentSpecifier {
span: __binding_0, fragment: __binding_1, help: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid fragment specifier `{$fragment}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$help}")));
;
diag.arg("fragment", __binding_1);
diag.arg("help", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
378#[diag("invalid fragment specifier `{$fragment}`")]
379#[help("{$help}")]
380pub(crate) struct InvalidFragmentSpecifier {
381 #[primary_span]
382 pub span: Span,
383 pub fragment: Ident,
384 pub help: &'static str,
385}
386
387#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedParenOrBrace<'a> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedParenOrBrace { span: __binding_0, token: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `(` or `{\"{\"}`, found `{$token}`")));
;
diag.arg("token", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
388#[diag("expected `(` or `{\"{\"}`, found `{$token}`")]
389pub(crate) struct ExpectedParenOrBrace<'a> {
390 #[primary_span]
391 pub span: Span,
392 pub token: Cow<'a, str>,
393}
394
395#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EmptyDelegationMac where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EmptyDelegationMac { span: __binding_0, kind: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("empty {$kind} delegation is not supported")));
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
396#[diag("empty {$kind} delegation is not supported")]
397pub(crate) struct EmptyDelegationMac {
398 #[primary_span]
399 pub span: Span,
400 pub kind: String,
401}
402
403#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GlobDelegationOutsideImpls where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GlobDelegationOutsideImpls { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("glob delegation is only supported in impls")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
404#[diag("glob delegation is only supported in impls")]
405pub(crate) struct GlobDelegationOutsideImpls {
406 #[primary_span]
407 pub span: Span,
408}
409
410#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CrateNameInCfgAttr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CrateNameInCfgAttr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `crate_name` attribute is forbidden within a `cfg_attr` attribute")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
411#[diag("the `crate_name` attribute is forbidden within a `cfg_attr` attribute")]
412pub(crate) struct CrateNameInCfgAttr {
413 #[primary_span]
414 pub span: Span,
415}
416
417#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CrateTypeInCfgAttr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CrateTypeInCfgAttr { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `crate_type` attribute is forbidden within a `cfg_attr` attribute")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
418#[diag("the `crate_type` attribute is forbidden within a `cfg_attr` attribute")]
419pub(crate) struct CrateTypeInCfgAttr {
420 #[primary_span]
421 pub span: Span,
422}
423
424#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
GlobDelegationTraitlessQpath where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
GlobDelegationTraitlessQpath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("qualified path without a trait in glob delegation")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
425#[diag("qualified path without a trait in glob delegation")]
426pub(crate) struct GlobDelegationTraitlessQpath {
427 #[primary_span]
428 pub span: Span,
429}
430
431pub(crate) use metavar_exprs::*;
432mod metavar_exprs {
433 use super::*;
434
435 #[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MveExtraTokens
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MveExtraTokens {
span: __binding_0,
ident_span: __binding_1,
extra_count: __binding_2,
exact_args_note: __binding_3,
range_args_note: __binding_4,
min_or_exact_args: __binding_5,
max_args: __binding_6,
name: __binding_7 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected trailing tokens")));
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("extra_count", __binding_2);
diag.arg("min_or_exact_args", __binding_5);
diag.arg("max_args", __binding_6);
diag.arg("name", __binding_7);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try removing {$extra_count ->\n [one] this token\n *[other] these tokens\n }")),
__code_3, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for this metavariable expression")));
if let Some(__binding_3) = __binding_3 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$name}` metavariable expression takes {$min_or_exact_args ->\n [zero] no arguments\n [one] a single argument\n *[other] {$min_or_exact_args} arguments\n }")));
}
if let Some(__binding_4) = __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$name}` metavariable expression takes between {$min_or_exact_args} and {$max_args} arguments")));
}
diag
}
}
}
}
};Diagnostic, #[automatically_derived]
impl ::core::default::Default for MveExtraTokens {
#[inline]
fn default() -> MveExtraTokens {
MveExtraTokens {
span: ::core::default::Default::default(),
ident_span: ::core::default::Default::default(),
extra_count: ::core::default::Default::default(),
exact_args_note: ::core::default::Default::default(),
range_args_note: ::core::default::Default::default(),
min_or_exact_args: ::core::default::Default::default(),
max_args: ::core::default::Default::default(),
name: ::core::default::Default::default(),
}
}
}Default)]
436 #[diag("unexpected trailing tokens")]
437 pub(crate) struct MveExtraTokens {
438 #[primary_span]
439 #[suggestion(
440 "try removing {$extra_count ->
441 [one] this token
442 *[other] these tokens
443 }",
444 code = "",
445 applicability = "machine-applicable"
446 )]
447 pub span: Span,
448 #[label("for this metavariable expression")]
449 pub ident_span: Span,
450 pub extra_count: usize,
451
452 #[note(
455 "the `{$name}` metavariable expression takes {$min_or_exact_args ->
456 [zero] no arguments
457 [one] a single argument
458 *[other] {$min_or_exact_args} arguments
459 }"
460 )]
461 pub exact_args_note: Option<()>,
462 #[note(
463 "the `{$name}` metavariable expression takes between {$min_or_exact_args} and {$max_args} arguments"
464 )]
465 pub range_args_note: Option<()>,
466 pub min_or_exact_args: usize,
467 pub max_args: usize,
468 pub name: String,
469 }
470
471 #[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MveMissingParen where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MveMissingParen {
ident_span: __binding_0,
unexpected_span: __binding_1,
insert_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `(`")));
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("( /* ... */ )"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("metavariable expressions use function-like parentheses syntax")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for this this metavariable expression")));
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected token")));
}
if let Some(__binding_2) = __binding_2 {
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding parentheses")),
__code_4, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
472 #[note("metavariable expressions use function-like parentheses syntax")]
473 #[diag("expected `(`")]
474 pub(crate) struct MveMissingParen {
475 #[primary_span]
476 #[label("for this this metavariable expression")]
477 pub ident_span: Span,
478 #[label("unexpected token")]
479 pub unexpected_span: Option<Span>,
480 #[suggestion(
481 "try adding parentheses",
482 code = "( /* ... */ )",
483 applicability = "has-placeholders"
484 )]
485 pub insert_span: Option<Span>,
486 }
487
488 #[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MveUnrecognizedExpr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MveUnrecognizedExpr {
span: __binding_0, valid_expr_list: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unrecognized metavariable expression")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("valid metavariable expressions are {$valid_expr_list}")));
;
diag.arg("valid_expr_list", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a valid metavariable expression")));
diag
}
}
}
}
};Diagnostic)]
489 #[note("valid metavariable expressions are {$valid_expr_list}")]
490 #[diag("unrecognized metavariable expression")]
491 pub(crate) struct MveUnrecognizedExpr {
492 #[primary_span]
493 #[label("not a valid metavariable expression")]
494 pub span: Span,
495 pub valid_expr_list: &'static str,
496 }
497
498 #[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MveUnrecognizedVar where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MveUnrecognizedVar { span: __binding_0, key: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("variable `{$key}` is not recognized in meta-variable expression")));
;
diag.arg("key", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
499 #[diag("variable `{$key}` is not recognized in meta-variable expression")]
500 pub(crate) struct MveUnrecognizedVar {
501 #[primary_span]
502 pub span: Span,
503 pub key: MacroRulesNormalizedIdent,
504 }
505
506 #[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConcatInvalidIdent where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConcatInvalidIdent { span: __binding_0, reason: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`${\"{\"}concat(..){\"}\"}` is not generating a valid identifier")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
507 #[diag(r#"`${"{"}concat(..){"}"}` is not generating a valid identifier"#)]
508 pub(crate) struct ConcatInvalidIdent {
509 #[primary_span]
510 pub span: Span,
511 #[subdiagnostic]
512 pub reason: InvalidIdentReason,
513 }
514
515 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidIdentReason {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidIdentReason::Empty => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `${\"{\"}concat(..){\"}\"}` invocation generated an empty ident")),
&sub_args);
diag.note(__message);
}
InvalidIdentReason::InvalidStart {
symbol: __binding_0, start: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("symbol".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("start".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 `${\"{\"}concat(..){\"}\"}` invocation generated `{$symbol}`, but {$start} is neither '_' nor XID_Start")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers")),
&sub_args);
diag.note(__message);
}
InvalidIdentReason::InvalidContinue {
symbol: __binding_0, not_continue: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("symbol".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("not_continue".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 `${\"{\"}concat(..){\"}\"}` invocation generated `{$symbol}`, but {$not_continue} is not XID_Continue")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
516 pub(crate) enum InvalidIdentReason {
517 #[note(r#"this `${"{"}concat(..){"}"}` invocation generated an empty ident"#)]
518 Empty,
519 #[note(r#"this `${"{"}concat(..){"}"}` invocation generated `{$symbol}`, but {$start} is neither '_' nor XID_Start"#)]
520 #[note(
521 "see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers"
522 )]
523 InvalidStart { symbol: Symbol, start: char },
524 #[note(r#"this `${"{"}concat(..){"}"}` invocation generated `{$symbol}`, but {$not_continue} is not XID_Continue"#)]
525 #[note(
526 "see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers"
527 )]
528 InvalidContinue { symbol: Symbol, not_continue: char },
529 }
530
531 impl InvalidIdentReason {
532 pub(crate) fn new(symbol: Symbol) -> Self {
533 let mut chars = symbol.as_str().chars();
534 if let Some(start) = chars.next() {
535 if rustc_lexer::is_id_start(start) {
536 let not_continue = chars
537 .find(|c| !rustc_lexer::is_id_continue(*c))
538 .expect("InvalidIdentReason: cannot find invalid ident reason");
539 InvalidIdentReason::InvalidContinue { symbol, not_continue }
540 } else {
541 InvalidIdentReason::InvalidStart { symbol, start }
542 }
543 } else {
544 InvalidIdentReason::Empty
545 }
546 }
547 }
548}
549
550#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroArgsBadDelim where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroArgsBadDelim {
span: __binding_0, sugg: __binding_1, rule_kw: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$rule_kw}` rule argument matchers require parentheses")));
;
diag.arg("rule_kw", __binding_2);
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
551#[diag("`{$rule_kw}` rule argument matchers require parentheses")]
552pub(crate) struct MacroArgsBadDelim {
553 #[primary_span]
554 pub span: Span,
555 #[subdiagnostic]
556 pub sugg: MacroArgsBadDelimSugg,
557 pub rule_kw: Symbol,
558}
559
560#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MacroArgsBadDelimSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MacroArgsBadDelimSugg {
open: __binding_0, close: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_5 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_6 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_5));
suggestions.push((__binding_1, __code_6));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the delimiters should be `(` and `)`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
561#[multipart_suggestion(
562 "the delimiters should be `(` and `)`",
563 applicability = "machine-applicable"
564)]
565pub(crate) struct MacroArgsBadDelimSugg {
566 #[suggestion_part(code = "(")]
567 pub open: Span,
568 #[suggestion_part(code = ")")]
569 pub close: Span,
570}
571
572#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroCallUnusedDocComment where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroCallUnusedDocComment { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused doc comment")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to document an item produced by a macro, the macro must produce the documentation as part of its expansion")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rustdoc does not generate documentation for macro invocations")));
diag
}
}
}
}
};Diagnostic)]
573#[diag("unused doc comment")]
574#[help(
575 "to document an item produced by a macro, the macro must produce the documentation as part of its expansion"
576)]
577pub(crate) struct MacroCallUnusedDocComment {
578 #[label("rustdoc does not generate documentation for macro invocations")]
579 pub span: Span,
580}
581
582#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OrPatternsBackCompat where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OrPatternsBackCompat {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro")));
let __code_7 =
[::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("use pat_param to preserve semantics")),
__code_7, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
583#[diag(
584 "the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro"
585)]
586pub(crate) struct OrPatternsBackCompat {
587 #[suggestion(
588 "use pat_param to preserve semantics",
589 code = "{suggestion}",
590 applicability = "machine-applicable"
591 )]
592 pub span: Span,
593 pub suggestion: String,
594}
595
596#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TrailingMacro
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TrailingMacro { is_trailing: __binding_0, name: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trailing semicolon in macro used in expression position")));
;
diag.arg("name", __binding_1);
if __binding_0 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("macro invocations at the end of a block are treated as expressions")));
}
if __binding_0 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to ignore the value produced by the macro, add a semicolon after the invocation of `{$name}`")));
}
diag
}
}
}
}
};Diagnostic)]
597#[diag("trailing semicolon in macro used in expression position")]
598pub(crate) struct TrailingMacro {
599 #[note("macro invocations at the end of a block are treated as expressions")]
600 #[note(
601 "to ignore the value produced by the macro, add a semicolon after the invocation of `{$name}`"
602 )]
603 pub is_trailing: bool,
604 pub name: Ident,
605}
606
607#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedBuiltinAttribute where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnusedBuiltinAttribute {
invoc_span: __binding_0,
attr_name: __binding_1,
macro_name: __binding_2,
attr_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused attribute `{$attr_name}`")));
let __code_8 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("attr_name", __binding_1);
diag.arg("macro_name", __binding_2);
diag.span_note(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attribute")),
__code_8, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
608#[diag("unused attribute `{$attr_name}`")]
609pub(crate) struct UnusedBuiltinAttribute {
610 #[note(
611 "the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`"
612 )]
613 pub invoc_span: Span,
614 pub attr_name: Symbol,
615 pub macro_name: String,
616 #[suggestion(
617 "remove the attribute",
618 code = "",
619 applicability = "machine-applicable",
620 style = "tool-only"
621 )]
622 pub attr_span: Span,
623}