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