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