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