1use std::io::Error;
2use std::path::{Path, PathBuf};
3
4use rustc_errors::codes::*;
5use rustc_errors::{
6 Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
7 MultiSpan, inline_fluent,
8};
9use rustc_hir::Target;
10use rustc_hir::attrs::{MirDialect, MirPhase};
11use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
12use rustc_middle::ty::{MainDefinition, Ty};
13use rustc_span::{DUMMY_SP, Span, Symbol};
14
15use crate::check_attr::ProcMacroKind;
16use crate::lang_items::Duplicate;
17
18#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
IncorrectDoNotRecommendLocation {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
IncorrectDoNotRecommendLocation => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[diagnostic::do_not_recommend]` can only be placed on trait implementations")));
;
diag
}
};
}
}
};LintDiagnostic)]
19#[diag("`#[diagnostic::do_not_recommend]` can only be placed on trait implementations")]
20pub(crate) struct IncorrectDoNotRecommendLocation;
21
22#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AutoDiffAttr
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 {
AutoDiffAttr { attr_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[autodiff]` should be applied to a function")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a function")));
diag
}
}
}
}
};Diagnostic)]
23#[diag("`#[autodiff]` should be applied to a function")]
24pub(crate) struct AutoDiffAttr {
25 #[primary_span]
26 #[label("not a function")]
27 pub attr_span: Span,
28}
29
30#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LoopMatchAttr
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 {
LoopMatchAttr {
attr_span: __binding_0, node_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[loop_match]` should be applied to a loop")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a loop")));
diag
}
}
}
}
};Diagnostic)]
31#[diag("`#[loop_match]` should be applied to a loop")]
32pub(crate) struct LoopMatchAttr {
33 #[primary_span]
34 pub attr_span: Span,
35 #[label("not a loop")]
36 pub node_span: Span,
37}
38
39#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstContinueAttr 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 {
ConstContinueAttr {
attr_span: __binding_0, node_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[const_continue]` should be applied to a break expression")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a break expression")));
diag
}
}
}
}
};Diagnostic)]
40#[diag("`#[const_continue]` should be applied to a break expression")]
41pub(crate) struct ConstContinueAttr {
42 #[primary_span]
43 pub attr_span: Span,
44 #[label("not a break expression")]
45 pub node_span: Span,
46}
47
48#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
MixedExportNameAndNoMangle {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MixedExportNameAndNoMangle {
no_mangle_span: __binding_0,
export_name_span: __binding_1,
no_mangle_attr: __binding_2,
export_name_attr: __binding_3 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$no_mangle_attr}` attribute may not be used in combination with `{$export_name_attr}`")));
;
let __code_0 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.arg("no_mangle_attr", __binding_2);
diag.arg("export_name_attr", __binding_3);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$no_mangle_attr}` is ignored")));
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `{$no_mangle_attr}` attribute")),
__code_0, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$export_name_attr}` takes precedence")));
diag
}
};
}
}
};LintDiagnostic)]
49#[diag("`{$no_mangle_attr}` attribute may not be used in combination with `{$export_name_attr}`")]
50pub(crate) struct MixedExportNameAndNoMangle {
51 #[label("`{$no_mangle_attr}` is ignored")]
52 #[suggestion(
53 "remove the `{$no_mangle_attr}` attribute",
54 style = "verbose",
55 code = "",
56 applicability = "machine-applicable"
57 )]
58 pub no_mangle_span: Span,
59 #[note("`{$export_name_attr}` takes precedence")]
60 pub export_name_span: Span,
61 pub no_mangle_attr: &'static str,
62 pub export_name_attr: &'static str,
63}
64
65#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
OuterCrateLevelAttr {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
OuterCrateLevelAttr { suggestion: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate-level attribute should be an inner attribute")));
;
diag.subdiagnostic(__binding_0);
diag
}
};
}
}
};LintDiagnostic)]
66#[diag("crate-level attribute should be an inner attribute")]
67pub(crate) struct OuterCrateLevelAttr {
68 #[subdiagnostic]
69 pub suggestion: OuterCrateLevelAttrSuggestion,
70}
71
72#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for OuterCrateLevelAttrSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OuterCrateLevelAttrSuggestion { bang_position: __binding_0 }
=> {
let mut suggestions = Vec::new();
let __code_1 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("!"))
});
suggestions.push((__binding_0, __code_1));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a `!`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::Unspecified,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
73#[multipart_suggestion("add a `!`", style = "verbose")]
74pub(crate) struct OuterCrateLevelAttrSuggestion {
75 #[suggestion_part(code = "!")]
76 pub bang_position: Span,
77}
78
79#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
InnerCrateLevelAttr {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
InnerCrateLevelAttr => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate-level attribute should be in the root module")));
;
diag
}
};
}
}
};LintDiagnostic)]
80#[diag("crate-level attribute should be in the root module")]
81pub(crate) struct InnerCrateLevelAttr;
82
83#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NonExhaustiveWithDefaultFieldValues 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 {
NonExhaustiveWithDefaultFieldValues {
attr_span: __binding_0, defn_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[non_exhaustive]` can't be used to annotate items with default field values")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this struct has default field values")));
diag
}
}
}
}
};Diagnostic)]
84#[diag("`#[non_exhaustive]` can't be used to annotate items with default field values")]
85pub(crate) struct NonExhaustiveWithDefaultFieldValues {
86 #[primary_span]
87 pub attr_span: Span,
88 #[label("this struct has default field values")]
89 pub defn_span: Span,
90}
91
92#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DocAliasBadLocation<'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 {
DocAliasBadLocation {
span: __binding_0, location: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc(alias = \"...\")]` isn't allowed on {$location}")));
;
diag.arg("location", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
93#[diag("`#[doc(alias = \"...\")]` isn't allowed on {$location}")]
94pub(crate) struct DocAliasBadLocation<'a> {
95 #[primary_span]
96 pub span: Span,
97 pub location: &'a str,
98}
99
100#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocAliasNotAnAlias 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 {
DocAliasNotAnAlias {
span: __binding_0, attr_str: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc(alias = \"{$attr_str}\"]` is the same as the item's name")));
;
diag.arg("attr_str", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
101#[diag("`#[doc(alias = \"{$attr_str}\"]` is the same as the item's name")]
102pub(crate) struct DocAliasNotAnAlias {
103 #[primary_span]
104 pub span: Span,
105 pub attr_str: Symbol,
106}
107
108#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocKeywordAttributeEmptyMod 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 {
DocKeywordAttributeEmptyMod {
span: __binding_0, attr_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc({$attr_name} = \"...\")]` should be used on empty modules")));
;
diag.arg("attr_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
109#[diag("`#[doc({$attr_name} = \"...\")]` should be used on empty modules")]
110pub(crate) struct DocKeywordAttributeEmptyMod {
111 #[primary_span]
112 pub span: Span,
113 pub attr_name: &'static str,
114}
115
116#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocKeywordAttributeNotMod 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 {
DocKeywordAttributeNotMod {
span: __binding_0, attr_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc({$attr_name} = \"...\")]` should be used on modules")));
;
diag.arg("attr_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
117#[diag("`#[doc({$attr_name} = \"...\")]` should be used on modules")]
118pub(crate) struct DocKeywordAttributeNotMod {
119 #[primary_span]
120 pub span: Span,
121 pub attr_name: &'static str,
122}
123
124#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocFakeVariadicNotValid 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 {
DocFakeVariadicNotValid { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc(fake_variadic)]` must be used on the first of a set of tuple or fn pointer trait impls with varying arity")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
125#[diag(
126 "`#[doc(fake_variadic)]` must be used on the first of a set of tuple or fn pointer trait impls with varying arity"
127)]
128pub(crate) struct DocFakeVariadicNotValid {
129 #[primary_span]
130 pub span: Span,
131}
132
133#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocKeywordOnlyImpl 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 {
DocKeywordOnlyImpl { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc(keyword = \"...\")]` should be used on impl blocks")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
134#[diag("`#[doc(keyword = \"...\")]` should be used on impl blocks")]
135pub(crate) struct DocKeywordOnlyImpl {
136 #[primary_span]
137 pub span: Span,
138}
139
140#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocSearchUnboxInvalid 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 {
DocSearchUnboxInvalid { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc(search_unbox)]` should be used on generic structs and enums")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
141#[diag("`#[doc(search_unbox)]` should be used on generic structs and enums")]
142pub(crate) struct DocSearchUnboxInvalid {
143 #[primary_span]
144 pub span: Span,
145}
146
147#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocInlineConflict 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 {
DocInlineConflict { spans: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("conflicting doc inlining attributes")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove one of the conflicting attributes")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
148#[diag("conflicting doc inlining attributes")]
149#[help("remove one of the conflicting attributes")]
150pub(crate) struct DocInlineConflict {
151 #[primary_span]
152 pub spans: MultiSpan,
153}
154
155#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for DocInlineOnlyUse
{
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
DocInlineOnlyUse {
attr_span: __binding_0, item_span: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this attribute can only be applied to a `use` item")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#inline-and-no_inline> for more information")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only applicable on `use` items")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a `use` item")));
diag
}
};
}
}
};LintDiagnostic)]
156#[diag("this attribute can only be applied to a `use` item")]
157#[note(
158 "read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#inline-and-no_inline> for more information"
159)]
160pub(crate) struct DocInlineOnlyUse {
161 #[label("only applicable on `use` items")]
162 pub attr_span: Span,
163 #[label("not a `use` item")]
164 pub item_span: Span,
165}
166
167#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
DocMaskedOnlyExternCrate {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
DocMaskedOnlyExternCrate {
attr_span: __binding_0, item_span: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this attribute can only be applied to an `extern crate` item")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only applicable on `extern crate` items")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not an `extern crate` item")));
diag
}
};
}
}
};LintDiagnostic)]
168#[diag("this attribute can only be applied to an `extern crate` item")]
169#[note(
170 "read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information"
171)]
172pub(crate) struct DocMaskedOnlyExternCrate {
173 #[label("only applicable on `extern crate` items")]
174 pub attr_span: Span,
175 #[label("not an `extern crate` item")]
176 pub item_span: Span,
177}
178
179#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
DocMaskedNotExternCrateSelf {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
DocMaskedNotExternCrateSelf {
attr_span: __binding_0, item_span: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this attribute cannot be applied to an `extern crate self` item")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not applicable on `extern crate self` items")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern crate self` defined here")));
diag
}
};
}
}
};LintDiagnostic)]
180#[diag("this attribute cannot be applied to an `extern crate self` item")]
181pub(crate) struct DocMaskedNotExternCrateSelf {
182 #[label("not applicable on `extern crate self` items")]
183 pub attr_span: Span,
184 #[label("`extern crate self` defined here")]
185 pub item_span: Span,
186}
187
188#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BothFfiConstAndPure 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 {
BothFfiConstAndPure { attr_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[ffi_const]` function cannot be `#[ffi_pure]`")));
diag.code(E0757);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
189#[diag("`#[ffi_const]` function cannot be `#[ffi_pure]`", code = E0757)]
190pub(crate) struct BothFfiConstAndPure {
191 #[primary_span]
192 pub attr_span: Span,
193}
194
195#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for Link {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
Link { span: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to an `extern` block with non-Rust ABI")));
diag.warn(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!")));
;
if let Some(__binding_0) = __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not an `extern` block")));
}
diag
}
};
}
}
};LintDiagnostic)]
196#[diag("attribute should be applied to an `extern` block with non-Rust ABI")]
197#[warning(
198 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
199)]
200pub(crate) struct Link {
201 #[label("not an `extern` block")]
202 pub span: Option<Span>,
203}
204
205#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcLegacyConstGenericsOnly 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 {
RustcLegacyConstGenericsOnly {
attr_span: __binding_0, param_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("#[rustc_legacy_const_generics] functions must only have const generics")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-const generic parameter")));
diag
}
}
}
}
};Diagnostic)]
206#[diag("#[rustc_legacy_const_generics] functions must only have const generics")]
207pub(crate) struct RustcLegacyConstGenericsOnly {
208 #[primary_span]
209 pub attr_span: Span,
210 #[label("non-const generic parameter")]
211 pub param_span: Span,
212}
213
214#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcLegacyConstGenericsIndex 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 {
RustcLegacyConstGenericsIndex {
attr_span: __binding_0, generics_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("#[rustc_legacy_const_generics] must have one index for each generic parameter")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic parameters")));
diag
}
}
}
}
};Diagnostic)]
215#[diag("#[rustc_legacy_const_generics] must have one index for each generic parameter")]
216pub(crate) struct RustcLegacyConstGenericsIndex {
217 #[primary_span]
218 pub attr_span: Span,
219 #[label("generic parameters")]
220 pub generics_span: Span,
221}
222
223#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcLegacyConstGenericsIndexExceed 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 {
RustcLegacyConstGenericsIndexExceed {
span: __binding_0, arg_count: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("index exceeds number of arguments")));
;
diag.arg("arg_count", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there {$arg_count ->\n [one] is\n *[other] are\n } only {$arg_count} {$arg_count ->\n [one] argument\n *[other] arguments\n }")));
diag
}
}
}
}
};Diagnostic)]
224#[diag("index exceeds number of arguments")]
225pub(crate) struct RustcLegacyConstGenericsIndexExceed {
226 #[primary_span]
227 #[label(
228 "there {$arg_count ->
229 [one] is
230 *[other] are
231 } only {$arg_count} {$arg_count ->
232 [one] argument
233 *[other] arguments
234 }"
235 )]
236 pub span: Span,
237 pub arg_count: usize,
238}
239
240#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReprConflicting 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 {
ReprConflicting { hint_spans: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("conflicting representation hints")));
diag.code(E0566);
;
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
241#[diag("conflicting representation hints", code = E0566)]
242pub(crate) struct ReprConflicting {
243 #[primary_span]
244 pub hint_spans: Vec<Span>,
245}
246
247#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidReprAlignForTarget 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 {
InvalidReprAlignForTarget {
span: __binding_0, size: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alignment must not be greater than `isize::MAX` bytes")));
diag.code(E0589);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`isize::MAX` is {$size} for the current target")));
;
diag.arg("size", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
248#[diag("alignment must not be greater than `isize::MAX` bytes", code = E0589)]
249#[note("`isize::MAX` is {$size} for the current target")]
250pub(crate) struct InvalidReprAlignForTarget {
251 #[primary_span]
252 pub span: Span,
253 pub size: u64,
254}
255
256#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
ReprConflictingLint {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
ReprConflictingLint => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("conflicting representation hints")));
diag.code(E0566);
;
diag
}
};
}
}
};LintDiagnostic)]
257#[diag("conflicting representation hints", code = E0566)]
258pub(crate) struct ReprConflictingLint;
259
260#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroOnlyAttribute 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 {
MacroOnlyAttribute {
attr_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to a macro")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a macro")));
diag
}
}
}
}
};Diagnostic)]
261#[diag("attribute should be applied to a macro")]
262pub(crate) struct MacroOnlyAttribute {
263 #[primary_span]
264 pub attr_span: Span,
265 #[label("not a macro")]
266 pub span: Span,
267}
268
269#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DebugVisualizerUnreadable<'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 {
DebugVisualizerUnreadable {
span: __binding_0, file: __binding_1, error: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("couldn't read {$file}: {$error}")));
;
diag.arg("file", __binding_1);
diag.arg("error", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
270#[diag("couldn't read {$file}: {$error}")]
271pub(crate) struct DebugVisualizerUnreadable<'a> {
272 #[primary_span]
273 pub span: Span,
274 pub file: &'a Path,
275 pub error: Error,
276}
277
278#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcAllowConstFnUnstable 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 {
RustcAllowConstFnUnstable {
attr_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to `const fn`")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a `const fn`")));
diag
}
}
}
}
};Diagnostic)]
279#[diag("attribute should be applied to `const fn`")]
280pub(crate) struct RustcAllowConstFnUnstable {
281 #[primary_span]
282 pub attr_span: Span,
283 #[label("not a `const fn`")]
284 pub span: Span,
285}
286
287#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcPubTransparent 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 {
RustcPubTransparent {
attr_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to `#[repr(transparent)]` types")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a `#[repr(transparent)]` type")));
diag
}
}
}
}
};Diagnostic)]
288#[diag("attribute should be applied to `#[repr(transparent)]` types")]
289pub(crate) struct RustcPubTransparent {
290 #[primary_span]
291 pub attr_span: Span,
292 #[label("not a `#[repr(transparent)]` type")]
293 pub span: Span,
294}
295
296#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcForceInlineCoro 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 {
RustcForceInlineCoro {
attr_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute cannot be applied to a `async`, `gen` or `async gen` function")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`async`, `gen` or `async gen` function")));
diag
}
}
}
}
};Diagnostic)]
297#[diag("attribute cannot be applied to a `async`, `gen` or `async gen` function")]
298pub(crate) struct RustcForceInlineCoro {
299 #[primary_span]
300 pub attr_span: Span,
301 #[label("`async`, `gen` or `async gen` function")]
302 pub span: Span,
303}
304
305#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for MacroExport {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MacroExport::OnDeclMacro => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[macro_export]` has no effect on declarative macro definitions")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declarative macros follow the same exporting rules as regular items")));
;
diag
}
};
}
}
};LintDiagnostic)]
306pub(crate) enum MacroExport {
307 #[diag("`#[macro_export]` has no effect on declarative macro definitions")]
308 #[note("declarative macros follow the same exporting rules as regular items")]
309 OnDeclMacro,
310}
311
312#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnusedNote::EmptyList { name: __binding_0 } => {
diag.store_args();
diag.arg("name", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute `{$name}` with an empty list has no effect")));
diag.note(__message);
diag.restore_args();
}
UnusedNote::NoLints { name: __binding_0 } => {
diag.store_args();
diag.arg("name", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute `{$name}` without any lints has no effect")));
diag.note(__message);
diag.restore_args();
}
UnusedNote::DefaultMethodBodyConst => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`default_method_body_is_const` has been replaced with `const` on traits")));
diag.note(__message);
diag.restore_args();
}
UnusedNote::LinkerMessagesBinaryCrateOnly => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `linker_messages` lint can only be controlled at the root of a crate that needs to be linked")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
313pub(crate) enum UnusedNote {
314 #[note("attribute `{$name}` with an empty list has no effect")]
315 EmptyList { name: Symbol },
316 #[note("attribute `{$name}` without any lints has no effect")]
317 NoLints { name: Symbol },
318 #[note("`default_method_body_is_const` has been replaced with `const` on traits")]
319 DefaultMethodBodyConst,
320 #[note(
321 "the `linker_messages` lint can only be controlled at the root of a crate that needs to be linked"
322 )]
323 LinkerMessagesBinaryCrateOnly,
324}
325
326#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for Unused {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
Unused { attr_span: __binding_0, note: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused attribute")));
;
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this attribute")),
__code_2, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.subdiagnostic(__binding_1);
diag
}
};
}
}
};LintDiagnostic)]
327#[diag("unused attribute")]
328pub(crate) struct Unused {
329 #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
330 pub attr_span: Span,
331 #[subdiagnostic]
332 pub note: UnusedNote,
333}
334
335#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NonExportedMacroInvalidAttrs 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 {
NonExportedMacroInvalidAttrs { attr_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to function or closure")));
diag.code(E0518);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a function or closure")));
diag
}
}
}
}
};Diagnostic)]
336#[diag("attribute should be applied to function or closure", code = E0518)]
337pub(crate) struct NonExportedMacroInvalidAttrs {
338 #[primary_span]
339 #[label("not a function or closure")]
340 pub attr_span: Span,
341}
342
343#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidMayDangle 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 {
InvalidMayDangle { attr_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[may_dangle]` must be applied to a lifetime or type generic parameter in `Drop` impl")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
344#[diag("`#[may_dangle]` must be applied to a lifetime or type generic parameter in `Drop` impl")]
345pub(crate) struct InvalidMayDangle {
346 #[primary_span]
347 pub attr_span: Span,
348}
349
350#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for UnusedDuplicate
{
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnusedDuplicate {
this: __binding_0, other: __binding_1, warning: __binding_2
} => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused attribute")));
;
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this attribute")),
__code_3, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute also specified here")));
if __binding_2 {
diag.warn(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!")));
}
diag
}
};
}
}
};LintDiagnostic)]
351#[diag("unused attribute")]
352pub(crate) struct UnusedDuplicate {
353 #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
354 pub this: Span,
355 #[note("attribute also specified here")]
356 pub other: Span,
357 #[warning(
358 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
359 )]
360 pub warning: bool,
361}
362
363#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnusedMultiple
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 {
UnusedMultiple {
this: __binding_0, other: __binding_1, name: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple `{$name}` attributes")));
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this attribute")),
__code_4, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute also specified here")));
diag
}
}
}
}
};Diagnostic)]
364#[diag("multiple `{$name}` attributes")]
365pub(crate) struct UnusedMultiple {
366 #[primary_span]
367 #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
368 pub this: Span,
369 #[note("attribute also specified here")]
370 pub other: Span,
371 pub name: Symbol,
372}
373
374#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
DeprecatedAnnotationHasNoEffect {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
DeprecatedAnnotationHasNoEffect { span: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `#[deprecated]` annotation has no effect")));
;
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the unnecessary deprecation attribute")),
__code_5, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
};
}
}
};LintDiagnostic)]
375#[diag("this `#[deprecated]` annotation has no effect")]
376pub(crate) struct DeprecatedAnnotationHasNoEffect {
377 #[suggestion(
378 "remove the unnecessary deprecation attribute",
379 applicability = "machine-applicable",
380 code = ""
381 )]
382 pub span: Span,
383}
384
385#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownExternLangItem 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 {
UnknownExternLangItem {
span: __binding_0, lang_item: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown external lang item: `{$lang_item}`")));
diag.code(E0264);
;
diag.arg("lang_item", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
386#[diag("unknown external lang item: `{$lang_item}`", code = E0264)]
387pub(crate) struct UnknownExternLangItem {
388 #[primary_span]
389 pub span: Span,
390 pub lang_item: Symbol,
391}
392
393#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingPanicHandler 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 {
MissingPanicHandler => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[panic_handler]` function required, but not found")));
;
diag
}
}
}
}
};Diagnostic)]
394#[diag("`#[panic_handler]` function required, but not found")]
395pub(crate) struct MissingPanicHandler;
396
397#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PanicUnwindWithoutStd 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 {
PanicUnwindWithoutStd => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unwinding panics are not supported without std")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using nightly cargo, use -Zbuild-std with panic=\"abort\" to avoid unwinding")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("since the core library is usually precompiled with panic=\"unwind\", rebuilding your crate with panic=\"abort\" may not be enough to fix the problem")));
;
diag
}
}
}
}
};Diagnostic)]
398#[diag("unwinding panics are not supported without std")]
399#[help("using nightly cargo, use -Zbuild-std with panic=\"abort\" to avoid unwinding")]
400#[note(
401 "since the core library is usually precompiled with panic=\"unwind\", rebuilding your crate with panic=\"abort\" may not be enough to fix the problem"
402)]
403pub(crate) struct PanicUnwindWithoutStd;
404
405#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingLangItem 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 {
MissingLangItem { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lang item required, but not found: `{$name}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this can occur when a binary crate with `#![no_std]` is compiled for a target where `{$name}` is defined in the standard library")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you may be able to compile for a target that doesn't need `{$name}`, specify a target with `--target` or in `.cargo/config`")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
406#[diag("lang item required, but not found: `{$name}`")]
407#[note(
408 "this can occur when a binary crate with `#![no_std]` is compiled for a target where `{$name}` is defined in the standard library"
409)]
410#[help(
411 "you may be able to compile for a target that doesn't need `{$name}`, specify a target with `--target` or in `.cargo/config`"
412)]
413pub(crate) struct MissingLangItem {
414 pub name: Symbol,
415}
416
417#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LangItemWithTrackCaller 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 {
LangItemWithTrackCaller {
attr_span: __binding_0,
name: __binding_1,
sig_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$name ->\n [panic_impl] `#[panic_handler]`\n *[other] `{$name}` lang item\n} function is not allowed to have `#[track_caller]`")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$name ->\n [panic_impl] `#[panic_handler]`\n *[other] `{$name}` lang item\n } function is not allowed to have `#[track_caller]`")));
diag
}
}
}
}
};Diagnostic)]
418#[diag(
419 "{$name ->
420 [panic_impl] `#[panic_handler]`
421 *[other] `{$name}` lang item
422} function is not allowed to have `#[track_caller]`"
423)]
424pub(crate) struct LangItemWithTrackCaller {
425 #[primary_span]
426 pub attr_span: Span,
427 pub name: Symbol,
428 #[label(
429 "{$name ->
430 [panic_impl] `#[panic_handler]`
431 *[other] `{$name}` lang item
432 } function is not allowed to have `#[track_caller]`"
433 )]
434 pub sig_span: Span,
435}
436
437#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LangItemWithTargetFeature 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 {
LangItemWithTargetFeature {
attr_span: __binding_0,
name: __binding_1,
sig_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$name ->\n [panic_impl] `#[panic_handler]`\n *[other] `{$name}` lang item\n } function is not allowed to have `#[target_feature]`")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$name ->\n [panic_impl] `#[panic_handler]`\n *[other] `{$name}` lang item\n } function is not allowed to have `#[target_feature]`")));
diag
}
}
}
}
};Diagnostic)]
438#[diag(
439 "{$name ->
440 [panic_impl] `#[panic_handler]`
441 *[other] `{$name}` lang item
442 } function is not allowed to have `#[target_feature]`"
443)]
444pub(crate) struct LangItemWithTargetFeature {
445 #[primary_span]
446 pub attr_span: Span,
447 pub name: Symbol,
448 #[label(
449 "{$name ->
450 [panic_impl] `#[panic_handler]`
451 *[other] `{$name}` lang item
452 } function is not allowed to have `#[target_feature]`"
453 )]
454 pub sig_span: Span,
455}
456
457#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LangItemOnIncorrectTarget 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 {
LangItemOnIncorrectTarget {
span: __binding_0,
name: __binding_1,
expected_target: __binding_2,
actual_target: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` lang item must be applied to a {$expected_target}")));
diag.code(E0718);
;
diag.arg("name", __binding_1);
diag.arg("expected_target", __binding_2);
diag.arg("actual_target", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to a {$expected_target}, not a {$actual_target}")));
diag
}
}
}
}
};Diagnostic)]
458#[diag("`{$name}` lang item must be applied to a {$expected_target}", code = E0718)]
459pub(crate) struct LangItemOnIncorrectTarget {
460 #[primary_span]
461 #[label("attribute should be applied to a {$expected_target}, not a {$actual_target}")]
462 pub span: Span,
463 pub name: Symbol,
464 pub expected_target: Target,
465 pub actual_target: Target,
466}
467
468#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownLangItem 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 {
UnknownLangItem { span: __binding_0, name: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("definition of an unknown lang item: `{$name}`")));
diag.code(E0522);
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("definition of unknown lang item `{$name}`")));
diag
}
}
}
}
};Diagnostic)]
469#[diag("definition of an unknown lang item: `{$name}`", code = E0522)]
470pub(crate) struct UnknownLangItem {
471 #[primary_span]
472 #[label("definition of unknown lang item `{$name}`")]
473 pub span: Span,
474 pub name: Symbol,
475}
476
477pub(crate) struct InvalidAttrAtCrateLevel {
478 pub span: Span,
479 pub sugg_span: Option<Span>,
480 pub name: Symbol,
481 pub item: Option<ItemFollowingInnerAttr>,
482}
483
484#[derive(#[automatically_derived]
impl ::core::clone::Clone for ItemFollowingInnerAttr {
#[inline]
fn clone(&self) -> ItemFollowingInnerAttr {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'static str>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ItemFollowingInnerAttr { }Copy)]
485pub(crate) struct ItemFollowingInnerAttr {
486 pub span: Span,
487 pub kind: &'static str,
488}
489
490impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidAttrAtCrateLevel {
491 #[track_caller]
492 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
493 let mut diag = Diag::new(
494 dcx,
495 level,
496 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` attribute cannot be used at crate level"))inline_fluent!("`{$name}` attribute cannot be used at crate level"),
497 );
498 diag.span(self.span);
499 diag.arg("name", self.name);
500 if let Some(span) = self.sugg_span {
503 diag.span_suggestion_verbose(
504 span,
505 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("perhaps you meant to use an outer attribute"))inline_fluent!("perhaps you meant to use an outer attribute"),
506 String::new(),
507 Applicability::MachineApplicable,
508 );
509 }
510 if let Some(item) = self.item {
511 diag.arg("kind", item.kind);
512 diag.span_label(
513 item.span,
514 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the inner attribute doesn't annotate this {$kind}"))inline_fluent!("the inner attribute doesn't annotate this {$kind}"),
515 );
516 }
517 diag
518 }
519}
520
521#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DuplicateDiagnosticItemInCrate 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 {
DuplicateDiagnosticItemInCrate {
duplicate_span: __binding_0,
orig_span: __binding_1,
different_crates: __binding_2,
crate_name: __binding_3,
orig_crate_name: __binding_4,
name: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate diagnostic item in crate `{$crate_name}`: `{$name}`")));
;
diag.arg("crate_name", __binding_3);
diag.arg("orig_crate_name", __binding_4);
diag.arg("name", __binding_5);
if let Some(__binding_0) = __binding_0 {
diag.span(__binding_0);
}
if let Some(__binding_1) = __binding_1 {
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the diagnostic item is first defined here")));
}
if __binding_2 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the diagnostic item is first defined in crate `{$orig_crate_name}`")));
}
diag
}
}
}
}
};Diagnostic)]
522#[diag("duplicate diagnostic item in crate `{$crate_name}`: `{$name}`")]
523pub(crate) struct DuplicateDiagnosticItemInCrate {
524 #[primary_span]
525 pub duplicate_span: Option<Span>,
526 #[note("the diagnostic item is first defined here")]
527 pub orig_span: Option<Span>,
528 #[note("the diagnostic item is first defined in crate `{$orig_crate_name}`")]
529 pub different_crates: bool,
530 pub crate_name: Symbol,
531 pub orig_crate_name: Symbol,
532 pub name: Symbol,
533}
534
535#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LayoutAbi
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 {
LayoutAbi { span: __binding_0, abi: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("abi: {$abi}")));
;
diag.arg("abi", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
536#[diag("abi: {$abi}")]
537pub(crate) struct LayoutAbi {
538 #[primary_span]
539 pub span: Span,
540 pub abi: String,
541}
542
543#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LayoutAlign
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 {
LayoutAlign { span: __binding_0, align: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("align: {$align}")));
;
diag.arg("align", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
544#[diag("align: {$align}")]
545pub(crate) struct LayoutAlign {
546 #[primary_span]
547 pub span: Span,
548 pub align: String,
549}
550
551#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LayoutSize
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 {
LayoutSize { span: __binding_0, size: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("size: {$size}")));
;
diag.arg("size", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
552#[diag("size: {$size}")]
553pub(crate) struct LayoutSize {
554 #[primary_span]
555 pub span: Span,
556 pub size: String,
557}
558
559#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LayoutHomogeneousAggregate 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 {
LayoutHomogeneousAggregate {
span: __binding_0, homogeneous_aggregate: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("homogeneous_aggregate: {$homogeneous_aggregate}")));
;
diag.arg("homogeneous_aggregate", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
560#[diag("homogeneous_aggregate: {$homogeneous_aggregate}")]
561pub(crate) struct LayoutHomogeneousAggregate {
562 #[primary_span]
563 pub span: Span,
564 pub homogeneous_aggregate: String,
565}
566
567#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
LayoutOf<'tcx> 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 {
LayoutOf {
span: __binding_0,
normalized_ty: __binding_1,
ty_layout: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("layout_of({$normalized_ty}) = {$ty_layout}")));
;
diag.arg("normalized_ty", __binding_1);
diag.arg("ty_layout", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
568#[diag("layout_of({$normalized_ty}) = {$ty_layout}")]
569pub(crate) struct LayoutOf<'tcx> {
570 #[primary_span]
571 pub span: Span,
572 pub normalized_ty: Ty<'tcx>,
573 pub ty_layout: String,
574}
575
576#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AbiOf 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 {
AbiOf {
span: __binding_0, fn_name: __binding_1, fn_abi: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fn_abi_of({$fn_name}) = {$fn_abi}")));
;
diag.arg("fn_name", __binding_1);
diag.arg("fn_abi", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
577#[diag("fn_abi_of({$fn_name}) = {$fn_abi}")]
578pub(crate) struct AbiOf {
579 #[primary_span]
580 pub span: Span,
581 pub fn_name: Symbol,
582 pub fn_abi: String,
583}
584
585#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for AbiNe 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 {
AbiNe {
span: __binding_0, left: __binding_1, right: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ABIs are not compatible\n left ABI = {$left}\n right ABI = {$right}")));
;
diag.arg("left", __binding_1);
diag.arg("right", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
586#[diag(
587 "ABIs are not compatible
588 left ABI = {$left}
589 right ABI = {$right}"
590)]
591pub(crate) struct AbiNe {
592 #[primary_span]
593 pub span: Span,
594 pub left: String,
595 pub right: String,
596}
597
598#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AbiInvalidAttribute 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 {
AbiInvalidAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[rustc_abi]` can only be applied to function items, type aliases, and associated functions")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
599#[diag(
600 "`#[rustc_abi]` can only be applied to function items, type aliases, and associated functions"
601)]
602pub(crate) struct AbiInvalidAttribute {
603 #[primary_span]
604 pub span: Span,
605}
606
607#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnrecognizedArgument 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 {
UnrecognizedArgument { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unrecognized argument")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
608#[diag("unrecognized argument")]
609pub(crate) struct UnrecognizedArgument {
610 #[primary_span]
611 pub span: Span,
612}
613
614#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FeatureStableTwice 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 {
FeatureStableTwice {
span: __binding_0,
feature: __binding_1,
since: __binding_2,
prev_since: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature `{$feature}` is declared stable since {$since}, but was previously declared stable since {$prev_since}")));
diag.code(E0711);
;
diag.arg("feature", __binding_1);
diag.arg("since", __binding_2);
diag.arg("prev_since", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
615#[diag("feature `{$feature}` is declared stable since {$since}, but was previously declared stable since {$prev_since}", code = E0711)]
616pub(crate) struct FeatureStableTwice {
617 #[primary_span]
618 pub span: Span,
619 pub feature: Symbol,
620 pub since: Symbol,
621 pub prev_since: Symbol,
622}
623
624#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
FeaturePreviouslyDeclared<'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 {
FeaturePreviouslyDeclared {
span: __binding_0,
feature: __binding_1,
declared: __binding_2,
prev_declared: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature `{$feature}` is declared {$declared}, but was previously declared {$prev_declared}")));
diag.code(E0711);
;
diag.arg("feature", __binding_1);
diag.arg("declared", __binding_2);
diag.arg("prev_declared", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
625#[diag("feature `{$feature}` is declared {$declared}, but was previously declared {$prev_declared}", code = E0711)]
626pub(crate) struct FeaturePreviouslyDeclared<'a> {
627 #[primary_span]
628 pub span: Span,
629 pub feature: Symbol,
630 pub declared: &'a str,
631 pub prev_declared: &'a str,
632}
633
634#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MultipleRustcMain 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 {
MultipleRustcMain {
span: __binding_0,
first: __binding_1,
additional: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple functions with a `#[rustc_main]` attribute")));
diag.code(E0137);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first `#[rustc_main]` function")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("additional `#[rustc_main]` function")));
diag
}
}
}
}
};Diagnostic)]
635#[diag("multiple functions with a `#[rustc_main]` attribute", code = E0137)]
636pub(crate) struct MultipleRustcMain {
637 #[primary_span]
638 pub span: Span,
639 #[label("first `#[rustc_main]` function")]
640 pub first: Span,
641 #[label("additional `#[rustc_main]` function")]
642 pub additional: Span,
643}
644
645#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ExternMain
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 {
ExternMain { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `main` function cannot be declared in an `extern` block")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
646#[diag("the `main` function cannot be declared in an `extern` block")]
647pub(crate) struct ExternMain {
648 #[primary_span]
649 pub span: Span,
650}
651
652pub(crate) struct NoMainErr {
653 pub sp: Span,
654 pub crate_name: Symbol,
655 pub has_filename: bool,
656 pub filename: PathBuf,
657 pub file_empty: bool,
658 pub non_main_fns: Vec<Span>,
659 pub main_def_opt: Option<MainDefinition>,
660 pub add_teach_note: bool,
661}
662
663impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NoMainErr {
664 #[track_caller]
665 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
666 let mut diag = Diag::new(
667 dcx,
668 level,
669 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function not found in crate `{$crate_name}`"))inline_fluent!("`main` function not found in crate `{$crate_name}`"),
670 );
671 diag.span(DUMMY_SP);
672 diag.code(E0601);
673 diag.arg("crate_name", self.crate_name);
674 diag.arg("filename", self.filename);
675 diag.arg("has_filename", self.has_filename);
676 let note = if !self.non_main_fns.is_empty() {
677 for &span in &self.non_main_fns {
678 diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("here is a function named `main`"))inline_fluent!("here is a function named `main`"));
679 }
680 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you have one or more functions named `main` not defined at the crate level"))inline_fluent!(
681 "you have one or more functions named `main` not defined at the crate level"
682 ));
683 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the `main` function definitions"))inline_fluent!("consider moving the `main` function definitions"));
684 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the main function must be defined at the crate level{$has_filename ->
[true] {\" \"}(in `{$filename}`)
*[false] {\"\"}
}"))inline_fluent!(
686 "the main function must be defined at the crate level{$has_filename ->
687 [true] {\" \"}(in `{$filename}`)
688 *[false] {\"\"}
689 }"
690 )
691 } else if self.has_filename {
692 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a `main` function to `{$filename}`"))inline_fluent!("consider adding a `main` function to `{$filename}`")
693 } else {
694 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a `main` function at the crate level"))inline_fluent!("consider adding a `main` function at the crate level")
695 };
696 if self.file_empty {
697 diag.note(note);
698 } else {
699 diag.span(self.sp.shrink_to_hi());
700 diag.span_label(self.sp.shrink_to_hi(), note);
701 }
702
703 if let Some(main_def) = self.main_def_opt
704 && main_def.opt_fn_def_id().is_none()
705 {
706 diag.span_label(
708 main_def.span,
709 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-function item at `crate::main` is found"))inline_fluent!("non-function item at `crate::main` is found"),
710 );
711 }
712
713 if self.add_teach_note {
714 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you don't know the basics of Rust, you can go look to the Rust Book to get started: https://doc.rust-lang.org/book/"))inline_fluent!("if you don't know the basics of Rust, you can go look to the Rust Book to get started: https://doc.rust-lang.org/book/"));
715 }
716 diag
717 }
718}
719
720pub(crate) struct DuplicateLangItem {
721 pub local_span: Option<Span>,
722 pub lang_item_name: Symbol,
723 pub crate_name: Symbol,
724 pub dependency_of: Option<Symbol>,
725 pub is_local: bool,
726 pub path: String,
727 pub first_defined_span: Option<Span>,
728 pub orig_crate_name: Option<Symbol>,
729 pub orig_dependency_of: Option<Symbol>,
730 pub orig_is_local: bool,
731 pub orig_path: String,
732 pub(crate) duplicate: Duplicate,
733}
734
735impl<G: EmissionGuarantee> Diagnostic<'_, G> for DuplicateLangItem {
736 #[track_caller]
737 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
738 let mut diag = Diag::new(
739 dcx,
740 level,
741 match self.duplicate {
742 Duplicate::Plain => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found duplicate lang item `{$lang_item_name}`"))inline_fluent!("found duplicate lang item `{$lang_item_name}`"),
743 Duplicate::Crate => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate lang item in crate `{$crate_name}`: `{$lang_item_name}`"))inline_fluent!(
744 "duplicate lang item in crate `{$crate_name}`: `{$lang_item_name}`"
745 ),
746 Duplicate::CrateDepends => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate lang item in crate `{$crate_name}` (which `{$dependency_of}` depends on): `{$lang_item_name}`"))inline_fluent!(
747 "duplicate lang item in crate `{$crate_name}` (which `{$dependency_of}` depends on): `{$lang_item_name}`"
748 ),
749 },
750 );
751 diag.code(E0152);
752 diag.arg("lang_item_name", self.lang_item_name);
753 diag.arg("crate_name", self.crate_name);
754 if let Some(dependency_of) = self.dependency_of {
755 diag.arg("dependency_of", dependency_of);
756 }
757 diag.arg("path", self.path);
758 if let Some(orig_crate_name) = self.orig_crate_name {
759 diag.arg("orig_crate_name", orig_crate_name);
760 }
761 if let Some(orig_dependency_of) = self.orig_dependency_of {
762 diag.arg("orig_dependency_of", orig_dependency_of);
763 }
764 diag.arg("orig_path", self.orig_path);
765 if let Some(span) = self.local_span {
766 diag.span(span);
767 }
768 if let Some(span) = self.first_defined_span {
769 diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined here"))inline_fluent!("the lang item is first defined here"));
770 } else {
771 if self.orig_dependency_of.is_none() {
772 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined in crate `{$orig_crate_name}`"))inline_fluent!(
773 "the lang item is first defined in crate `{$orig_crate_name}`"
774 ));
775 } else {
776 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined in crate `{$orig_crate_name}` (which `{$orig_dependency_of}` depends on)"))inline_fluent!("the lang item is first defined in crate `{$orig_crate_name}` (which `{$orig_dependency_of}` depends on)"));
777 }
778
779 if self.orig_is_local {
780 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first definition in the local crate (`{$orig_crate_name}`)"))inline_fluent!(
781 "first definition in the local crate (`{$orig_crate_name}`)"
782 ));
783 } else {
784 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first definition in `{$orig_crate_name}` loaded from {$orig_path}"))inline_fluent!(
785 "first definition in `{$orig_crate_name}` loaded from {$orig_path}"
786 ));
787 }
788
789 if self.is_local {
790 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second definition in the local crate (`{$crate_name}`)"))inline_fluent!("second definition in the local crate (`{$crate_name}`)"));
791 } else {
792 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second definition in `{$crate_name}` loaded from {$path}"))inline_fluent!(
793 "second definition in `{$crate_name}` loaded from {$path}"
794 ));
795 }
796 }
797 diag
798 }
799}
800
801#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectTarget<'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 {
IncorrectTarget {
span: __binding_0,
generics_span: __binding_1,
name: __binding_2,
kind: __binding_3,
num: __binding_4,
actual_num: __binding_5,
at_least: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` lang item must be applied to a {$kind} with {$at_least ->\n [true] at least {$num}\n *[false] {$num}\n } generic {$num ->\n [one] argument\n *[other] arguments\n }")));
diag.code(E0718);
;
diag.arg("name", __binding_2);
diag.arg("kind", __binding_3);
diag.arg("num", __binding_4);
diag.arg("actual_num", __binding_5);
diag.arg("at_least", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this {$kind} has {$actual_num} generic {$actual_num ->\n [one] argument\n *[other] arguments\n }")));
diag
}
}
}
}
};Diagnostic)]
802#[diag("`{$name}` lang item must be applied to a {$kind} with {$at_least ->
803 [true] at least {$num}
804 *[false] {$num}
805 } generic {$num ->
806 [one] argument
807 *[other] arguments
808 }", code = E0718)]
809pub(crate) struct IncorrectTarget<'a> {
810 #[primary_span]
811 pub span: Span,
812 #[label(
813 "this {$kind} has {$actual_num} generic {$actual_num ->
814 [one] argument
815 *[other] arguments
816 }"
817 )]
818 pub generics_span: Span,
819 pub name: &'a str, pub kind: &'static str,
821 pub num: usize,
822 pub actual_num: usize,
823 pub at_least: bool,
824}
825
826#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncorrectCrateType 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 {
IncorrectCrateType { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lang items are not allowed in stable dylibs")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
827#[diag("lang items are not allowed in stable dylibs")]
828pub(crate) struct IncorrectCrateType {
829 #[primary_span]
830 pub span: Span,
831}
832
833#[derive(const _: () =
{
impl<'__a, 'a> rustc_errors::LintDiagnostic<'__a, ()> for
UselessAssignment<'a> {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UselessAssignment {
is_field_assign: __binding_0, ty: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("useless assignment of {$is_field_assign ->\n [true] field\n *[false] variable\n } of type `{$ty}` to itself")));
;
diag.arg("is_field_assign", __binding_0);
diag.arg("ty", __binding_1);
diag
}
};
}
}
};LintDiagnostic)]
834#[diag(
835 "useless assignment of {$is_field_assign ->
836 [true] field
837 *[false] variable
838 } of type `{$ty}` to itself"
839)]
840pub(crate) struct UselessAssignment<'a> {
841 pub is_field_assign: bool,
842 pub ty: Ty<'a>,
843}
844
845#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
InlineIgnoredForExported {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
InlineIgnoredForExported {} => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[inline]` is ignored on externally exported functions")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("externally exported functions are functions with `#[no_mangle]`, `#[export_name]`, or `#[linkage]`")));
;
diag
}
};
}
}
};LintDiagnostic)]
846#[diag("`#[inline]` is ignored on externally exported functions")]
847#[help(
848 "externally exported functions are functions with `#[no_mangle]`, `#[export_name]`, or `#[linkage]`"
849)]
850pub(crate) struct InlineIgnoredForExported {}
851
852#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ObjectLifetimeErr 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 {
ObjectLifetimeErr { span: __binding_0, repr: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$repr}")));
;
diag.arg("repr", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
853#[diag("{$repr}")]
854pub(crate) struct ObjectLifetimeErr {
855 #[primary_span]
856 pub span: Span,
857 pub repr: String,
858}
859
860#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttrApplication 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 {
AttrApplication::Enum {
hint_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to an enum")));
diag.code(E0517);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not an enum")));
diag
}
AttrApplication::Struct {
hint_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to a struct")));
diag.code(E0517);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a struct")));
diag
}
AttrApplication::StructUnion {
hint_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to a struct or union")));
diag.code(E0517);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a struct or union")));
diag
}
AttrApplication::StructEnumUnion {
hint_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute should be applied to a struct, enum, or union")));
diag.code(E0517);
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a struct, enum, or union")));
diag
}
}
}
}
};Diagnostic)]
861pub(crate) enum AttrApplication {
862 #[diag("attribute should be applied to an enum", code = E0517)]
863 Enum {
864 #[primary_span]
865 hint_span: Span,
866 #[label("not an enum")]
867 span: Span,
868 },
869 #[diag("attribute should be applied to a struct", code = E0517)]
870 Struct {
871 #[primary_span]
872 hint_span: Span,
873 #[label("not a struct")]
874 span: Span,
875 },
876 #[diag("attribute should be applied to a struct or union", code = E0517)]
877 StructUnion {
878 #[primary_span]
879 hint_span: Span,
880 #[label("not a struct or union")]
881 span: Span,
882 },
883 #[diag("attribute should be applied to a struct, enum, or union", code = E0517)]
884 StructEnumUnion {
885 #[primary_span]
886 hint_span: Span,
887 #[label("not a struct, enum, or union")]
888 span: Span,
889 },
890}
891
892#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TransparentIncompatible 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 {
TransparentIncompatible {
hint_spans: __binding_0, target: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("transparent {$target} cannot have other repr hints")));
diag.code(E0692);
;
diag.arg("target", __binding_1);
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
893#[diag("transparent {$target} cannot have other repr hints", code = E0692)]
894pub(crate) struct TransparentIncompatible {
895 #[primary_span]
896 pub hint_spans: Vec<Span>,
897 pub target: String,
898}
899
900#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DeprecatedAttribute 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 {
DeprecatedAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("deprecated attribute must be paired with either stable or unstable attribute")));
diag.code(E0549);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
901#[diag("deprecated attribute must be paired with either stable or unstable attribute", code = E0549)]
902pub(crate) struct DeprecatedAttribute {
903 #[primary_span]
904 pub span: Span,
905}
906
907#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UselessStability 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 {
UselessStability { span: __binding_0, item_sp: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this stability annotation is useless")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("useless stability annotation")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the stability attribute annotates this item")));
diag
}
}
}
}
};Diagnostic)]
908#[diag("this stability annotation is useless")]
909pub(crate) struct UselessStability {
910 #[primary_span]
911 #[label("useless stability annotation")]
912 pub span: Span,
913 #[label("the stability attribute annotates this item")]
914 pub item_sp: Span,
915}
916
917#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotStabilizeDeprecated 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 {
CannotStabilizeDeprecated {
span: __binding_0, item_sp: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an API can't be stabilized after it is deprecated")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid version")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the stability attribute annotates this item")));
diag
}
}
}
}
};Diagnostic)]
918#[diag("an API can't be stabilized after it is deprecated")]
919pub(crate) struct CannotStabilizeDeprecated {
920 #[primary_span]
921 #[label("invalid version")]
922 pub span: Span,
923 #[label("the stability attribute annotates this item")]
924 pub item_sp: Span,
925}
926
927#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnstableAttrForAlreadyStableFeature 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 {
UnstableAttrForAlreadyStableFeature {
attr_span: __binding_0, item_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't mark as unstable using an already stable feature")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this feature is already stable")));
diag.span_help(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the attribute")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the stability attribute annotates this item")));
diag
}
}
}
}
};Diagnostic)]
928#[diag("can't mark as unstable using an already stable feature")]
929pub(crate) struct UnstableAttrForAlreadyStableFeature {
930 #[primary_span]
931 #[label("this feature is already stable")]
932 #[help("consider removing the attribute")]
933 pub attr_span: Span,
934 #[label("the stability attribute annotates this item")]
935 pub item_span: Span,
936}
937
938#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MissingStabilityAttr<'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 {
MissingStabilityAttr { span: __binding_0, descr: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr} has missing stability attribute")));
;
diag.arg("descr", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
939#[diag("{$descr} has missing stability attribute")]
940pub(crate) struct MissingStabilityAttr<'a> {
941 #[primary_span]
942 pub span: Span,
943 pub descr: &'a str,
944}
945
946#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
MissingConstStabAttr<'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 {
MissingConstStabAttr { span: __binding_0, descr: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr} has missing const stability attribute")));
;
diag.arg("descr", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
947#[diag("{$descr} has missing const stability attribute")]
948pub(crate) struct MissingConstStabAttr<'a> {
949 #[primary_span]
950 pub span: Span,
951 pub descr: &'a str,
952}
953
954#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitImplConstStable 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 {
TraitImplConstStable { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait implementations cannot be const stable yet")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
955#[diag("trait implementations cannot be const stable yet")]
956#[note("see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information")]
957pub(crate) struct TraitImplConstStable {
958 #[primary_span]
959 pub span: Span,
960}
961
962#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TraitImplConstStabilityMismatch 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 {
TraitImplConstStabilityMismatch {
span: __binding_0,
impl_stability: __binding_1,
trait_stability: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const stability on the impl does not match the const stability on the trait")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
963#[diag("const stability on the impl does not match the const stability on the trait")]
964pub(crate) struct TraitImplConstStabilityMismatch {
965 #[primary_span]
966 pub span: Span,
967 #[subdiagnostic]
968 pub impl_stability: ImplConstStability,
969 #[subdiagnostic]
970 pub trait_stability: TraitConstStability,
971}
972
973#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TraitConstStability {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
TraitConstStability::Stable { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but the trait is stable")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
TraitConstStability::Unstable { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but the trait is unstable")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
974pub(crate) enum TraitConstStability {
975 #[note("...but the trait is stable")]
976 Stable {
977 #[primary_span]
978 span: Span,
979 },
980 #[note("...but the trait is unstable")]
981 Unstable {
982 #[primary_span]
983 span: Span,
984 },
985}
986
987#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImplConstStability {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ImplConstStability::Stable { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this impl is (implicitly) stable...")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
ImplConstStability::Unstable { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this impl is unstable...")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
988pub(crate) enum ImplConstStability {
989 #[note("this impl is (implicitly) stable...")]
990 Stable {
991 #[primary_span]
992 span: Span,
993 },
994 #[note("this impl is unstable...")]
995 Unstable {
996 #[primary_span]
997 span: Span,
998 },
999}
1000
1001#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnknownFeature
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 {
UnknownFeature {
span: __binding_0,
feature: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown feature `{$feature}`")));
diag.code(E0635);
;
diag.arg("feature", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
1002#[diag("unknown feature `{$feature}`", code = E0635)]
1003pub(crate) struct UnknownFeature {
1004 #[primary_span]
1005 pub span: Span,
1006 pub feature: Symbol,
1007 #[subdiagnostic]
1008 pub suggestion: Option<MisspelledFeature>,
1009}
1010
1011#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MisspelledFeature {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MisspelledFeature {
span: __binding_0, actual_name: __binding_1 } => {
let __code_6 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("actual_name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is a feature with a similar name: `{$actual_name}`")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_6, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1012#[suggestion(
1013 "there is a feature with a similar name: `{$actual_name}`",
1014 style = "verbose",
1015 code = "{actual_name}",
1016 applicability = "maybe-incorrect"
1017)]
1018pub(crate) struct MisspelledFeature {
1019 #[primary_span]
1020 pub span: Span,
1021 pub actual_name: Symbol,
1022}
1023
1024#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for RenamedFeature
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 {
RenamedFeature {
span: __binding_0, feature: __binding_1, alias: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature `{$alias}` has been renamed to `{$feature}`")));
diag.code(E0635);
;
diag.arg("feature", __binding_1);
diag.arg("alias", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1025#[diag("feature `{$alias}` has been renamed to `{$feature}`", code = E0635)]
1026pub(crate) struct RenamedFeature {
1027 #[primary_span]
1028 pub span: Span,
1029 pub feature: Symbol,
1030 pub alias: Symbol,
1031}
1032
1033#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ImpliedFeatureNotExist 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 {
ImpliedFeatureNotExist {
span: __binding_0,
feature: __binding_1,
implied_by: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature `{$implied_by}` implying `{$feature}` does not exist")));
;
diag.arg("feature", __binding_1);
diag.arg("implied_by", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1034#[diag("feature `{$implied_by}` implying `{$feature}` does not exist")]
1035pub(crate) struct ImpliedFeatureNotExist {
1036 #[primary_span]
1037 pub span: Span,
1038 pub feature: Symbol,
1039 pub implied_by: Symbol,
1040}
1041
1042#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DuplicateFeatureErr 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 {
DuplicateFeatureErr {
span: __binding_0, feature: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$feature}` has already been enabled")));
diag.code(E0636);
;
diag.arg("feature", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1043#[diag("the feature `{$feature}` has already been enabled", code = E0636)]
1044pub(crate) struct DuplicateFeatureErr {
1045 #[primary_span]
1046 pub span: Span,
1047 pub feature: Symbol,
1048}
1049
1050#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingConstErr 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 {
MissingConstErr { fn_sig_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const`")));
;
diag.span(__binding_0);
diag.span_help(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("make the function or method const")));
diag
}
}
}
}
};Diagnostic)]
1051#[diag(
1052 "attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const`"
1053)]
1054pub(crate) struct MissingConstErr {
1055 #[primary_span]
1056 #[help("make the function or method const")]
1057 pub fn_sig_span: Span,
1058}
1059
1060#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstStableNotStable 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 {
ConstStableNotStable {
fn_sig_span: __binding_0, const_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute `#[rustc_const_stable]` can only be applied to functions that are declared `#[stable]`")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute specified here")));
diag
}
}
}
}
};Diagnostic)]
1061#[diag(
1062 "attribute `#[rustc_const_stable]` can only be applied to functions that are declared `#[stable]`"
1063)]
1064pub(crate) struct ConstStableNotStable {
1065 #[primary_span]
1066 pub fn_sig_span: Span,
1067 #[label("attribute specified here")]
1068 pub const_span: Span,
1069}
1070
1071#[derive(const _: () =
{
impl<'__a, 'tcx> rustc_errors::LintDiagnostic<'__a, ()> for
MultipleDeadCodes<'tcx> {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
MultipleDeadCodes::DeadCodes {
multiple: __binding_0,
num: __binding_1,
descr: __binding_2,
participle: __binding_3,
name_list: __binding_4,
enum_variants_with_same_name: __binding_5,
parent_info: __binding_6,
ignored_derived_impls: __binding_7 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{ $multiple ->\n *[true] multiple {$descr}s are\n [false] { $num ->\n [one] {$descr} {$name_list} is\n *[other] {$descr}s {$name_list} are\n }\n } never {$participle}")));
;
diag.arg("multiple", __binding_0);
diag.arg("num", __binding_1);
diag.arg("descr", __binding_2);
diag.arg("participle", __binding_3);
diag.arg("name_list", __binding_4);
for __binding_5 in __binding_5 {
diag.subdiagnostic(__binding_5);
}
if let Some(__binding_6) = __binding_6 {
diag.subdiagnostic(__binding_6);
}
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
diag
}
MultipleDeadCodes::UnusedTupleStructFields {
multiple: __binding_0,
num: __binding_1,
descr: __binding_2,
participle: __binding_3,
name_list: __binding_4,
change_fields_suggestion: __binding_5,
parent_info: __binding_6,
ignored_derived_impls: __binding_7 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{ $multiple ->\n *[true] multiple {$descr}s are\n [false] { $num ->\n [one] {$descr} {$name_list} is\n *[other] {$descr}s {$name_list} are\n }\n } never {$participle}")));
;
diag.arg("multiple", __binding_0);
diag.arg("num", __binding_1);
diag.arg("descr", __binding_2);
diag.arg("participle", __binding_3);
diag.arg("name_list", __binding_4);
diag.subdiagnostic(__binding_5);
if let Some(__binding_6) = __binding_6 {
diag.subdiagnostic(__binding_6);
}
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
diag
}
};
}
}
};LintDiagnostic)]
1072pub(crate) enum MultipleDeadCodes<'tcx> {
1073 #[diag(
1074 "{ $multiple ->
1075 *[true] multiple {$descr}s are
1076 [false] { $num ->
1077 [one] {$descr} {$name_list} is
1078 *[other] {$descr}s {$name_list} are
1079 }
1080 } never {$participle}"
1081 )]
1082 DeadCodes {
1083 multiple: bool,
1084 num: usize,
1085 descr: &'tcx str,
1086 participle: &'tcx str,
1087 name_list: DiagSymbolList,
1088 #[subdiagnostic]
1089 enum_variants_with_same_name: Vec<EnumVariantSameName<'tcx>>,
1091 #[subdiagnostic]
1092 parent_info: Option<ParentInfo<'tcx>>,
1093 #[subdiagnostic]
1094 ignored_derived_impls: Option<IgnoredDerivedImpls>,
1095 },
1096 #[diag(
1097 "{ $multiple ->
1098 *[true] multiple {$descr}s are
1099 [false] { $num ->
1100 [one] {$descr} {$name_list} is
1101 *[other] {$descr}s {$name_list} are
1102 }
1103 } never {$participle}"
1104 )]
1105 UnusedTupleStructFields {
1106 multiple: bool,
1107 num: usize,
1108 descr: &'tcx str,
1109 participle: &'tcx str,
1110 name_list: DiagSymbolList,
1111 #[subdiagnostic]
1112 change_fields_suggestion: ChangeFields,
1113 #[subdiagnostic]
1114 parent_info: Option<ParentInfo<'tcx>>,
1115 #[subdiagnostic]
1116 ignored_derived_impls: Option<IgnoredDerivedImpls>,
1117 },
1118}
1119
1120#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for EnumVariantSameName<'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
EnumVariantSameName {
variant_span: __binding_0,
dead_name: __binding_1,
dead_descr: __binding_2 } => {
diag.store_args();
diag.arg("dead_name", __binding_1);
diag.arg("dead_descr", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("it is impossible to refer to the {$dead_descr} `{$dead_name}` because it is shadowed by this enum variant with the same name")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1121#[note(
1122 "it is impossible to refer to the {$dead_descr} `{$dead_name}` because it is shadowed by this enum variant with the same name"
1123)]
1124pub(crate) struct EnumVariantSameName<'tcx> {
1125 #[primary_span]
1126 pub variant_span: Span,
1127 pub dead_name: Symbol,
1128 pub dead_descr: &'tcx str,
1129}
1130
1131#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for ParentInfo<'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ParentInfo {
num: __binding_0,
descr: __binding_1,
parent_descr: __binding_2,
span: __binding_3 } => {
diag.store_args();
diag.arg("num", __binding_0);
diag.arg("descr", __binding_1);
diag.arg("parent_descr", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num ->\n [one] {$descr}\n *[other] {$descr}s\n } in this {$parent_descr}")));
diag.span_label(__binding_3, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1132#[label(
1133 "{$num ->
1134 [one] {$descr}
1135 *[other] {$descr}s
1136 } in this {$parent_descr}"
1137)]
1138pub(crate) struct ParentInfo<'tcx> {
1139 pub num: usize,
1140 pub descr: &'tcx str,
1141 pub parent_descr: &'tcx str,
1142 #[primary_span]
1143 pub span: Span,
1144}
1145
1146#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IgnoredDerivedImpls {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IgnoredDerivedImpls {
name: __binding_0,
trait_list: __binding_1,
trait_list_len: __binding_2 } => {
diag.store_args();
diag.arg("name", __binding_0);
diag.arg("trait_list", __binding_1);
diag.arg("trait_list_len", __binding_2);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` has {$trait_list_len ->\n [one] a derived impl\n *[other] derived impls\n } for the {$trait_list_len ->\n [one] trait {$trait_list}, but this is\n *[other] traits {$trait_list}, but these are\n } intentionally ignored during dead code analysis")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1147#[note(
1148 "`{$name}` has {$trait_list_len ->
1149 [one] a derived impl
1150 *[other] derived impls
1151 } for the {$trait_list_len ->
1152 [one] trait {$trait_list}, but this is
1153 *[other] traits {$trait_list}, but these are
1154 } intentionally ignored during dead code analysis"
1155)]
1156pub(crate) struct IgnoredDerivedImpls {
1157 pub name: Symbol,
1158 pub trait_list: DiagSymbolList,
1159 pub trait_list_len: usize,
1160}
1161
1162#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeFields {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ChangeFields::ChangeToUnitTypeOrRemove {
num: __binding_0, spans: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("()"))
});
for __binding_1 in __binding_1 {
suggestions.push((__binding_1, __code_7.clone()));
}
diag.store_args();
diag.arg("num", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider changing the { $num ->\n [one] field\n *[other] fields\n } to be of unit type to suppress this warning while preserving the field numbering, or remove the { $num ->\n [one] field\n *[other] fields\n }")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
ChangeFields::Remove { num: __binding_0 } => {
diag.store_args();
diag.arg("num", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing { $num ->\n [one] this\n *[other] these\n } { $num ->\n [one] field\n *[other] fields\n }")));
diag.help(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1163pub(crate) enum ChangeFields {
1164 #[multipart_suggestion(
1165 "consider changing the { $num ->
1166 [one] field
1167 *[other] fields
1168 } to be of unit type to suppress this warning while preserving the field numbering, or remove the { $num ->
1169 [one] field
1170 *[other] fields
1171 }",
1172 applicability = "has-placeholders"
1173 )]
1174 ChangeToUnitTypeOrRemove {
1175 num: usize,
1176 #[suggestion_part(code = "()")]
1177 spans: Vec<Span>,
1178 },
1179 #[help(
1180 "consider removing { $num ->
1181 [one] this
1182 *[other] these
1183 } { $num ->
1184 [one] field
1185 *[other] fields
1186 }"
1187 )]
1188 Remove { num: usize },
1189}
1190
1191#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ProcMacroBadSig 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 {
ProcMacroBadSig { span: __binding_0, kind: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind} has incorrect signature")));
;
diag.arg("kind", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1192#[diag("{$kind} has incorrect signature")]
1193pub(crate) struct ProcMacroBadSig {
1194 #[primary_span]
1195 pub span: Span,
1196 pub kind: ProcMacroKind,
1197}
1198
1199#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnnecessaryStableFeature {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnnecessaryStableFeature {
feature: __binding_0, since: __binding_1 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$feature}` has been stable since {$since} and no longer requires an attribute to enable")));
;
diag.arg("feature", __binding_0);
diag.arg("since", __binding_1);
diag
}
};
}
}
};LintDiagnostic)]
1200#[diag(
1201 "the feature `{$feature}` has been stable since {$since} and no longer requires an attribute to enable"
1202)]
1203pub(crate) struct UnnecessaryStableFeature {
1204 pub feature: Symbol,
1205 pub since: Symbol,
1206}
1207
1208#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnnecessaryPartialStableFeature {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnnecessaryPartialStableFeature {
span: __binding_0,
line: __binding_1,
feature: __binding_2,
since: __binding_3,
implies: __binding_4 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$feature}` has been partially stabilized since {$since} and is succeeded by the feature `{$implies}`")));
;
let __code_8 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
})].into_iter();
let __code_9 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.arg("feature", __binding_2);
diag.arg("since", __binding_3);
diag.arg("implies", __binding_4);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you are using features which are still unstable, change to using `{$implies}`")),
__code_8, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you are using features which are now stable, remove this line")),
__code_9, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
};
}
}
};LintDiagnostic)]
1209#[diag(
1210 "the feature `{$feature}` has been partially stabilized since {$since} and is succeeded by the feature `{$implies}`"
1211)]
1212pub(crate) struct UnnecessaryPartialStableFeature {
1213 #[suggestion(
1214 "if you are using features which are still unstable, change to using `{$implies}`",
1215 code = "{implies}",
1216 applicability = "maybe-incorrect"
1217 )]
1218 pub span: Span,
1219 #[suggestion(
1220 "if you are using features which are now stable, remove this line",
1221 code = "",
1222 applicability = "maybe-incorrect"
1223 )]
1224 pub line: Span,
1225 pub feature: Symbol,
1226 pub since: Symbol,
1227 pub implies: Symbol,
1228}
1229
1230#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
IneffectiveUnstableImpl {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
IneffectiveUnstableImpl => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `#[unstable]` annotation here has no effect")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information")));
;
diag
}
};
}
}
};LintDiagnostic)]
1231#[diag("an `#[unstable]` annotation here has no effect")]
1232#[note("see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information")]
1233pub(crate) struct IneffectiveUnstableImpl;
1234
1235#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizeAttributeNotAllowed 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 {
SanitizeAttributeNotAllowed {
attr_span: __binding_0,
not_fn_impl_mod: __binding_1,
no_body: __binding_2,
help: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("sanitize attribute not allowed here")));
;
diag.span(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a function, impl block, or module")));
}
if let Some(__binding_2) = __binding_2 {
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function has no body")));
}
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("sanitize attribute can be applied to a function (with body), impl block, or module")));
diag
}
}
}
}
};Diagnostic)]
1236#[diag("sanitize attribute not allowed here")]
1237pub(crate) struct SanitizeAttributeNotAllowed {
1238 #[primary_span]
1239 pub attr_span: Span,
1240 #[label("not a function, impl block, or module")]
1241 pub not_fn_impl_mod: Option<Span>,
1242 #[label("function has no body")]
1243 pub no_body: Option<Span>,
1244 #[help("sanitize attribute can be applied to a function (with body), impl block, or module")]
1245 pub help: (),
1246}
1247
1248#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcConstStableIndirectPairing 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 {
RustcConstStableIndirectPairing { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1250#[diag(
1251 "`const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied"
1252)]
1253pub(crate) struct RustcConstStableIndirectPairing {
1254 #[primary_span]
1255 pub span: Span,
1256}
1257
1258#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedAttributesInWhere 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 {
UnsupportedAttributesInWhere { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("most attributes are not supported in `where` clauses")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `#[cfg]` and `#[cfg_attr]` are supported")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1259#[diag("most attributes are not supported in `where` clauses")]
1260#[help("only `#[cfg]` and `#[cfg_attr]` are supported")]
1261pub(crate) struct UnsupportedAttributesInWhere {
1262 #[primary_span]
1263 pub span: MultiSpan,
1264}
1265
1266#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnexportableItem<'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 {
UnexportableItem::Item {
span: __binding_0, descr: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$descr}'s are not exportable")));
;
diag.arg("descr", __binding_1);
diag.span(__binding_0);
diag
}
UnexportableItem::GenericFn(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("generic functions are not exportable")));
;
diag.span(__binding_0);
diag
}
UnexportableItem::FnAbi(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only functions with \"C\" ABI are exportable")));
;
diag.span(__binding_0);
diag
}
UnexportableItem::TypeRepr(__binding_0) => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("types with unstable layout are not exportable")));
;
diag.span(__binding_0);
diag
}
UnexportableItem::TypeInInterface {
span: __binding_0,
desc: __binding_1,
ty: __binding_2,
ty_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$desc} with `#[export_stable]` attribute uses type `{$ty}`, which is not exportable")));
;
diag.arg("desc", __binding_1);
diag.arg("ty", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not exportable")));
diag
}
UnexportableItem::PrivItem {
span: __binding_0,
vis_note: __binding_1,
vis_descr: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("private items are not exportable")));
;
diag.arg("vis_descr", __binding_2);
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("is only usable at visibility `{$vis_descr}`")));
diag
}
UnexportableItem::AdtWithPrivFields {
span: __binding_0,
vis_note: __binding_1,
field_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ADT types with private fields are not exportable")));
;
diag.arg("field_name", __binding_2);
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$field_name}` is private")));
diag
}
}
}
}
};Diagnostic)]
1267pub(crate) enum UnexportableItem<'a> {
1268 #[diag("{$descr}'s are not exportable")]
1269 Item {
1270 #[primary_span]
1271 span: Span,
1272 descr: &'a str,
1273 },
1274
1275 #[diag("generic functions are not exportable")]
1276 GenericFn(#[primary_span] Span),
1277
1278 #[diag("only functions with \"C\" ABI are exportable")]
1279 FnAbi(#[primary_span] Span),
1280
1281 #[diag("types with unstable layout are not exportable")]
1282 TypeRepr(#[primary_span] Span),
1283
1284 #[diag("{$desc} with `#[export_stable]` attribute uses type `{$ty}`, which is not exportable")]
1285 TypeInInterface {
1286 #[primary_span]
1287 span: Span,
1288 desc: &'a str,
1289 ty: &'a str,
1290 #[label("not exportable")]
1291 ty_span: Span,
1292 },
1293
1294 #[diag("private items are not exportable")]
1295 PrivItem {
1296 #[primary_span]
1297 span: Span,
1298 #[note("is only usable at visibility `{$vis_descr}`")]
1299 vis_note: Span,
1300 vis_descr: &'a str,
1301 },
1302
1303 #[diag("ADT types with private fields are not exportable")]
1304 AdtWithPrivFields {
1305 #[primary_span]
1306 span: Span,
1307 #[note("`{$field_name}` is private")]
1308 vis_note: Span,
1309 field_name: &'a str,
1310 },
1311}
1312
1313#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReprAlignShouldBeAlign 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 {
ReprAlignShouldBeAlign {
span: __binding_0, item: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[repr(align(...))]` is not supported on {$item}")));
;
diag.arg("item", __binding_1);
diag.span(__binding_0);
diag.span_help(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `#[rustc_align(...)]` instead")));
diag
}
}
}
}
};Diagnostic)]
1314#[diag("`#[repr(align(...))]` is not supported on {$item}")]
1315pub(crate) struct ReprAlignShouldBeAlign {
1316 #[primary_span]
1317 #[help("use `#[rustc_align(...)]` instead")]
1318 pub span: Span,
1319 pub item: &'static str,
1320}
1321
1322#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ReprAlignShouldBeAlignStatic 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 {
ReprAlignShouldBeAlignStatic {
span: __binding_0, item: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[repr(align(...))]` is not supported on {$item}")));
;
diag.arg("item", __binding_1);
diag.span(__binding_0);
diag.span_help(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `#[rustc_align_static(...)]` instead")));
diag
}
}
}
}
};Diagnostic)]
1323#[diag("`#[repr(align(...))]` is not supported on {$item}")]
1324pub(crate) struct ReprAlignShouldBeAlignStatic {
1325 #[primary_span]
1326 #[help("use `#[rustc_align_static(...)]` instead")]
1327 pub span: Span,
1328 pub item: &'static str,
1329}
1330
1331#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CustomMirPhaseRequiresDialect 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 {
CustomMirPhaseRequiresDialect {
attr_span: __binding_0, phase_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`dialect` key required")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`phase` argument requires a `dialect` argument")));
diag
}
}
}
}
};Diagnostic)]
1332#[diag("`dialect` key required")]
1333pub(crate) struct CustomMirPhaseRequiresDialect {
1334 #[primary_span]
1335 pub attr_span: Span,
1336 #[label("`phase` argument requires a `dialect` argument")]
1337 pub phase_span: Span,
1338}
1339
1340#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CustomMirIncompatibleDialectAndPhase 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 {
CustomMirIncompatibleDialectAndPhase {
dialect: __binding_0,
phase: __binding_1,
attr_span: __binding_2,
dialect_span: __binding_3,
phase_span: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$dialect} dialect is not compatible with the {$phase} phase")));
;
diag.arg("dialect", __binding_0);
diag.arg("phase", __binding_1);
diag.span(__binding_2);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this dialect...")));
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("... is not compatible with this phase")));
diag
}
}
}
}
};Diagnostic)]
1341#[diag("the {$dialect} dialect is not compatible with the {$phase} phase")]
1342pub(crate) struct CustomMirIncompatibleDialectAndPhase {
1343 pub dialect: MirDialect,
1344 pub phase: MirPhase,
1345 #[primary_span]
1346 pub attr_span: Span,
1347 #[label("this dialect...")]
1348 pub dialect_span: Span,
1349 #[label("... is not compatible with this phase")]
1350 pub phase_span: Span,
1351}
1352
1353#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EiiImplNotFunction 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 {
EiiImplNotFunction { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`eii_macro_for` is only valid on functions")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1354#[diag("`eii_macro_for` is only valid on functions")]
1355pub(crate) struct EiiImplNotFunction {
1356 #[primary_span]
1357 pub span: Span,
1358}
1359
1360#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EiiImplRequiresUnsafe 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 {
EiiImplRequiresUnsafe {
span: __binding_0,
name: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}]` is unsafe to implement")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1361#[diag("`#[{$name}]` is unsafe to implement")]
1362pub(crate) struct EiiImplRequiresUnsafe {
1363 #[primary_span]
1364 pub span: Span,
1365 pub name: Symbol,
1366 #[subdiagnostic]
1367 pub suggestion: EiiImplRequiresUnsafeSuggestion,
1368}
1369
1370#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for EiiImplRequiresUnsafeSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
EiiImplRequiresUnsafeSuggestion {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_10 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe("))
});
let __code_11 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_10));
suggestions.push((__binding_1, __code_11));
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the attribute in `unsafe(...)`")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1371#[multipart_suggestion("wrap the attribute in `unsafe(...)`", applicability = "machine-applicable")]
1372pub(crate) struct EiiImplRequiresUnsafeSuggestion {
1373 #[suggestion_part(code = "unsafe(")]
1374 pub left: Span,
1375 #[suggestion_part(code = ")")]
1376 pub right: Span,
1377}
1378
1379#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EiiWithTrackCaller 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 {
EiiWithTrackCaller {
attr_span: __binding_0,
name: __binding_1,
sig_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}]` is not allowed to have `#[track_caller]`")));
;
diag.arg("name", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}]` is not allowed to have `#[track_caller]`")));
diag
}
}
}
}
};Diagnostic)]
1380#[diag("`#[{$name}]` is not allowed to have `#[track_caller]`")]
1381pub(crate) struct EiiWithTrackCaller {
1382 #[primary_span]
1383 pub attr_span: Span,
1384 pub name: Symbol,
1385 #[label("`#[{$name}]` is not allowed to have `#[track_caller]`")]
1386 pub sig_span: Span,
1387}
1388
1389#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for EiiWithoutImpl
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 {
EiiWithoutImpl {
span: __binding_0,
name: __binding_1,
current_crate_name: __binding_2,
decl_crate_name: __binding_3,
help: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}]` required, but not found")));
;
diag.arg("name", __binding_1);
diag.arg("current_crate_name", __binding_2);
diag.arg("decl_crate_name", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected because `#[{$name}]` was declared here in crate `{$decl_crate_name}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected at least one implementation in crate `{$current_crate_name}` or any of its dependencies")));
diag
}
}
}
}
};Diagnostic)]
1390#[diag("`#[{$name}]` required, but not found")]
1391pub(crate) struct EiiWithoutImpl {
1392 #[primary_span]
1393 #[label("expected because `#[{$name}]` was declared here in crate `{$decl_crate_name}`")]
1394 pub span: Span,
1395 pub name: Symbol,
1396
1397 pub current_crate_name: Symbol,
1398 pub decl_crate_name: Symbol,
1399 #[help(
1400 "expected at least one implementation in crate `{$current_crate_name}` or any of its dependencies"
1401 )]
1402 pub help: (),
1403}
1404
1405#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DuplicateEiiImpls 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 {
DuplicateEiiImpls {
name: __binding_0,
first_span: __binding_1,
first_crate: __binding_2,
second_span: __binding_3,
second_crate: __binding_4,
additional_crates: __binding_5,
num_additional_crates: __binding_6,
additional_crate_names: __binding_7,
help: __binding_8 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple implementations of `#[{$name}]`")));
;
diag.arg("name", __binding_0);
diag.arg("first_crate", __binding_2);
diag.arg("second_crate", __binding_4);
diag.arg("num_additional_crates", __binding_6);
diag.arg("additional_crate_names", __binding_7);
diag.span(__binding_1);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first implemented here in crate `{$first_crate}`")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("also implemented here in crate `{$second_crate}`")));
if let Some(__binding_5) = __binding_5 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in addition to these two, { $num_additional_crates ->\n [one] another implementation was found in crate {$additional_crate_names}\n *[other] more implementations were also found in the following crates: {$additional_crate_names}\n }")));
}
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an \"externally implementable item\" can only have a single implementation in the final artifact. When multiple implementations are found, also in different crates, they conflict")));
diag
}
}
}
}
};Diagnostic)]
1406#[diag("multiple implementations of `#[{$name}]`")]
1407pub(crate) struct DuplicateEiiImpls {
1408 pub name: Symbol,
1409
1410 #[primary_span]
1411 #[label("first implemented here in crate `{$first_crate}`")]
1412 pub first_span: Span,
1413 pub first_crate: Symbol,
1414
1415 #[label("also implemented here in crate `{$second_crate}`")]
1416 pub second_span: Span,
1417 pub second_crate: Symbol,
1418
1419 #[note("in addition to these two, { $num_additional_crates ->
1420 [one] another implementation was found in crate {$additional_crate_names}
1421 *[other] more implementations were also found in the following crates: {$additional_crate_names}
1422 }")]
1423 pub additional_crates: Option<()>,
1424
1425 pub num_additional_crates: usize,
1426 pub additional_crate_names: String,
1427
1428 #[help(
1429 "an \"externally implementable item\" can only have a single implementation in the final artifact. When multiple implementations are found, also in different crates, they conflict"
1430 )]
1431 pub help: (),
1432}
1433
1434#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionNotHaveDefaultImplementation 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 {
FunctionNotHaveDefaultImplementation {
span: __binding_0, note_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function doesn't have a default implementation")));
;
diag.span(__binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required by this annotation")));
diag
}
}
}
}
};Diagnostic)]
1435#[diag("function doesn't have a default implementation")]
1436pub(crate) struct FunctionNotHaveDefaultImplementation {
1437 #[primary_span]
1438 pub span: Span,
1439 #[note("required by this annotation")]
1440 pub note_span: Span,
1441}
1442
1443#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MustImplementNotFunction 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 {
MustImplementNotFunction {
span: __binding_0, span_note: __binding_1, note: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not a function")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1444#[diag("not a function")]
1445pub(crate) struct MustImplementNotFunction {
1446 #[primary_span]
1447 pub span: Span,
1448 #[subdiagnostic]
1449 pub span_note: MustImplementNotFunctionSpanNote,
1450 #[subdiagnostic]
1451 pub note: MustImplementNotFunctionNote,
1452}
1453
1454#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MustImplementNotFunctionSpanNote
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MustImplementNotFunctionSpanNote { span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required by this annotation")));
diag.span_note(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1455#[note("required by this annotation")]
1456pub(crate) struct MustImplementNotFunctionSpanNote {
1457 #[primary_span]
1458 pub span: Span,
1459}
1460
1461#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MustImplementNotFunctionNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MustImplementNotFunctionNote {} => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("all `#[rustc_must_implement_one_of]` arguments must be associated function names")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1462#[note("all `#[rustc_must_implement_one_of]` arguments must be associated function names")]
1463pub(crate) struct MustImplementNotFunctionNote {}
1464
1465#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionNotFoundInTrait 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 {
FunctionNotFoundInTrait { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function not found in this trait")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1466#[diag("function not found in this trait")]
1467pub(crate) struct FunctionNotFoundInTrait {
1468 #[primary_span]
1469 pub span: Span,
1470}
1471
1472#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionNamesDuplicated 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 {
FunctionNamesDuplicated { spans: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions names are duplicated")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("all `#[rustc_must_implement_one_of]` arguments must be unique")));
;
diag.span(__binding_0.clone());
diag
}
}
}
}
};Diagnostic)]
1473#[diag("functions names are duplicated")]
1474#[note("all `#[rustc_must_implement_one_of]` arguments must be unique")]
1475pub(crate) struct FunctionNamesDuplicated {
1476 #[primary_span]
1477 pub spans: Vec<Span>,
1478}