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