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