1use std::io::Error;
2use std::path::{Path, PathBuf};
3
4use rustc_errors::codes::*;
5use rustc_errors::{Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, Level, msg};
6use rustc_macros::{Diagnostic, Subdiagnostic};
7use rustc_middle::middle::resolve::MainDefinition;
8use rustc_middle::ty::Ty;
9use rustc_span::{DUMMY_SP, Ident, Span, Symbol};
10
11use crate::check_attr::ProcMacroKind;
12use crate::lang_items::Duplicate;
13
14#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MixedExportNameAndNoMangle {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MixedExportNameAndNoMangle {
no_mangle_span: __binding_0,
export_name_span: __binding_1,
no_mangle_attr: __binding_2,
export_name_attr: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
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
}
}
}
}
};Diagnostic)]
15#[diag("`{$no_mangle_attr}` attribute may not be used in combination with `{$export_name_attr}`")]
16pub(crate) struct MixedExportNameAndNoMangle {
17 #[label("`{$no_mangle_attr}` is ignored")]
18 #[suggestion(
19 "remove the `{$no_mangle_attr}` attribute",
20 style = "verbose",
21 code = "",
22 applicability = "machine-applicable"
23 )]
24 pub no_mangle_span: Span,
25 #[note("`{$export_name_attr}` takes precedence")]
26 pub export_name_span: Span,
27 pub no_mangle_attr: &'static str,
28 pub export_name_attr: &'static str,
29}
30
31#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
DocAliasBadLocation<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
32#[diag("`#[doc(alias = \"...\")]` isn't allowed on {$location}")]
33pub(crate) struct DocAliasBadLocation<'a> {
34 #[primary_span]
35 pub span: Span,
36 pub location: &'a str,
37}
38
39#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for DocAliasNotAnAlias {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
40#[diag("`#[doc(alias = \"{$attr_str}\"]` is the same as the item's name")]
41pub(crate) struct DocAliasNotAnAlias {
42 #[primary_span]
43 pub span: Span,
44 pub attr_str: Symbol,
45}
46
47#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DocKeywordAttributeNotAnonConst {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DocKeywordAttributeNotAnonConst {
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 anonymous constants")));
;
diag.arg("attr_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
48#[diag("`#[doc({$attr_name} = \"...\")]` should be used on anonymous constants")]
49pub(crate) struct DocKeywordAttributeNotAnonConst {
50 #[primary_span]
51 pub span: Span,
52 pub attr_name: &'static str,
53}
54
55#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DocFakeVariadicNotValid {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
56#[diag(
57 "`#[doc(fake_variadic)]` must be used on the first of a set of tuple or fn pointer trait impls with varying arity"
58)]
59pub(crate) struct DocFakeVariadicNotValid {
60 #[primary_span]
61 pub span: Span,
62}
63
64#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for DocKeywordOnlyImpl {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
65#[diag("`#[doc(keyword = \"...\")]` should be used on impl blocks")]
66pub(crate) struct DocKeywordOnlyImpl {
67 #[primary_span]
68 pub span: Span,
69}
70
71#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DocSearchUnboxInvalid {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
72#[diag("`#[doc(search_unbox)]` should be used on generic structs and enums")]
73pub(crate) struct DocSearchUnboxInvalid {
74 #[primary_span]
75 pub span: Span,
76}
77
78#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DocMaskedOnlyExternCrate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DocMaskedOnlyExternCrate {
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("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
}
}
}
}
};Diagnostic)]
79#[diag("this attribute can only be applied to an `extern crate` item")]
80#[note(
81 "read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information"
82)]
83pub(crate) struct DocMaskedOnlyExternCrate {
84 #[label("only applicable on `extern crate` items")]
85 pub attr_span: Span,
86 #[label("not an `extern crate` item")]
87 pub item_span: Span,
88}
89
90#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DocMaskedNotExternCrateSelf {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DocMaskedNotExternCrateSelf {
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("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
}
}
}
}
};Diagnostic)]
91#[diag("this attribute cannot be applied to an `extern crate self` item")]
92pub(crate) struct DocMaskedNotExternCrateSelf {
93 #[label("not applicable on `extern crate self` items")]
94 pub attr_span: Span,
95 #[label("`extern crate self` defined here")]
96 pub item_span: Span,
97}
98
99#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
BothOptimizeNoneAndInline {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BothOptimizeNoneAndInline {
optimize_span: __binding_0, inline_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[optimize(none)]` cannot be used with `#[inline]` attributes")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[optimize(none)]` here")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[inline]` here")));
diag
}
}
}
}
};Diagnostic)]
100#[diag("`#[optimize(none)]` cannot be used with `#[inline]` attributes")]
101pub(crate) struct BothOptimizeNoneAndInline {
102 #[primary_span]
103 #[label("`#[optimize(none)]` here")]
104 pub optimize_span: Span,
105 #[label("`#[inline]` here")]
106 pub inline_span: Span,
107}
108
109#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ReprConflicting {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
110#[diag("conflicting representation hints", code = E0566)]
111pub(crate) struct ReprConflicting {
112 #[primary_span]
113 pub hint_spans: Vec<Span>,
114}
115
116#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ReprConflictingLint
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ReprConflictingLint => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("conflicting representation hints")));
diag.code(E0566);
;
diag
}
}
}
}
};Diagnostic)]
117#[diag("conflicting representation hints", code = E0566)]
118pub(crate) struct ReprConflictingLint;
119
120#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
DebugVisualizerUnreadable<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
121#[diag("couldn't read {$file}: {$error}")]
122pub(crate) struct DebugVisualizerUnreadable<'a> {
123 #[primary_span]
124 pub span: Span,
125 pub file: &'a Path,
126 pub error: Error,
127}
128
129#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RustcAllowConstFnUnstable {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
130#[diag("attribute should be applied to `const fn`")]
131pub(crate) struct RustcAllowConstFnUnstable {
132 #[primary_span]
133 pub attr_span: Span,
134 #[label("not a `const fn`")]
135 pub span: Span,
136}
137
138#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for RustcForceInlineCoro
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
139#[diag("attribute cannot be applied to a `async`, `gen` or `async gen` function")]
140pub(crate) struct RustcForceInlineCoro {
141 #[primary_span]
142 pub attr_span: Span,
143 #[label("`async`, `gen` or `async gen` function")]
144 pub span: Span,
145}
146
147#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedNote {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
UnusedNote::LinkerMessagesBinaryCrateOnly => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `linker_messages` and `linker_info` lints can only be controlled at the root of a crate that needs to be linked")),
&sub_args);
diag.note(__message);
}
UnusedNote::NoEffectDeadCodePubInBinary => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `dead_code_pub_in_binary` lint has no effect in library crates")),
&sub_args);
diag.note(__message);
}
UnusedNote::PathOnInlineModule => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[path]` is unused on this inline module")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
148pub(crate) enum UnusedNote {
149 #[note(
150 "the `linker_messages` and `linker_info` lints can only be controlled at the root of a crate that needs to be linked"
151 )]
152 LinkerMessagesBinaryCrateOnly,
153 #[note("the `dead_code_pub_in_binary` lint has no effect in library crates")]
154 NoEffectDeadCodePubInBinary,
155 #[note("`#[path]` is unused on this inline module")]
156 PathOnInlineModule,
157}
158
159#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for Unused {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
Unused { attr_span: __binding_0, note: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused attribute")));
let __code_1 =
[::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_1, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
160#[diag("unused attribute")]
161pub(crate) struct Unused {
162 #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
163 pub attr_span: Span,
164 #[subdiagnostic]
165 pub note: UnusedNote,
166}
167
168#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NonExportedMacroInvalidAttrs {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
169#[diag("attribute should be applied to function or closure", code = E0518)]
170pub(crate) struct NonExportedMacroInvalidAttrs {
171 #[primary_span]
172 #[label("not a function or closure")]
173 pub attr_span: Span,
174}
175
176#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for InvalidMayDangle {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
177#[diag("`#[may_dangle]` must be applied to a lifetime or type generic parameter in `Drop` impl")]
178pub(crate) struct InvalidMayDangle {
179 #[primary_span]
180 pub attr_span: Span,
181}
182
183#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MissingPanicHandler
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
184#[diag("`#[panic_handler]` function required, but not found")]
185pub(crate) struct MissingPanicHandler;
186
187#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
PanicUnwindWithoutStd {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
188#[diag("unwinding panics are not supported without std")]
189#[help("using nightly cargo, use -Zbuild-std with panic=\"abort\" to avoid unwinding")]
190#[note(
191 "since the core library is usually precompiled with panic=\"unwind\", rebuilding your crate with panic=\"abort\" may not be enough to fix the problem"
192)]
193pub(crate) struct PanicUnwindWithoutStd;
194
195#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MissingLangItem {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
196#[diag("lang item required, but not found: `{$name}`")]
197#[note(
198 "this can occur when a binary crate with `#![no_std]` is compiled for a target where `{$name}` is defined in the standard library"
199)]
200#[help(
201 "you may be able to compile for a target that doesn't need `{$name}`, specify a target with `--target` or in `.cargo/config`"
202)]
203pub(crate) struct MissingLangItem {
204 pub name: Symbol,
205}
206
207#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DuplicateDiagnosticItemInCrate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
208#[diag("duplicate diagnostic item in crate `{$crate_name}`: `{$name}`")]
209pub(crate) struct DuplicateDiagnosticItemInCrate {
210 #[primary_span]
211 pub duplicate_span: Option<Span>,
212 #[note("the diagnostic item is first defined here")]
213 pub orig_span: Option<Span>,
214 #[note("the diagnostic item is first defined in crate `{$orig_crate_name}`")]
215 pub different_crates: bool,
216 pub crate_name: Symbol,
217 pub orig_crate_name: Symbol,
218 pub name: Symbol,
219}
220
221#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
DuplicateCanonicalSymbolInCrate {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DuplicateCanonicalSymbolInCrate {
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 canonical symbol 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 canonical symbol is first defined here")));
}
if __binding_2 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the canonical symbol is first defined in crate `{$orig_crate_name}`")));
}
diag
}
}
}
}
};Diagnostic)]
222#[diag("duplicate canonical symbol in crate `{$crate_name}`: `{$name}`")]
223pub(crate) struct DuplicateCanonicalSymbolInCrate {
224 #[primary_span]
225 pub duplicate_span: Option<Span>,
226 #[note("the canonical symbol is first defined here")]
227 pub orig_span: Option<Span>,
228 #[note("the canonical symbol is first defined in crate `{$orig_crate_name}`")]
229 pub different_crates: bool,
230 pub crate_name: Symbol,
231 pub orig_crate_name: Symbol,
232 pub name: Symbol,
233}
234
235#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AbiOf {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
236#[diag("fn_abi_of({$fn_name}) = {$fn_abi}")]
237pub(crate) struct AbiOf {
238 #[primary_span]
239 pub span: Span,
240 pub fn_name: Symbol,
241 pub fn_abi: String,
242}
243
244#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AbiNe {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
245#[diag(
246 "ABIs are not compatible
247 left ABI = {$left}
248 right ABI = {$right}"
249)]
250pub(crate) struct AbiNe {
251 #[primary_span]
252 pub span: Span,
253 pub left: String,
254 pub right: String,
255}
256
257#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for AbiInvalidAttribute
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AbiInvalidAttribute { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
258#[diag(
259 "the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions"
260)]
261pub(crate) struct AbiInvalidAttribute {
262 #[primary_span]
263 pub span: Span,
264}
265
266#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnrecognizedArgument
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
267#[diag("unrecognized argument")]
268pub(crate) struct UnrecognizedArgument {
269 #[primary_span]
270 pub span: Span,
271}
272
273#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FeatureStableTwice {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
274#[diag("feature `{$feature}` is declared stable since {$since}, but was previously declared stable since {$prev_since}", code = E0711)]
275pub(crate) struct FeatureStableTwice {
276 #[primary_span]
277 pub span: Span,
278 pub feature: Symbol,
279 pub since: Symbol,
280 pub prev_since: Symbol,
281}
282
283#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
FeaturePreviouslyDeclared<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
284#[diag("feature `{$feature}` is declared {$declared}, but was previously declared {$prev_declared}", code = E0711)]
285pub(crate) struct FeaturePreviouslyDeclared<'a> {
286 #[primary_span]
287 pub span: Span,
288 pub feature: Symbol,
289 pub declared: &'a str,
290 pub prev_declared: &'a str,
291}
292
293#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MultipleRustcMain {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
294#[diag("multiple functions with a `#[rustc_main]` attribute", code = E0137)]
295pub(crate) struct MultipleRustcMain {
296 #[primary_span]
297 pub span: Span,
298 #[label("first `#[rustc_main]` function")]
299 pub first: Span,
300 #[label("additional `#[rustc_main]` function")]
301 pub additional: Span,
302}
303
304#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ExternMain {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
305#[diag("the `main` function cannot be declared in an `extern` block")]
306pub(crate) struct ExternMain {
307 #[primary_span]
308 pub span: Span,
309}
310
311pub(crate) struct NoMainErr {
312 pub sp: Span,
313 pub crate_name: Symbol,
314 pub has_filename: bool,
315 pub filename: PathBuf,
316 pub file_empty: bool,
317 pub non_main_fns: Vec<Span>,
318 pub main_def_opt: Option<MainDefinition>,
319 pub add_teach_note: bool,
320}
321
322impl<'a> Diagnostic<'a> for NoMainErr {
323 #[track_caller]
324 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> {
325 let mut diag =
326 Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function not found in crate `{$crate_name}`"))msg!("`main` function not found in crate `{$crate_name}`"));
327 diag.span(DUMMY_SP);
328 diag.code(E0601);
329 diag.arg("crate_name", self.crate_name);
330 diag.arg("filename", self.filename);
331 diag.arg("has_filename", self.has_filename);
332 let note = if !self.non_main_fns.is_empty() {
333 for &span in &self.non_main_fns {
334 diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("here is a function named `main`"))msg!("here is a function named `main`"));
335 }
336 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you have one or more functions named `main` not defined at the crate level"))msg!(
337 "you have one or more functions named `main` not defined at the crate level"
338 ));
339 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving the `main` function definitions"))msg!("consider moving the `main` function definitions"));
340 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the main function must be defined at the crate level{$has_filename ->\n [true] {\" \"}(in `{$filename}`)\n *[false] {\"\"}\n }"))msg!(
342 "the main function must be defined at the crate level{$has_filename ->
343 [true] {\" \"}(in `{$filename}`)
344 *[false] {\"\"}
345 }"
346 )
347 } else if self.has_filename {
348 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a `main` function to `{$filename}`"))msg!("consider adding a `main` function to `{$filename}`")
349 } else {
350 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding a `main` function at the crate level"))msg!("consider adding a `main` function at the crate level")
351 };
352 if self.file_empty {
353 diag.note(note);
354 } else {
355 diag.span(self.sp.shrink_to_hi());
356 diag.span_label(self.sp.shrink_to_hi(), note);
357 }
358
359 if let Some(main_def) = self.main_def_opt
360 && main_def.opt_fn_def_id().is_none()
361 {
362 diag.span_label(main_def.span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-function item at `crate::main` is found"))msg!("non-function item at `crate::main` is found"));
364 }
365
366 if self.add_teach_note {
367 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/"))msg!("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/"));
368 }
369
370 diag
371 }
372}
373pub(crate) struct DuplicateLangItem {
374 pub local_span: Option<Span>,
375 pub lang_item_name: Symbol,
376 pub crate_name: Symbol,
377 pub dependency_of: Option<Symbol>,
378 pub is_local: bool,
379 pub path: String,
380 pub first_defined_span: Option<Span>,
381 pub orig_crate_name: Option<Symbol>,
382 pub orig_dependency_of: Option<Symbol>,
383 pub orig_is_local: bool,
384 pub orig_path: String,
385 pub(crate) duplicate: Duplicate,
386}
387
388impl Diagnostic<'_> for DuplicateLangItem {
389 #[track_caller]
390 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
391 let mut diag = Diag::new(
392 dcx,
393 level,
394 match self.duplicate {
395 Duplicate::Plain => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found duplicate lang item `{$lang_item_name}`"))msg!("found duplicate lang item `{$lang_item_name}`"),
396 Duplicate::Crate => {
397 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("duplicate lang item in crate `{$crate_name}`: `{$lang_item_name}`"))msg!("duplicate lang item in crate `{$crate_name}`: `{$lang_item_name}`")
398 }
399 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}`"))msg!(
400 "duplicate lang item in crate `{$crate_name}` (which `{$dependency_of}` depends on): `{$lang_item_name}`"
401 ),
402 },
403 );
404 diag.code(E0152);
405 diag.arg("lang_item_name", self.lang_item_name);
406 diag.arg("crate_name", self.crate_name);
407 if let Some(dependency_of) = self.dependency_of {
408 diag.arg("dependency_of", dependency_of);
409 }
410 diag.arg("path", self.path);
411 if let Some(orig_crate_name) = self.orig_crate_name {
412 diag.arg("orig_crate_name", orig_crate_name);
413 }
414 if let Some(orig_dependency_of) = self.orig_dependency_of {
415 diag.arg("orig_dependency_of", orig_dependency_of);
416 }
417 diag.arg("orig_path", self.orig_path);
418 if let Some(span) = self.local_span {
419 diag.span(span);
420 }
421 if let Some(span) = self.first_defined_span {
422 diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined here"))msg!("the lang item is first defined here"));
423 } else {
424 if self.orig_dependency_of.is_none() {
425 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lang item is first defined in crate `{$orig_crate_name}`"))msg!("the lang item is first defined in crate `{$orig_crate_name}`"));
426 } else {
427 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)"))msg!("the lang item is first defined in crate `{$orig_crate_name}` (which `{$orig_dependency_of}` depends on)"));
428 }
429
430 if self.orig_is_local {
431 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first definition in the local crate (`{$orig_crate_name}`)"))msg!("first definition in the local crate (`{$orig_crate_name}`)"));
432 } else {
433 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first definition in `{$orig_crate_name}` loaded from {$orig_path}"))msg!(
434 "first definition in `{$orig_crate_name}` loaded from {$orig_path}"
435 ));
436 }
437
438 if self.is_local {
439 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second definition in the local crate (`{$crate_name}`)"))msg!("second definition in the local crate (`{$crate_name}`)"));
440 } else {
441 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("second definition in `{$crate_name}` loaded from {$path}"))msg!("second definition in `{$crate_name}` loaded from {$path}"));
442 }
443 }
444 diag
445 }
446}
447
448#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
IncorrectTarget<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
449#[diag("`{$name}` lang item must be applied to a {$kind} with {$at_least ->
450 [true] at least {$num}
451 *[false] {$num}
452 } generic {$num ->
453 [one] argument
454 *[other] arguments
455 }", code = E0718)]
456pub(crate) struct IncorrectTarget<'a> {
457 #[primary_span]
458 pub span: Span,
459 #[label(
460 "this {$kind} has {$actual_num} generic {$actual_num ->
461 [one] argument
462 *[other] arguments
463 }"
464 )]
465 pub generics_span: Span,
466 pub name: &'a str, pub kind: &'static str,
468 pub num: usize,
469 pub actual_num: usize,
470 pub at_least: bool,
471}
472
473#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for IncorrectCrateType {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
474#[diag("lang items are not allowed in stable dylibs")]
475pub(crate) struct IncorrectCrateType {
476 #[primary_span]
477 pub span: Span,
478}
479
480#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
UselessAssignment<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UselessAssignment {
is_field_assign: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
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
}
}
}
}
};Diagnostic)]
481#[diag(
482 "useless assignment of {$is_field_assign ->
483 [true] field
484 *[false] variable
485 } of type `{$ty}` to itself"
486)]
487pub(crate) struct UselessAssignment<'a> {
488 pub is_field_assign: bool,
489 pub ty: Ty<'a>,
490}
491
492#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
TransparentIncompatible {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
493#[diag("transparent {$target} cannot have other repr hints", code = E0692)]
494pub(crate) struct TransparentIncompatible {
495 #[primary_span]
496 pub hint_spans: Vec<Span>,
497 pub target: String,
498}
499
500#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for RepeatedRepr {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RepeatedRepr => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[repr(..)]` attribute is specified more than once")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for consistency, only specify the representation once")));
;
diag
}
}
}
}
};Diagnostic)]
501#[diag("`#[repr(..)]` attribute is specified more than once")]
502#[note("for consistency, only specify the representation once")]
503pub(crate) struct RepeatedRepr;
504
505#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for DeprecatedAttribute
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
506#[diag("deprecated attribute must be paired with either stable or unstable attribute", code = E0549)]
507pub(crate) struct DeprecatedAttribute {
508 #[primary_span]
509 pub span: Span,
510}
511
512#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UselessStability {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
513#[diag("this stability annotation is useless")]
514pub(crate) struct UselessStability {
515 #[primary_span]
516 #[label("useless stability annotation")]
517 pub span: Span,
518 #[label("the stability attribute annotates this item")]
519 pub item_sp: Span,
520}
521
522#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CannotStabilizeDeprecated {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
523#[diag("an API can't be stabilized after it is deprecated")]
524pub(crate) struct CannotStabilizeDeprecated {
525 #[primary_span]
526 #[label("invalid version")]
527 pub span: Span,
528 #[label("the stability attribute annotates this item")]
529 pub item_sp: Span,
530}
531
532#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
MissingStabilityAttr<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
533#[diag("{$descr} has missing stability attribute")]
534pub(crate) struct MissingStabilityAttr<'a> {
535 #[primary_span]
536 pub span: Span,
537 pub descr: &'a str,
538}
539
540#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
MissingConstStabAttr<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
541#[diag("{$descr} has missing const stability attribute")]
542pub(crate) struct MissingConstStabAttr<'a> {
543 #[primary_span]
544 pub span: Span,
545 pub descr: &'a str,
546}
547
548#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TraitImplConstStable
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
549#[diag("trait implementations cannot be const stable yet")]
550#[note("see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information")]
551pub(crate) struct TraitImplConstStable {
552 #[primary_span]
553 pub span: Span,
554}
555
556#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
TraitImplConstStabilityMismatch {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
557#[diag("const stability on the impl does not match the const stability on the trait")]
558pub(crate) struct TraitImplConstStabilityMismatch {
559 #[primary_span]
560 pub span: Span,
561 #[subdiagnostic]
562 pub impl_stability: ImplConstStability,
563 #[subdiagnostic]
564 pub trait_stability: TraitConstStability,
565}
566
567#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for TraitConstStability {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
TraitConstStability::Stable { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but the trait is stable")),
&sub_args);
diag.span_note(__binding_0, __message);
}
TraitConstStability::Unstable { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but the trait is unstable")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
568pub(crate) enum TraitConstStability {
569 #[note("...but the trait is stable")]
570 Stable {
571 #[primary_span]
572 span: Span,
573 },
574 #[note("...but the trait is unstable")]
575 Unstable {
576 #[primary_span]
577 span: Span,
578 },
579}
580
581#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImplConstStability {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ImplConstStability::Stable { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this impl is (implicitly) stable...")),
&sub_args);
diag.span_note(__binding_0, __message);
}
ImplConstStability::Unstable { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this impl is unstable...")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
582pub(crate) enum ImplConstStability {
583 #[note("this impl is (implicitly) stable...")]
584 Stable {
585 #[primary_span]
586 span: Span,
587 },
588 #[note("this impl is unstable...")]
589 Unstable {
590 #[primary_span]
591 span: Span,
592 },
593}
594
595#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for UnknownFeature {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
596#[diag("unknown feature `{$feature}`", code = E0635)]
597pub(crate) struct UnknownFeature {
598 #[primary_span]
599 pub span: Span,
600 pub feature: Symbol,
601 #[subdiagnostic]
602 pub suggestion: Option<MisspelledFeature>,
603}
604
605#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MisspelledFeature {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MisspelledFeature {
span: __binding_0, actual_name: __binding_1 } => {
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("actual_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is a feature with a similar name: `{$actual_name}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_2, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
606#[suggestion(
607 "there is a feature with a similar name: `{$actual_name}`",
608 style = "verbose",
609 code = "{actual_name}",
610 applicability = "maybe-incorrect"
611)]
612pub(crate) struct MisspelledFeature {
613 #[primary_span]
614 pub span: Span,
615 pub actual_name: Symbol,
616}
617
618#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for RenamedFeature {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
619#[diag("feature `{$alias}` has been renamed to `{$feature}`", code = E0635)]
620pub(crate) struct RenamedFeature {
621 #[primary_span]
622 pub span: Span,
623 pub feature: Symbol,
624 pub alias: Symbol,
625}
626
627#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ImpliedFeatureNotExist {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
628#[diag("feature `{$implied_by}` implying `{$feature}` does not exist")]
629pub(crate) struct ImpliedFeatureNotExist {
630 #[primary_span]
631 pub span: Span,
632 pub feature: Symbol,
633 pub implied_by: Symbol,
634}
635
636#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FeatureRemoved {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FeatureRemoved {
span: __binding_0,
feature: __binding_1,
reason: __binding_2,
since: __binding_3,
link: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature `{$feature}` has been removed")));
diag.code(E0557);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("removed in {$since}; see <{$link}> for more information")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$reason}")));
;
diag.arg("feature", __binding_1);
diag.arg("reason", __binding_2);
diag.arg("since", __binding_3);
diag.arg("link", __binding_4);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("feature has been removed")));
diag
}
}
}
}
};Diagnostic)]
637#[diag("feature `{$feature}` has been removed", code = E0557)]
638#[note("removed in {$since}; see <{$link}> for more information")]
639#[note("{$reason}")]
640pub(crate) struct FeatureRemoved {
641 #[primary_span]
642 #[label("feature has been removed")]
643 pub span: Span,
644 pub feature: Symbol,
645 pub reason: Symbol,
646 pub since: String,
647 pub link: Symbol,
648}
649
650#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for MissingConstErr {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
651#[diag(
652 "attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const`"
653)]
654pub(crate) struct MissingConstErr {
655 #[primary_span]
656 #[help("make the function or method const")]
657 pub fn_sig_span: Span,
658}
659
660#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ConstStableNotStable
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstStableNotStable {
fn_sig_span: __binding_0, path_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `rustc_const_stable` attribute can only be applied to functions marked with the `stable` attribute")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute specified here")));
diag
}
}
}
}
};Diagnostic)]
661#[diag(
662 "the `rustc_const_stable` attribute can only be applied to functions marked with the `stable` attribute"
663)]
664pub(crate) struct ConstStableNotStable {
665 #[primary_span]
666 pub fn_sig_span: Span,
667 #[label("attribute specified here")]
668 pub path_span: Span,
669}
670
671#[derive(const _: () =
{
impl<'_sess, 'tcx> rustc_errors::Diagnostic<'_sess> for
MultipleDeadCodes<'tcx> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MultipleDeadCodes::DeadCodes {
multiple: __binding_0,
num: __binding_1,
descr: __binding_2,
participle: __binding_3,
name_list: __binding_4,
dead_code_pub_in_binary_note: __binding_5,
enum_variants_with_same_name: __binding_6,
parent_info: __binding_7,
ignored_derived_impls: __binding_8 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
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);
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
for __binding_6 in __binding_6 {
diag.subdiagnostic(__binding_6);
}
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
if let Some(__binding_8) = __binding_8 {
diag.subdiagnostic(__binding_8);
}
diag
}
MultipleDeadCodes::UnusedTupleStructFields {
multiple: __binding_0,
num: __binding_1,
descr: __binding_2,
participle: __binding_3,
name_list: __binding_4,
dead_code_pub_in_binary_note: __binding_5,
change_fields_suggestion: __binding_6,
parent_info: __binding_7,
ignored_derived_impls: __binding_8 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
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);
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag.subdiagnostic(__binding_6);
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
if let Some(__binding_8) = __binding_8 {
diag.subdiagnostic(__binding_8);
}
diag
}
}
}
}
};Diagnostic)]
672pub(crate) enum MultipleDeadCodes<'tcx> {
673 #[diag(
674 "{ $multiple ->
675 *[true] multiple {$descr}s are
676 [false] { $num ->
677 [one] {$descr} {$name_list} is
678 *[other] {$descr}s {$name_list} are
679 }
680 } never {$participle}"
681 )]
682 DeadCodes {
683 multiple: bool,
684 num: usize,
685 descr: &'tcx str,
686 participle: &'tcx str,
687 name_list: DiagSymbolList,
688 #[subdiagnostic]
689 dead_code_pub_in_binary_note: Option<DeadCodePubInBinaryNote>,
690 #[subdiagnostic]
691 enum_variants_with_same_name: Vec<EnumVariantSameName<'tcx>>,
693 #[subdiagnostic]
694 parent_info: Option<ParentInfo<'tcx>>,
695 #[subdiagnostic]
696 ignored_derived_impls: Option<IgnoredDerivedImpls>,
697 },
698 #[diag(
699 "{ $multiple ->
700 *[true] multiple {$descr}s are
701 [false] { $num ->
702 [one] {$descr} {$name_list} is
703 *[other] {$descr}s {$name_list} are
704 }
705 } never {$participle}"
706 )]
707 UnusedTupleStructFields {
708 multiple: bool,
709 num: usize,
710 descr: &'tcx str,
711 participle: &'tcx str,
712 name_list: DiagSymbolList,
713 #[subdiagnostic]
714 dead_code_pub_in_binary_note: Option<DeadCodePubInBinaryNote>,
715 #[subdiagnostic]
716 change_fields_suggestion: ChangeFields,
717 #[subdiagnostic]
718 parent_info: Option<ParentInfo<'tcx>>,
719 #[subdiagnostic]
720 ignored_derived_impls: Option<IgnoredDerivedImpls>,
721 },
722}
723
724#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for DeadCodePubInBinaryNote {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
DeadCodePubInBinaryNote => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in libraries, `pub` items can be used by dependent crates; in binaries, they cannot, so this `pub` item is unused")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
725#[note(
726 "in libraries, `pub` items can be used by dependent crates; in binaries, they cannot, so this `pub` item is unused"
727)]
728pub(crate) struct DeadCodePubInBinaryNote;
729
730#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for EnumVariantSameName<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
EnumVariantSameName {
variant_span: __binding_0,
dead_name: __binding_1,
dead_descr: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("dead_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("dead_descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("it is impossible to refer to the {$dead_descr} `{$dead_name}` because it is shadowed by this enum variant with the same name")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
731#[note(
732 "it is impossible to refer to the {$dead_descr} `{$dead_name}` because it is shadowed by this enum variant with the same name"
733)]
734pub(crate) struct EnumVariantSameName<'tcx> {
735 #[primary_span]
736 pub variant_span: Span,
737 pub dead_name: Symbol,
738 pub dead_descr: &'tcx str,
739}
740
741#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for ParentInfo<'tcx> {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ParentInfo {
num: __binding_0,
descr: __binding_1,
parent_descr: __binding_2,
span: __binding_3 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("num".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("parent_descr".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num ->\n [one] {$descr}\n *[other] {$descr}s\n } in this {$parent_descr}")),
&sub_args);
diag.span_label(__binding_3, __message);
}
}
}
}
};Subdiagnostic)]
742#[label(
743 "{$num ->
744 [one] {$descr}
745 *[other] {$descr}s
746 } in this {$parent_descr}"
747)]
748pub(crate) struct ParentInfo<'tcx> {
749 pub num: usize,
750 pub descr: &'tcx str,
751 pub parent_descr: &'tcx str,
752 #[primary_span]
753 pub span: Span,
754}
755
756#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IgnoredDerivedImpls {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
IgnoredDerivedImpls {
name: __binding_0,
trait_list: __binding_1,
trait_list_len: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("trait_list".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("trait_list_len".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$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")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
757#[note(
758 "`{$name}` has {$trait_list_len ->
759 [one] a derived impl
760 *[other] derived impls
761 } for the {$trait_list_len ->
762 [one] trait {$trait_list}, but this is
763 *[other] traits {$trait_list}, but these are
764 } intentionally ignored during dead code analysis"
765)]
766pub(crate) struct IgnoredDerivedImpls {
767 pub name: Symbol,
768 pub trait_list: DiagSymbolList,
769 pub trait_list_len: usize,
770}
771
772#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeFields {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
ChangeFields::ChangeToUnitTypeOrRemove {
num: __binding_0, spans: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_3 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("()"))
});
for __binding_1 in __binding_1 {
suggestions.push((__binding_1, __code_3.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("num".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("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 }")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
ChangeFields::Remove { num: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("num".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing { $num ->\n [one] this\n *[other] these\n } { $num ->\n [one] field\n *[other] fields\n }")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
773pub(crate) enum ChangeFields {
774 #[multipart_suggestion(
775 "consider changing the { $num ->
776 [one] field
777 *[other] fields
778 } to be of unit type to suppress this warning while preserving the field numbering, or remove the { $num ->
779 [one] field
780 *[other] fields
781 }",
782 applicability = "has-placeholders"
783 )]
784 ChangeToUnitTypeOrRemove {
785 num: usize,
786 #[suggestion_part(code = "()")]
787 spans: Vec<Span>,
788 },
789 #[help(
790 "consider removing { $num ->
791 [one] this
792 *[other] these
793 } { $num ->
794 [one] field
795 *[other] fields
796 }"
797 )]
798 Remove { num: usize },
799}
800
801#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ProcMacroBadSig {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
802#[diag("{$kind} has incorrect signature")]
803pub(crate) struct ProcMacroBadSig {
804 #[primary_span]
805 pub span: Span,
806 pub kind: ProcMacroKind,
807}
808
809#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for DuplicateFeature {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DuplicateFeature { feature: __binding_0 } => {
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.arg("feature", __binding_0);
diag
}
}
}
}
};Diagnostic)]
810#[diag("the feature `{$feature}` has already been enabled")]
811pub(crate) struct DuplicateFeature {
812 pub feature: Symbol,
813}
814
815#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnnecessaryStableFeature {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnnecessaryStableFeature {
feature: __binding_0, since: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
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
}
}
}
}
};Diagnostic)]
816#[diag(
817 "the feature `{$feature}` has been stable since {$since} and no longer requires an attribute to enable"
818)]
819pub(crate) struct UnnecessaryStableFeature {
820 pub feature: Symbol,
821 pub since: Symbol,
822}
823
824#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnnecessaryPartialStableFeature {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnnecessaryPartialStableFeature {
span: __binding_0,
line: __binding_1,
feature: __binding_2,
since: __binding_3,
implies: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
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_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_4))
})].into_iter();
let __code_5 =
[::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_4, 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_5, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
825#[diag(
826 "the feature `{$feature}` has been partially stabilized since {$since} and is succeeded by the feature `{$implies}`"
827)]
828pub(crate) struct UnnecessaryPartialStableFeature {
829 #[suggestion(
830 "if you are using features which are still unstable, change to using `{$implies}`",
831 code = "{implies}",
832 applicability = "maybe-incorrect"
833 )]
834 pub span: Span,
835 #[suggestion(
836 "if you are using features which are now stable, remove this line",
837 code = "",
838 applicability = "maybe-incorrect"
839 )]
840 pub line: Span,
841 pub feature: Symbol,
842 pub since: Symbol,
843 pub implies: Symbol,
844}
845
846#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
IneffectiveUnstableImpl {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IneffectiveUnstableImpl => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
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
}
}
}
}
};Diagnostic)]
847#[diag("an `#[unstable]` annotation here has no effect")]
848#[note("see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information")]
849pub(crate) struct IneffectiveUnstableImpl;
850
851#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
IneffectiveUnstableReexport {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IneffectiveUnstableReexport => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[unstable]` does not make this re-exported path unstable")));
;
diag
}
}
}
}
};Diagnostic)]
852#[diag("`#[unstable]` does not make this re-exported path unstable")]
853pub(crate) struct IneffectiveUnstableReexport;
854
855#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RustcConstStableIndirectPairing {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
857#[diag(
858 "`const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied"
859)]
860pub(crate) struct RustcConstStableIndirectPairing {
861 #[primary_span]
862 pub span: Span,
863}
864
865#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
UnexportableItem<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
866pub(crate) enum UnexportableItem<'a> {
867 #[diag("{$descr}'s are not exportable")]
868 Item {
869 #[primary_span]
870 span: Span,
871 descr: &'a str,
872 },
873
874 #[diag("generic functions are not exportable")]
875 GenericFn(#[primary_span] Span),
876
877 #[diag("only functions with \"C\" ABI are exportable")]
878 FnAbi(#[primary_span] Span),
879
880 #[diag("types with unstable layout are not exportable")]
881 TypeRepr(#[primary_span] Span),
882
883 #[diag("{$desc} with `#[export_stable]` attribute uses type `{$ty}`, which is not exportable")]
884 TypeInInterface {
885 #[primary_span]
886 span: Span,
887 desc: &'a str,
888 ty: &'a str,
889 #[label("not exportable")]
890 ty_span: Span,
891 },
892
893 #[diag("private items are not exportable")]
894 PrivItem {
895 #[primary_span]
896 span: Span,
897 #[note("is only usable at visibility `{$vis_descr}`")]
898 vis_note: Span,
899 vis_descr: &'a str,
900 },
901
902 #[diag("ADT types with private fields are not exportable")]
903 AdtWithPrivFields {
904 #[primary_span]
905 span: Span,
906 #[note("`{$field_name}` is private")]
907 vis_note: Span,
908 field_name: &'a str,
909 },
910}
911
912#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
EiiImplRequiresUnsafe {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
913#[diag("`#[{$name}]` is unsafe to implement")]
914pub(crate) struct EiiImplRequiresUnsafe {
915 #[primary_span]
916 pub span: Span,
917 pub name: Symbol,
918 #[subdiagnostic]
919 pub suggestion: EiiImplRequiresUnsafeSuggestion,
920}
921
922#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for EiiImplRequiresUnsafeSuggestion {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
EiiImplRequiresUnsafeSuggestion {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_6 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe("))
});
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_6));
suggestions.push((__binding_1, __code_7));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the attribute in `unsafe(...)`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
923#[multipart_suggestion("wrap the attribute in `unsafe(...)`", applicability = "machine-applicable")]
924pub(crate) struct EiiImplRequiresUnsafeSuggestion {
925 #[suggestion_part(code = "unsafe(")]
926 pub left: Span,
927 #[suggestion_part(code = ")")]
928 pub right: Span,
929}
930
931#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
EiiImplCannotBeUnsafe {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EiiImplCannotBeUnsafe {
impl_span: __binding_0,
unsafe_span: __binding_1,
name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` is not unsafe to implement")));
;
diag.arg("name", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`unsafe` is not allowed here")));
diag
}
}
}
}
};Diagnostic)]
932#[diag("`{$name}` is not unsafe to implement")]
933pub(crate) struct EiiImplCannotBeUnsafe {
934 #[primary_span]
935 pub impl_span: Span,
936 #[label("`unsafe` is not allowed here")]
937 pub unsafe_span: Span,
938 pub name: Symbol,
939}
940
941#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for EiiWithoutImpl {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EiiWithoutImpl {
span: __binding_0,
name: __binding_1,
kind: __binding_2,
current_crate_name: __binding_3,
decl_crate_name: __binding_4,
help: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}]` {$kind} required, but not found")));
;
diag.arg("name", __binding_1);
diag.arg("kind", __binding_2);
diag.arg("current_crate_name", __binding_3);
diag.arg("decl_crate_name", __binding_4);
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)]
942#[diag("`#[{$name}]` {$kind} required, but not found")]
943pub(crate) struct EiiWithoutImpl {
944 #[primary_span]
945 #[label("expected because `#[{$name}]` was declared here in crate `{$decl_crate_name}`")]
946 pub span: Span,
947 pub name: Symbol,
948 pub kind: &'static str,
949
950 pub current_crate_name: Symbol,
951 pub decl_crate_name: Symbol,
952 #[help(
953 "expected at least one implementation in crate `{$current_crate_name}` or any of its dependencies"
954 )]
955 pub help: (),
956}
957
958#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
FunctionNotHaveDefaultImplementation {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
959#[diag("function doesn't have a default implementation")]
960pub(crate) struct FunctionNotHaveDefaultImplementation {
961 #[primary_span]
962 pub span: Span,
963 #[note("required by this annotation")]
964 pub note_span: Span,
965}
966
967#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MustImplementNotFunction {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
968#[diag("not a function")]
969pub(crate) struct MustImplementNotFunction {
970 #[primary_span]
971 pub span: Span,
972 #[subdiagnostic]
973 pub span_note: MustImplementNotFunctionSpanNote,
974 #[subdiagnostic]
975 pub note: MustImplementNotFunctionNote,
976}
977
978#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MustImplementNotFunctionSpanNote
{
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MustImplementNotFunctionSpanNote { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required by this annotation")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
979#[note("required by this annotation")]
980pub(crate) struct MustImplementNotFunctionSpanNote {
981 #[primary_span]
982 pub span: Span,
983}
984
985#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MustImplementNotFunctionNote {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
MustImplementNotFunctionNote {} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("all `#[rustc_must_implement_one_of]` arguments must be associated function names")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
986#[note("all `#[rustc_must_implement_one_of]` arguments must be associated function names")]
987pub(crate) struct MustImplementNotFunctionNote {}
988
989#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
FunctionNotFoundInTrait {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
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)]
990#[diag("function not found in this trait")]
991pub(crate) struct FunctionNotFoundInTrait {
992 #[primary_span]
993 pub span: Span,
994}
995
996#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnknownFormatParameterForOnUnimplementedAttr {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnknownFormatParameterForOnUnimplementedAttr {
argument_name: __binding_0,
trait_name: __binding_1,
help: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is no parameter `{$argument_name}` on trait `{$trait_name}`")));
;
diag.arg("argument_name", __binding_0);
diag.arg("trait_name", __binding_1);
if __binding_2 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expect either a generic argument name or {\"`{Self}`\"} as format argument")));
}
diag
}
}
}
}
};Diagnostic)]
997#[diag("there is no parameter `{$argument_name}` on trait `{$trait_name}`")]
998pub(crate) struct UnknownFormatParameterForOnUnimplementedAttr {
999 pub argument_name: Symbol,
1000 pub trait_name: Ident,
1001 #[help(r#"expect either a generic argument name or {"`{Self}`"} as format argument"#)]
1003 pub help: bool,
1004}
1005
1006#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
OnMoveMalformedFormatLiterals {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OnMoveMalformedFormatLiterals { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown parameter `{$name}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expect either a generic argument name or {\"`{Self}`\"} as format argument")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1007#[diag("unknown parameter `{$name}`")]
1008#[help(r#"expect either a generic argument name or {"`{Self}`"} as format argument"#)]
1009pub(crate) struct OnMoveMalformedFormatLiterals {
1010 pub name: Symbol,
1011}
1012
1013#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
OnConstMalformedFormatLiterals {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OnConstMalformedFormatLiterals { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown parameter `{$name}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expect either a generic argument name or {\"`{Self}`\"} as format argument")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1014#[diag("unknown parameter `{$name}`")]
1015#[help(r#"expect either a generic argument name or {"`{Self}`"} as format argument"#)]
1016pub(crate) struct OnConstMalformedFormatLiterals {
1017 pub name: Symbol,
1018}
1019
1020#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
GlobOrListDelegationUnusedTargetExpr {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
GlobOrListDelegationUnusedTargetExpr { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused target expression is specified for glob or list delegation")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1021#[diag("unused target expression is specified for glob or list delegation")]
1022pub(crate) struct GlobOrListDelegationUnusedTargetExpr {
1023 #[primary_span]
1024 pub span: Span,
1025}
1026
1027#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
OnTypeErrorMalformedFormatLiterals {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OnTypeErrorMalformedFormatLiterals { name: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown parameter `{$name}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expect either a generic argument name, {\"`{this}`\"}, {\"`{expected}`\"} or {\"`{found}`\"} as format argument")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1028#[diag("unknown parameter `{$name}`")]
1029#[help(r#"expect either a generic argument name, {"`{this}`"}, {"`{expected}`"} or {"`{found}`"} as format argument"#)]
1030pub(crate) struct OnTypeErrorMalformedFormatLiterals {
1031 pub name: Symbol,
1032}
1033
1034#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
OnTypeErrorNotExactlyOneGeneric {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
OnTypeErrorNotExactlyOneGeneric { count: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[diagnostic::on_type_error]` only supports exactly one ADT generic parameter, but found `{$count}`")));
;
diag.arg("count", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1035#[diag(
1036 "`#[diagnostic::on_type_error]` only supports exactly one ADT generic parameter, but found `{$count}`"
1037)]
1038pub(crate) struct OnTypeErrorNotExactlyOneGeneric {
1039 pub count: usize,
1040}
1041
1042#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for StaticMutLinkage {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
StaticMutLinkage { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern mutable statics are incompatible with the `linkage` attribute")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `linkage` attribute on extern statics generates a symbol that contains the address of another static. Making the extern static mutable would allow changing the address, rather than the static the address is pointing to")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1043#[diag("extern mutable statics are incompatible with the `linkage` attribute")]
1044#[note(
1045 "the `linkage` attribute on extern statics generates a symbol that contains the address of \
1046 another static. Making the extern static mutable would allow changing the address, rather \
1047 than the static the address is pointing to"
1048)]
1049pub(crate) struct StaticMutLinkage {
1050 #[primary_span]
1051 pub span: Span,
1052}
1053
1054#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for ConstFnLinkage {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConstFnLinkage { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const fn` are incompatible with the `linkage` attribute")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const fn` may be called at compile time, which happens before linking")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1055#[diag("`const fn` are incompatible with the `linkage` attribute")]
1056#[note("`const fn` may be called at compile time, which happens before linking")]
1057pub(crate) struct ConstFnLinkage {
1058 #[primary_span]
1059 pub span: Span,
1060}
1061
1062#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for RustcAtumSuggestion
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RustcAtumSuggestion {
import_span: __binding_0,
message: __binding_1,
suggestion: __binding_2,
module: __binding_3,
unstable_mod_span: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of deprecated import through accidentally stabilized module `{$module}`")));
let __code_8 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
;
diag.arg("message", __binding_1);
diag.arg("module", __binding_3);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$message}")),
__code_8, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1063#[diag("use of deprecated import through accidentally stabilized module `{$module}`")]
1064pub(crate) struct RustcAtumSuggestion {
1065 #[primary_span]
1066 pub import_span: Span,
1067 pub message: Symbol,
1068 pub suggestion: Symbol,
1069 pub module: Ident,
1070 #[suggestion(
1071 "{$message}",
1072 code = "{suggestion}",
1073 style = "verbose",
1074 applicability = "machine-applicable"
1075 )]
1076 pub unstable_mod_span: Span,
1077}
1078
1079#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RustcAssertVarianceFailed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RustcAssertVarianceFailed {
item_span: __binding_0,
note: __binding_1,
param_span: __binding_2,
param_ident: __binding_3,
item_ident: __binding_4,
expected_variance: __binding_5,
actual_variance: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$item_ident}` is expected to be {$expected_variance} in `{$param_ident}` but is not")));
;
diag.arg("param_ident", __binding_3);
diag.arg("item_ident", __binding_4);
diag.arg("expected_variance", __binding_5);
diag.arg("actual_variance", __binding_6);
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$item_ident}` is {$actual_variance} in `{$param_ident}`")));
diag
}
}
}
}
};Diagnostic)]
1080#[diag("`{$item_ident}` is expected to be {$expected_variance} in `{$param_ident}` but is not")]
1081pub(crate) struct RustcAssertVarianceFailed {
1082 #[primary_span]
1083 pub item_span: Span,
1084 #[subdiagnostic]
1085 pub note: RustcAssertVarianceFailedNote,
1086 #[label("`{$item_ident}` is {$actual_variance} in `{$param_ident}`")]
1087 pub param_span: Span,
1088 pub param_ident: Ident,
1089 pub item_ident: Ident,
1090 pub expected_variance: Symbol,
1091 pub actual_variance: Symbol,
1092}
1093
1094#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RustcAssertVarianceFailedNote {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
RustcAssertVarianceFailedNote { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required by this attribute")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1095#[note("required by this attribute")]
1096pub(crate) struct RustcAssertVarianceFailedNote {
1097 #[primary_span]
1098 pub span: Span,
1099}