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