1use std::borrow::Cow;
2
3use rustc_errors::codes::*;
4use rustc_hir::limit::Limit;
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();
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("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
ResolveRelativePath where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ResolveRelativePath { span: __binding_0, path: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot resolve relative path in non-file source `{$path}`")));
;
diag.arg("path", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
128#[diag("cannot resolve relative path in non-file source `{$path}`")]
129pub(crate) struct ResolveRelativePath {
130 #[primary_span]
131 pub span: Span,
132 pub path: String,
133}
134
135#[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)]
136#[diag("macros cannot have body stability attributes")]
137pub(crate) struct MacroBodyStability {
138 #[primary_span]
139 #[label("invalid body stability attribute")]
140 pub span: Span,
141 #[label("body stability attribute affects this macro")]
142 pub head_span: Span,
143}
144
145#[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)]
146#[diag("feature has been removed", code = E0557)]
147#[note("removed in {$removed_rustc_version}{$pull_note}")]
148pub(crate) struct FeatureRemoved<'a> {
149 #[primary_span]
150 #[label("feature has been removed")]
151 pub span: Span,
152 #[subdiagnostic]
153 pub reason: Option<FeatureRemovedReason<'a>>,
154 pub removed_rustc_version: &'a str,
155 pub pull_note: String,
156}
157
158#[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)]
159#[note("{$reason}")]
160pub(crate) struct FeatureRemovedReason<'a> {
161 pub reason: &'a str,
162}
163
164#[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)]
165#[diag("the feature `{$name}` is not in the list of allowed features", code = E0725)]
166pub(crate) struct FeatureNotAllowed {
167 #[primary_span]
168 pub span: Span,
169 pub name: Symbol,
170}
171
172#[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)]
173#[diag("recursion limit reached while expanding `{$descr}`")]
174#[help(
175 "consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]` attribute to your crate (`{$crate_name}`)"
176)]
177pub(crate) struct RecursionLimitReached {
178 #[primary_span]
179 pub span: Span,
180 pub descr: String,
181 pub suggested_limit: Limit,
182 pub crate_name: Symbol,
183}
184
185#[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)]
186#[diag("removing an expression is not supported in this position")]
187pub(crate) struct RemoveExprNotSupported {
188 #[primary_span]
189 pub span: Span,
190}
191
192#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InvalidCfg
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidCfg::NotFollowedByParens { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`cfg` is not followed by parentheses")));
let __code_1 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("cfg(/* predicate */)"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected syntax is")),
__code_1, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
InvalidCfg::NoPredicate { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`cfg` predicate is not specified")));
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("cfg(/* predicate */)"))
})].into_iter();
;
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected syntax is")),
__code_2, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
InvalidCfg::MultiplePredicates { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple `cfg` predicates are specified")));
;
diag.span(__binding_0);
diag
}
InvalidCfg::PredicateLiteral { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`cfg` predicate key cannot be a literal")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
193pub(crate) enum InvalidCfg {
194 #[diag("`cfg` is not followed by parentheses")]
195 NotFollowedByParens {
196 #[primary_span]
197 #[suggestion(
198 "expected syntax is",
199 code = "cfg(/* predicate */)",
200 applicability = "has-placeholders"
201 )]
202 span: Span,
203 },
204 #[diag("`cfg` predicate is not specified")]
205 NoPredicate {
206 #[primary_span]
207 #[suggestion(
208 "expected syntax is",
209 code = "cfg(/* predicate */)",
210 applicability = "has-placeholders"
211 )]
212 span: Span,
213 },
214 #[diag("multiple `cfg` predicates are specified")]
215 MultiplePredicates {
216 #[primary_span]
217 span: Span,
218 },
219 #[diag("`cfg` predicate key cannot be a literal")]
220 PredicateLiteral {
221 #[primary_span]
222 span: Span,
223 },
224}
225
226#[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)]
227#[diag("non-{$kind} macro in {$kind} position: {$name}")]
228pub(crate) struct WrongFragmentKind<'a> {
229 #[primary_span]
230 pub span: Span,
231 pub kind: &'a str,
232 pub name: String,
233}
234
235#[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)]
236#[diag("key-value macro attributes are not supported")]
237pub(crate) struct UnsupportedKeyValue {
238 #[primary_span]
239 pub span: Span,
240}
241
242#[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_3 =
[::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_3, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
diag
}
}
}
}
};Diagnostic)]
243#[diag("macro expansion ignores {$descr} and any tokens following")]
244#[note("the usage of `{$macro_path}!` is likely invalid in {$kind_name} context")]
245pub(crate) struct IncompleteParse<'a> {
246 #[primary_span]
247 pub span: Span,
248 pub descr: String,
249 #[label("caused by the macro expansion here")]
250 pub label_span: Span,
251 pub macro_path: String,
252 pub kind_name: &'a str,
253 #[note("macros cannot expand to match arms")]
254 pub expands_to_match_arm: bool,
255
256 #[suggestion(
257 "you might be missing a semicolon here",
258 style = "verbose",
259 code = ";",
260 applicability = "maybe-incorrect"
261 )]
262 pub add_semicolon: Option<Span>,
263}
264
265#[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)]
266#[diag("removing {$descr} is not supported in this position")]
267pub(crate) struct RemoveNodeNotSupported {
268 #[primary_span]
269 pub span: Span,
270 pub descr: &'static str,
271}
272
273#[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)]
274#[diag("circular modules: {$modules}")]
275pub(crate) struct ModuleCircular {
276 #[primary_span]
277 pub span: Span,
278 pub modules: String,
279}
280
281#[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)]
282#[diag("cannot declare a file module inside a block unless it has a path attribute")]
283#[note("file modules are usually placed outside of blocks, at the top level of the file")]
284pub(crate) struct ModuleInBlock {
285 #[primary_span]
286 pub span: Span,
287 #[subdiagnostic]
288 pub name: Option<ModuleInBlockName>,
289}
290
291#[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)]
292#[help("maybe `use` the module `{$name}` instead of redeclaring it")]
293pub(crate) struct ModuleInBlockName {
294 #[primary_span]
295 pub span: Span,
296 pub name: Ident,
297}
298
299#[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)]
300#[diag("file not found for module `{$name}`", code = E0583)]
301#[help("to create the module `{$name}`, create file \"{$default_path}\" or \"{$secondary_path}\"")]
302#[note(
303 "if there is a `mod {$name}` elsewhere in the crate already, import it with `use crate::...` instead"
304)]
305pub(crate) struct ModuleFileNotFound {
306 #[primary_span]
307 pub span: Span,
308 pub name: Ident,
309 pub default_path: String,
310 pub secondary_path: String,
311}
312
313#[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)]
314#[diag("file for module `{$name}` found at both \"{$default_path}\" and \"{$secondary_path}\"", code = E0761)]
315#[help("delete or rename one of them to remove the ambiguity")]
316pub(crate) struct ModuleMultipleCandidates {
317 #[primary_span]
318 pub span: Span,
319 pub name: Ident,
320 pub default_path: String,
321 pub secondary_path: String,
322}
323
324#[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)]
325#[diag("trace_macro")]
326pub(crate) struct TraceMacro {
327 #[primary_span]
328 pub span: Span,
329}
330
331#[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)]
332#[diag("proc macro panicked")]
333pub(crate) struct ProcMacroPanicked {
334 #[primary_span]
335 pub span: Span,
336 #[subdiagnostic]
337 pub message: Option<ProcMacroPanickedHelp>,
338}
339
340#[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)]
341#[help("message: {$message}")]
342pub(crate) struct ProcMacroPanickedHelp {
343 pub message: String,
344}
345
346#[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)]
347#[diag("proc-macro derive panicked")]
348pub(crate) struct ProcMacroDerivePanicked {
349 #[primary_span]
350 pub span: Span,
351 #[subdiagnostic]
352 pub message: Option<ProcMacroDerivePanickedHelp>,
353}
354
355#[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)]
356#[help("message: {$message}")]
357pub(crate) struct ProcMacroDerivePanickedHelp {
358 pub message: String,
359}
360
361#[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)]
362#[diag("custom attribute panicked")]
363pub(crate) struct CustomAttributePanicked {
364 #[primary_span]
365 pub span: Span,
366 #[subdiagnostic]
367 pub message: Option<CustomAttributePanickedHelp>,
368}
369
370#[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)]
371#[help("message: {$message}")]
372pub(crate) struct CustomAttributePanickedHelp {
373 pub message: String,
374}
375
376#[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)]
377#[diag("proc-macro derive produced unparsable tokens")]
378pub(crate) struct ProcMacroDeriveTokens {
379 #[primary_span]
380 pub span: Span,
381}
382
383#[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)]
384#[diag("duplicate matcher binding")]
385pub(crate) struct DuplicateMatcherBinding {
386 #[primary_span]
387 #[label("duplicate binding")]
388 pub span: Span,
389 #[label("previous binding")]
390 pub prev: Span,
391}
392
393#[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)]
394#[diag("duplicate matcher binding")]
395pub(crate) struct DuplicateMatcherBindingLint {
396 #[label("duplicate binding")]
397 pub span: Span,
398 #[label("previous binding")]
399 pub prev: Span,
400}
401
402#[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_4 =
[::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_4, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
403#[diag("missing fragment specifier")]
404#[note("fragment specifiers must be provided")]
405#[help("{$valid}")]
406pub(crate) struct MissingFragmentSpecifier {
407 #[primary_span]
408 pub span: Span,
409 #[suggestion(
410 "try adding a specifier here",
411 style = "verbose",
412 code = ":spec",
413 applicability = "maybe-incorrect"
414 )]
415 pub add_span: Span,
416 pub valid: &'static str,
417}
418
419#[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)]
420#[diag("invalid fragment specifier `{$fragment}`")]
421#[help("{$help}")]
422pub(crate) struct InvalidFragmentSpecifier {
423 #[primary_span]
424 pub span: Span,
425 pub fragment: Ident,
426 pub help: &'static str,
427}
428
429#[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)]
430#[diag("expected `(` or `{\"{\"}`, found `{$token}`")]
431pub(crate) struct ExpectedParenOrBrace<'a> {
432 #[primary_span]
433 pub span: Span,
434 pub token: Cow<'a, str>,
435}
436
437#[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)]
438#[diag("empty {$kind} delegation is not supported")]
439pub(crate) struct EmptyDelegationMac {
440 #[primary_span]
441 pub span: Span,
442 pub kind: String,
443}
444
445#[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)]
446#[diag("glob delegation is only supported in impls")]
447pub(crate) struct GlobDelegationOutsideImpls {
448 #[primary_span]
449 pub span: Span,
450}
451
452#[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("`crate_name` within an `#![cfg_attr]` attribute is forbidden")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
453#[diag("`crate_name` within an `#![cfg_attr]` attribute is forbidden")]
454pub(crate) struct CrateNameInCfgAttr {
455 #[primary_span]
456 pub span: Span,
457}
458
459#[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("`crate_type` within an `#![cfg_attr]` attribute is forbidden")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
460#[diag("`crate_type` within an `#![cfg_attr]` attribute is forbidden")]
461pub(crate) struct CrateTypeInCfgAttr {
462 #[primary_span]
463 pub span: Span,
464}
465
466#[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)]
467#[diag("qualified path without a trait in glob delegation")]
468pub(crate) struct GlobDelegationTraitlessQpath {
469 #[primary_span]
470 pub span: Span,
471}
472
473pub(crate) use metavar_exprs::*;
474mod metavar_exprs {
475 use super::*;
476
477 #[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_5 =
[::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_5, 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)]
478 #[diag("unexpected trailing tokens")]
479 pub(crate) struct MveExtraTokens {
480 #[primary_span]
481 #[suggestion(
482 "try removing {$extra_count ->
483 [one] this token
484 *[other] these tokens
485 }",
486 code = "",
487 applicability = "machine-applicable"
488 )]
489 pub span: Span,
490 #[label("for this metavariable expression")]
491 pub ident_span: Span,
492 pub extra_count: usize,
493
494 #[note(
497 "the `{$name}` metavariable expression takes {$min_or_exact_args ->
498 [zero] no arguments
499 [one] a single argument
500 *[other] {$min_or_exact_args} arguments
501 }"
502 )]
503 pub exact_args_note: Option<()>,
504 #[note(
505 "the `{$name}` metavariable expression takes between {$min_or_exact_args} and {$max_args} arguments"
506 )]
507 pub range_args_note: Option<()>,
508 pub min_or_exact_args: usize,
509 pub max_args: usize,
510 pub name: String,
511 }
512
513 #[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_6 =
[::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_6, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
514 #[note("metavariable expressions use function-like parentheses syntax")]
515 #[diag("expected `(`")]
516 pub(crate) struct MveMissingParen {
517 #[primary_span]
518 #[label("for this this metavariable expression")]
519 pub ident_span: Span,
520 #[label("unexpected token")]
521 pub unexpected_span: Option<Span>,
522 #[suggestion(
523 "try adding parentheses",
524 code = "( /* ... */ )",
525 applicability = "has-placeholders"
526 )]
527 pub insert_span: Option<Span>,
528 }
529
530 #[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)]
531 #[note("valid metavariable expressions are {$valid_expr_list}")]
532 #[diag("unrecognized metavariable expression")]
533 pub(crate) struct MveUnrecognizedExpr {
534 #[primary_span]
535 #[label("not a valid metavariable expression")]
536 pub span: Span,
537 pub valid_expr_list: &'static str,
538 }
539
540 #[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)]
541 #[diag("variable `{$key}` is not recognized in meta-variable expression")]
542 pub(crate) struct MveUnrecognizedVar {
543 #[primary_span]
544 pub span: Span,
545 pub key: MacroRulesNormalizedIdent,
546 }
547
548 #[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)]
549 #[diag(r#"`${"{"}concat(..){"}"}` is not generating a valid identifier"#)]
550 pub(crate) struct ConcatInvalidIdent {
551 #[primary_span]
552 pub span: Span,
553 #[subdiagnostic]
554 pub reason: InvalidIdentReason,
555 }
556
557 #[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)]
558 pub(crate) enum InvalidIdentReason {
559 #[note(r#"this `${"{"}concat(..){"}"}` invocation generated an empty ident"#)]
560 Empty,
561 #[note(r#"this `${"{"}concat(..){"}"}` invocation generated `{$symbol}`, but {$start} is neither '_' nor XID_Start"#)]
562 #[note(
563 "see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers"
564 )]
565 InvalidStart { symbol: Symbol, start: char },
566 #[note(r#"this `${"{"}concat(..){"}"}` invocation generated `{$symbol}`, but {$not_continue} is not XID_Continue"#)]
567 #[note(
568 "see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers"
569 )]
570 InvalidContinue { symbol: Symbol, not_continue: char },
571 }
572
573 impl InvalidIdentReason {
574 pub(crate) fn new(symbol: Symbol) -> Self {
575 let mut chars = symbol.as_str().chars();
576 if let Some(start) = chars.next() {
577 if rustc_lexer::is_id_start(start) {
578 let not_continue = chars
579 .find(|c| !rustc_lexer::is_id_continue(*c))
580 .expect("InvalidIdentReason: cannot find invalid ident reason");
581 InvalidIdentReason::InvalidContinue { symbol, not_continue }
582 } else {
583 InvalidIdentReason::InvalidStart { symbol, start }
584 }
585 } else {
586 InvalidIdentReason::Empty
587 }
588 }
589 }
590}
591
592#[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)]
593#[diag("`{$rule_kw}` rule argument matchers require parentheses")]
594pub(crate) struct MacroArgsBadDelim {
595 #[primary_span]
596 pub span: Span,
597 #[subdiagnostic]
598 pub sugg: MacroArgsBadDelimSugg,
599 pub rule_kw: Symbol,
600}
601
602#[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_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_7));
suggestions.push((__binding_1, __code_8));
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)]
603#[multipart_suggestion(
604 "the delimiters should be `(` and `)`",
605 applicability = "machine-applicable"
606)]
607pub(crate) struct MacroArgsBadDelimSugg {
608 #[suggestion_part(code = "(")]
609 pub open: Span,
610 #[suggestion_part(code = ")")]
611 pub close: Span,
612}
613
614#[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)]
615#[diag("unused doc comment")]
616#[help(
617 "to document an item produced by a macro, the macro must produce the documentation as part of its expansion"
618)]
619pub(crate) struct MacroCallUnusedDocComment {
620 #[label("rustdoc does not generate documentation for macro invocations")]
621 pub span: Span,
622}
623
624#[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_9 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("suggestion", __binding_1);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use pat_param to preserve semantics")),
__code_9, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
625#[diag(
626 "the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro"
627)]
628pub(crate) struct OrPatternsBackCompat {
629 #[suggestion(
630 "use pat_param to preserve semantics",
631 code = "{suggestion}",
632 applicability = "machine-applicable"
633 )]
634 pub span: Span,
635 pub suggestion: String,
636}
637
638#[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)]
639#[diag("trailing semicolon in macro used in expression position")]
640pub(crate) struct TrailingMacro {
641 #[note("macro invocations at the end of a block are treated as expressions")]
642 #[note(
643 "to ignore the value produced by the macro, add a semicolon after the invocation of `{$name}`"
644 )]
645 pub is_trailing: bool,
646 pub name: Ident,
647}
648
649#[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_10 =
[::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_10, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
650#[diag("unused attribute `{$attr_name}`")]
651pub(crate) struct UnusedBuiltinAttribute {
652 #[note(
653 "the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`"
654 )]
655 pub invoc_span: Span,
656 pub attr_name: Symbol,
657 pub macro_name: String,
658 #[suggestion(
659 "remove the attribute",
660 code = "",
661 applicability = "machine-applicable",
662 style = "tool-only"
663 )]
664 pub attr_span: Span,
665}