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