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