1use std::num::NonZero;
4
5use rustc_data_structures::fx::FxIndexMap;
6use rustc_errors::codes::*;
7use rustc_errors::formatting::DiagMessageAddArg;
8use rustc_errors::{
9 Applicability, Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic,
10 EmissionGuarantee, Level, Subdiagnostic, SuggestionStyle, msg,
11};
12use rustc_hir as hir;
13use rustc_hir::def_id::DefId;
14use rustc_hir::intravisit::VisitorExt;
15use rustc_macros::{Diagnostic, Subdiagnostic};
16use rustc_middle::ty::inhabitedness::InhabitedPredicate;
17use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt};
18use rustc_session::Session;
19use rustc_span::edition::Edition;
20use rustc_span::{Ident, Span, Symbol, sym};
21
22use crate::LateContext;
23use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds};
24use crate::errors::{OverruledAttributeSub, RequestedLevel};
25use crate::lifetime_syntax::LifetimeSyntaxCategories;
26
27#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ShadowedIntoIterDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ShadowedIntoIterDiag {
target: __binding_0,
edition: __binding_1,
suggestion: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this method call resolves to `<&{$target} as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<{$target} as IntoIterator>::into_iter` in Rust {$edition}")));
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("iter"))
})].into_iter();
;
diag.arg("target", __binding_0);
diag.arg("edition", __binding_1);
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `.iter()` instead of `.into_iter()` to avoid ambiguity")),
__code_4, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
29#[diag(
30 "this method call resolves to `<&{$target} as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<{$target} as IntoIterator>::into_iter` in Rust {$edition}"
31)]
32pub(crate) struct ShadowedIntoIterDiag {
33 pub target: &'static str,
34 pub edition: &'static str,
35 #[suggestion(
36 "use `.iter()` instead of `.into_iter()` to avoid ambiguity",
37 code = "iter",
38 applicability = "machine-applicable"
39 )]
40 pub suggestion: Span,
41 #[subdiagnostic]
42 pub sub: Option<ShadowedIntoIterDiagSub>,
43}
44
45#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ShadowedIntoIterDiagSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ShadowedIntoIterDiagSub::RemoveIntoIter { span: __binding_0
} => {
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or remove `.into_iter()` to iterate by value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_5, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
ShadowedIntoIterDiagSub::UseExplicitIntoIter {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_6 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("IntoIterator::into_iter("))
});
let __code_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_6));
suggestions.push((__binding_1, __code_7));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
46pub(crate) enum ShadowedIntoIterDiagSub {
47 #[suggestion(
48 "or remove `.into_iter()` to iterate by value",
49 code = "",
50 applicability = "maybe-incorrect"
51 )]
52 RemoveIntoIter {
53 #[primary_span]
54 span: Span,
55 },
56 #[multipart_suggestion(
57 "or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value",
58 applicability = "maybe-incorrect"
59 )]
60 UseExplicitIntoIter {
61 #[suggestion_part(code = "IntoIterator::into_iter(")]
62 start_span: Span,
63 #[suggestion_part(code = ")")]
64 end_span: Span,
65 },
66}
67
68#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ImplicitUnsafeAutorefsDiag<'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 {
ImplicitUnsafeAutorefsDiag {
raw_ptr_span: __binding_0,
raw_ptr_ty: __binding_1,
origin: __binding_2,
method: __binding_3,
suggestion: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implicit autoref creates a reference to the dereference of a raw pointer")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("creating a reference requires the pointer target to be valid and imposes aliasing requirements")));
;
diag.arg("raw_ptr_ty", __binding_1);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this raw pointer has type `{$raw_ptr_ty}`")));
diag.subdiagnostic(__binding_2);
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag.subdiagnostic(__binding_4);
diag
}
}
}
}
};Diagnostic)]
70#[diag("implicit autoref creates a reference to the dereference of a raw pointer")]
71#[note(
72 "creating a reference requires the pointer target to be valid and imposes aliasing requirements"
73)]
74pub(crate) struct ImplicitUnsafeAutorefsDiag<'a> {
75 #[label("this raw pointer has type `{$raw_ptr_ty}`")]
76 pub raw_ptr_span: Span,
77 pub raw_ptr_ty: Ty<'a>,
78 #[subdiagnostic]
79 pub origin: ImplicitUnsafeAutorefsOrigin<'a>,
80 #[subdiagnostic]
81 pub method: Option<ImplicitUnsafeAutorefsMethodNote>,
82 #[subdiagnostic]
83 pub suggestion: ImplicitUnsafeAutorefsSuggestion,
84}
85
86#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
ImplicitUnsafeAutorefsOrigin<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ImplicitUnsafeAutorefsOrigin::Autoref {
autoref_span: __binding_0, autoref_ty: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("autoref_ty".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("autoref is being applied to this expression, resulting in: `{$autoref_ty}`")),
&sub_args);
diag.span_note(__binding_0, __message);
}
ImplicitUnsafeAutorefsOrigin::OverloadedDeref => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are created through calls to explicit `Deref(Mut)::deref(_mut)` implementations")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
87pub(crate) enum ImplicitUnsafeAutorefsOrigin<'a> {
88 #[note("autoref is being applied to this expression, resulting in: `{$autoref_ty}`")]
89 Autoref {
90 #[primary_span]
91 autoref_span: Span,
92 autoref_ty: Ty<'a>,
93 },
94 #[note(
95 "references are created through calls to explicit `Deref(Mut)::deref(_mut)` implementations"
96 )]
97 OverloadedDeref,
98}
99
100#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImplicitUnsafeAutorefsMethodNote
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ImplicitUnsafeAutorefsMethodNote {
def_span: __binding_0, method_name: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("method_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("method calls to `{$method_name}` require a reference")),
&sub_args);
diag.span_note(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
101#[note("method calls to `{$method_name}` require a reference")]
102pub(crate) struct ImplicitUnsafeAutorefsMethodNote {
103 #[primary_span]
104 pub def_span: Span,
105 pub method_name: Symbol,
106}
107
108#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ImplicitUnsafeAutorefsSuggestion
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ImplicitUnsafeAutorefsSuggestion {
mutbl: __binding_0,
deref: __binding_1,
start_span: __binding_2,
end_span: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("({1}{0}", __binding_1,
__binding_0))
});
let __code_9 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_2, __code_8));
suggestions.push((__binding_3, __code_9));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("mutbl".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("deref".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("try using a raw pointer method instead; or if this reference is intentional, make it explicit")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
109#[multipart_suggestion(
110 "try using a raw pointer method instead; or if this reference is intentional, make it explicit",
111 applicability = "maybe-incorrect"
112)]
113pub(crate) struct ImplicitUnsafeAutorefsSuggestion {
114 pub mutbl: &'static str,
115 pub deref: &'static str,
116 #[suggestion_part(code = "({mutbl}{deref}")]
117 pub start_span: Span,
118 #[suggestion_part(code = ")")]
119 pub end_span: Span,
120}
121
122#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinWhileTrue where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinWhileTrue {
suggestion: __binding_0, replace: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("denote infinite loops with `loop {\"{\"} ... {\"}\"}`")));
let __code_10 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("replace", __binding_1);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `loop`")),
__code_10, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
124#[diag("denote infinite loops with `loop {\"{\"} ... {\"}\"}`")]
125pub(crate) struct BuiltinWhileTrue {
126 #[suggestion(
127 "use `loop`",
128 style = "short",
129 code = "{replace}",
130 applicability = "machine-applicable"
131 )]
132 pub suggestion: Span,
133 pub replace: String,
134}
135
136#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinNonShorthandFieldPatterns where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinNonShorthandFieldPatterns {
ident: __binding_0,
suggestion: __binding_1,
prefix: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$ident}:` in this pattern is redundant")));
let __code_11 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}{0}", __binding_0,
__binding_2))
})].into_iter();
;
diag.arg("ident", __binding_0);
diag.arg("prefix", __binding_2);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use shorthand field pattern")),
__code_11, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
137#[diag("the `{$ident}:` in this pattern is redundant")]
138pub(crate) struct BuiltinNonShorthandFieldPatterns {
139 pub ident: Ident,
140 #[suggestion(
141 "use shorthand field pattern",
142 code = "{prefix}{ident}",
143 applicability = "machine-applicable"
144 )]
145 pub suggestion: Span,
146 pub prefix: &'static str,
147}
148
149#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BuiltinUnsafe
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinUnsafe::AllowInternalUnsafe => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site")));
;
diag
}
BuiltinUnsafe::UnsafeBlock => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of an `unsafe` block")));
;
diag
}
BuiltinUnsafe::UnsafeExternBlock => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of an `unsafe extern` block")));
;
diag
}
BuiltinUnsafe::UnsafeTrait => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of an `unsafe` trait")));
;
diag
}
BuiltinUnsafe::UnsafeImpl => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementation of an `unsafe` trait")));
;
diag
}
BuiltinUnsafe::NoMangleFn => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a `no_mangle` function")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::ExportNameFn => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a function with `export_name`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::LinkSectionFn => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a function with `link_section`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the program's behavior with overridden link sections on items is unpredictable and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::NoMangleStatic => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a `no_mangle` static")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::ExportNameStatic => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a static with `export_name`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::LinkSectionStatic => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a static with `link_section`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the program's behavior with overridden link sections on items is unpredictable and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::NoMangleMethod => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a `no_mangle` method")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::ExportNameMethod => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of a method with `export_name`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them")));
;
diag
}
BuiltinUnsafe::DeclUnsafeFn => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of an `unsafe` function")));
;
diag
}
BuiltinUnsafe::DeclUnsafeMethod => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of an `unsafe` method")));
;
diag
}
BuiltinUnsafe::ImplUnsafeMethod => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementation of an `unsafe` method")));
;
diag
}
BuiltinUnsafe::GlobalAsm => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of `core::arch::global_asm`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using this macro is unsafe even though it does not need an `unsafe` block")));
;
diag
}
}
}
}
};Diagnostic)]
150pub(crate) enum BuiltinUnsafe {
151 #[diag(
152 "`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site"
153 )]
154 AllowInternalUnsafe,
155 #[diag("usage of an `unsafe` block")]
156 UnsafeBlock,
157 #[diag("usage of an `unsafe extern` block")]
158 UnsafeExternBlock,
159 #[diag("declaration of an `unsafe` trait")]
160 UnsafeTrait,
161 #[diag("implementation of an `unsafe` trait")]
162 UnsafeImpl,
163 #[diag("declaration of a `no_mangle` function")]
164 #[note(
165 "the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them"
166 )]
167 NoMangleFn,
168 #[diag("declaration of a function with `export_name`")]
169 #[note(
170 "the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them"
171 )]
172 ExportNameFn,
173 #[diag("declaration of a function with `link_section`")]
174 #[note(
175 "the program's behavior with overridden link sections on items is unpredictable and Rust cannot provide guarantees when you manually override them"
176 )]
177 LinkSectionFn,
178 #[diag("declaration of a `no_mangle` static")]
179 #[note(
180 "the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them"
181 )]
182 NoMangleStatic,
183 #[diag("declaration of a static with `export_name`")]
184 #[note(
185 "the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them"
186 )]
187 ExportNameStatic,
188 #[diag("declaration of a static with `link_section`")]
189 #[note(
190 "the program's behavior with overridden link sections on items is unpredictable and Rust cannot provide guarantees when you manually override them"
191 )]
192 LinkSectionStatic,
193 #[diag("declaration of a `no_mangle` method")]
194 #[note(
195 "the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them"
196 )]
197 NoMangleMethod,
198 #[diag("declaration of a method with `export_name`")]
199 #[note(
200 "the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them"
201 )]
202 ExportNameMethod,
203 #[diag("declaration of an `unsafe` function")]
204 DeclUnsafeFn,
205 #[diag("declaration of an `unsafe` method")]
206 DeclUnsafeMethod,
207 #[diag("implementation of an `unsafe` method")]
208 ImplUnsafeMethod,
209 #[diag("usage of `core::arch::global_asm`")]
210 #[note("using this macro is unsafe even though it does not need an `unsafe` block")]
211 GlobalAsm,
212}
213
214#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinMissingDoc<'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 {
BuiltinMissingDoc { article: __binding_0, desc: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing documentation for {$article} {$desc}")));
;
diag.arg("article", __binding_0);
diag.arg("desc", __binding_1);
diag
}
}
}
}
};Diagnostic)]
215#[diag("missing documentation for {$article} {$desc}")]
216pub(crate) struct BuiltinMissingDoc<'a> {
217 pub article: &'a str,
218 pub desc: &'a str,
219}
220
221#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinMissingCopyImpl where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinMissingCopyImpl => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type could implement `Copy`; consider adding `impl Copy`")));
;
diag
}
}
}
}
};Diagnostic)]
222#[diag("type could implement `Copy`; consider adding `impl Copy`")]
223pub(crate) struct BuiltinMissingCopyImpl;
224
225pub(crate) struct BuiltinMissingDebugImpl<'a> {
226 pub tcx: TyCtxt<'a>,
227 pub def_id: DefId,
228}
229
230impl<'a> Diagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
232 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
233 let Self { tcx, def_id } = self;
234 Diag::new(
235 dcx,
236 level,
237 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type does not implement `{$debug}`; consider adding `#[derive(Debug)]` or a manual implementation"))msg!("type does not implement `{$debug}`; consider adding `#[derive(Debug)]` or a manual implementation"),
238 ).with_arg("debug", tcx.def_path_str(def_id))
239 }
240}
241
242#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinAnonymousParams<'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 {
BuiltinAnonymousParams {
suggestion: __binding_0, ty_snip: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("anonymous parameters are deprecated and will be removed in the next edition")));
let __code_12 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_: {0}", __binding_1))
})].into_iter();
;
diag.arg("ty_snip", __binding_1);
diag.span_suggestions_with_style(__binding_0.0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try naming the parameter or explicitly ignoring it")),
__code_12, __binding_0.1,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
243#[diag("anonymous parameters are deprecated and will be removed in the next edition")]
244pub(crate) struct BuiltinAnonymousParams<'a> {
245 #[suggestion("try naming the parameter or explicitly ignoring it", code = "_: {ty_snip}")]
246 pub suggestion: (Span, Applicability),
247 pub ty_snip: &'a str,
248}
249
250#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinUnusedDocComment<'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 {
BuiltinUnusedDocComment {
kind: __binding_0, label: __binding_1, sub: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused doc comment")));
;
diag.arg("kind", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rustdoc does not generate documentation for {$kind}")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
251#[diag("unused doc comment")]
252pub(crate) struct BuiltinUnusedDocComment<'a> {
253 pub kind: &'a str,
254 #[label("rustdoc does not generate documentation for {$kind}")]
255 pub label: Span,
256 #[subdiagnostic]
257 pub sub: BuiltinUnusedDocCommentSub,
258}
259
260#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BuiltinUnusedDocCommentSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BuiltinUnusedDocCommentSub::PlainHelp => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `//` for a plain comment")),
&sub_args);
diag.help(__message);
}
BuiltinUnusedDocCommentSub::BlockHelp => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `/* */` for a plain comment")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
261pub(crate) enum BuiltinUnusedDocCommentSub {
262 #[help("use `//` for a plain comment")]
263 PlainHelp,
264 #[help("use `/* */` for a plain comment")]
265 BlockHelp,
266}
267
268#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinNoMangleGeneric where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinNoMangleGeneric { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions generic over types or consts must be mangled")));
let __code_13 =
[::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_13, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
269#[diag("functions generic over types or consts must be mangled")]
270pub(crate) struct BuiltinNoMangleGeneric {
271 #[suggestion(
274 "remove this attribute",
275 style = "short",
276 code = "",
277 applicability = "maybe-incorrect"
278 )]
279 pub suggestion: Span,
280}
281
282#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinConstNoMangle where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinConstNoMangle { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const items should never be `#[no_mangle]`")));
let __code_14 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub static "))
})].into_iter();
;
if let Some(__binding_0) = __binding_0 {
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try a static value")),
__code_14, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
283#[diag("const items should never be `#[no_mangle]`")]
284pub(crate) struct BuiltinConstNoMangle {
285 #[suggestion("try a static value", code = "pub static ", applicability = "machine-applicable")]
286 pub suggestion: Option<Span>,
287}
288
289#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinMutablesTransmutes where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinMutablesTransmutes => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell")));
;
diag
}
}
}
}
};Diagnostic)]
290#[diag(
291 "transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell"
292)]
293pub(crate) struct BuiltinMutablesTransmutes;
294
295#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinUnstableFeatures where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinUnstableFeatures => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of an unstable feature")));
;
diag
}
}
}
}
};Diagnostic)]
296#[diag("use of an unstable feature")]
297pub(crate) struct BuiltinUnstableFeatures;
298
299pub(crate) struct BuiltinUngatedAsyncFnTrackCaller<'a> {
301 pub label: Span,
302 pub session: &'a Session,
303}
304
305impl<'a> Diagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
306 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
307 let mut diag = Diag::new(dcx, level, "`#[track_caller]` on async functions is a no-op")
308 .with_span_label(self.label, "this function will not propagate the caller location");
309 rustc_session::parse::add_feature_diagnostics(
310 &mut diag,
311 self.session,
312 sym::async_fn_track_caller,
313 );
314 diag
315 }
316}
317
318#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinUnreachablePub<'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 {
BuiltinUnreachablePub {
what: __binding_0,
new_vis: __binding_1,
suggestion: __binding_2,
help: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable `pub` {$what}")));
let __code_15 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("what", __binding_0);
diag.arg("new_vis", __binding_1);
diag.span_suggestions_with_style(__binding_2.0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider restricting its visibility")),
__code_15, __binding_2.1,
rustc_errors::SuggestionStyle::ShowCode);
if __binding_3 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or consider exporting it for use by other crates")));
}
diag
}
}
}
}
};Diagnostic)]
319#[diag("unreachable `pub` {$what}")]
320pub(crate) struct BuiltinUnreachablePub<'a> {
321 pub what: &'a str,
322 pub new_vis: &'a str,
323 #[suggestion("consider restricting its visibility", code = "{new_vis}")]
324 pub suggestion: (Span, Applicability),
325 #[help("or consider exporting it for use by other crates")]
326 pub help: bool,
327}
328
329#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MacroExprFragment2024 where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MacroExprFragment2024 { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `expr` fragment specifier will accept more expressions in the 2024 edition")));
let __code_16 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("expr_2021"))
})].into_iter();
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to keep the existing behavior, use the `expr_2021` fragment specifier")),
__code_16, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
330#[diag("the `expr` fragment specifier will accept more expressions in the 2024 edition")]
331pub(crate) struct MacroExprFragment2024 {
332 #[suggestion(
333 "to keep the existing behavior, use the `expr_2021` fragment specifier",
334 code = "expr_2021",
335 applicability = "machine-applicable"
336 )]
337 pub suggestion: Span,
338}
339
340pub(crate) struct BuiltinTypeAliasBounds<'hir> {
341 pub in_where_clause: bool,
342 pub label: Span,
343 pub enable_feat_help: bool,
344 pub suggestions: Vec<(Span, String)>,
345 pub preds: &'hir [hir::WherePredicate<'hir>],
346 pub ty: Option<&'hir hir::Ty<'hir>>,
347}
348
349impl<'a> Diagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
350 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
351 let mut diag = Diag::new(dcx, level, if self.in_where_clause {
352 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses on type aliases are not enforced"))msg!("where clauses on type aliases are not enforced")
353 } else {
354 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds on generic parameters in type aliases are not enforced"))msg!("bounds on generic parameters in type aliases are not enforced")
355 })
356 .with_span_label(self.label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("will not be checked at usage sites of the type alias"))msg!("will not be checked at usage sites of the type alias"))
357 .with_note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a known limitation of the type checker that may be lifted in a future edition.\n see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"))msg!(
358 "this is a known limitation of the type checker that may be lifted in a future edition.
359 see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"
360 ));
361 if self.enable_feat_help {
362 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics"))msg!("add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics"));
363 }
364
365 let mut collector = ShorthandAssocTyCollector { qselves: Vec::new() };
368 if let Some(ty) = self.ty {
369 collector.visit_ty_unambig(ty);
370 }
371
372 let affect_object_lifetime_defaults = self
373 .preds
374 .iter()
375 .filter(|pred| pred.kind.in_where_clause() == self.in_where_clause)
376 .any(|pred| TypeAliasBounds::affects_object_lifetime_defaults(pred));
377
378 let applicability = if !collector.qselves.is_empty() || affect_object_lifetime_defaults {
381 Applicability::MaybeIncorrect
382 } else {
383 Applicability::MachineApplicable
384 };
385
386 diag.arg("count", self.suggestions.len());
387 diag.multipart_suggestion(
388 if self.in_where_clause {
389 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this where clause"))msg!("remove this where clause")
390 } else {
391 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove {$count ->\n [one] this bound\n *[other] these bounds\n }"))msg!(
392 "remove {$count ->
393 [one] this bound
394 *[other] these bounds
395 }"
396 )
397 },
398 self.suggestions,
399 applicability,
400 );
401
402 for qself in collector.qselves {
413 diag.multipart_suggestion(
414 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fully qualify this associated type"))msg!("fully qualify this associated type"),
415 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[(qself.shrink_to_lo(), "<".into()),
(qself.shrink_to_hi(), " as /* Trait */>".into())]))vec![
416 (qself.shrink_to_lo(), "<".into()),
417 (qself.shrink_to_hi(), " as /* Trait */>".into()),
418 ],
419 Applicability::HasPlaceholders,
420 );
421 }
422 diag
423 }
424}
425
426#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinTrivialBounds<'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 {
BuiltinTrivialBounds {
predicate_kind_name: __binding_0, predicate: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$predicate_kind_name} bound {$predicate} does not depend on any type or lifetime parameters")));
;
diag.arg("predicate_kind_name", __binding_0);
diag.arg("predicate", __binding_1);
diag
}
}
}
}
};Diagnostic)]
427#[diag(
428 "{$predicate_kind_name} bound {$predicate} does not depend on any type or lifetime parameters"
429)]
430pub(crate) struct BuiltinTrivialBounds<'a> {
431 pub predicate_kind_name: &'a str,
432 pub predicate: Clause<'a>,
433}
434
435#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinDoubleNegations where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinDoubleNegations { add_parens: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of a double negation")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the prefix `--` could be misinterpreted as a decrement operator which exists in other languages")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `-= 1` if you meant to decrement the value")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
436#[diag("use of a double negation")]
437#[note(
438 "the prefix `--` could be misinterpreted as a decrement operator which exists in other languages"
439)]
440#[note("use `-= 1` if you meant to decrement the value")]
441pub(crate) struct BuiltinDoubleNegations {
442 #[subdiagnostic]
443 pub add_parens: BuiltinDoubleNegationsAddParens,
444}
445
446#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BuiltinDoubleNegationsAddParens {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BuiltinDoubleNegationsAddParens {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_17 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_18 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_17));
suggestions.push((__binding_1, __code_18));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses for clarity")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
447#[multipart_suggestion("add parentheses for clarity", applicability = "maybe-incorrect")]
448pub(crate) struct BuiltinDoubleNegationsAddParens {
449 #[suggestion_part(code = "(")]
450 pub start_span: Span,
451 #[suggestion_part(code = ")")]
452 pub end_span: Span,
453}
454
455#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinEllipsisInclusiveRangePatternsLint where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinEllipsisInclusiveRangePatternsLint::Parenthesise {
suggestion: __binding_0, replace: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` range patterns are deprecated")));
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("replace", __binding_1);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..=` for an inclusive range")),
__code_19, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
BuiltinEllipsisInclusiveRangePatternsLint::NonParenthesise {
suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` range patterns are deprecated")));
let __code_20 =
[::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("use `..=` for an inclusive range")),
__code_20, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
456pub(crate) enum BuiltinEllipsisInclusiveRangePatternsLint {
457 #[diag("`...` range patterns are deprecated")]
458 Parenthesise {
459 #[suggestion(
460 "use `..=` for an inclusive range",
461 code = "{replace}",
462 applicability = "machine-applicable"
463 )]
464 suggestion: Span,
465 replace: String,
466 },
467 #[diag("`...` range patterns are deprecated")]
468 NonParenthesise {
469 #[suggestion(
470 "use `..=` for an inclusive range",
471 style = "short",
472 code = "..=",
473 applicability = "machine-applicable"
474 )]
475 suggestion: Span,
476 },
477}
478
479#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinKeywordIdents where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinKeywordIdents {
kw: __binding_0,
next: __binding_1,
suggestion: __binding_2,
prefix: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$kw}` is a keyword in the {$next} edition")));
let __code_21 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}r#{0}", __binding_0,
__binding_3))
})].into_iter();
;
diag.arg("kw", __binding_0);
diag.arg("next", __binding_1);
diag.arg("prefix", __binding_3);
diag.span_suggestions_with_style(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can use a raw identifier to stay compatible")),
__code_21, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
480#[diag("`{$kw}` is a keyword in the {$next} edition")]
481pub(crate) struct BuiltinKeywordIdents {
482 pub kw: Ident,
483 pub next: Edition,
484 #[suggestion(
485 "you can use a raw identifier to stay compatible",
486 code = "{prefix}r#{kw}",
487 applicability = "machine-applicable"
488 )]
489 pub suggestion: Span,
490 pub prefix: &'static str,
491}
492
493#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinExplicitOutlives where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinExplicitOutlives { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("outlives requirements can be inferred")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
494#[diag("outlives requirements can be inferred")]
495pub(crate) struct BuiltinExplicitOutlives {
496 #[subdiagnostic]
497 pub suggestion: BuiltinExplicitOutlivesSuggestion,
498}
499
500#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BuiltinExplicitOutlivesSuggestion
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BuiltinExplicitOutlivesSuggestion {
spans: __binding_0,
applicability: __binding_1,
count: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_22 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
for __binding_0 in __binding_0 {
suggestions.push((__binding_0, __code_22.clone()));
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("count".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("remove {$count ->\n [one] this bound\n *[other] these bounds\n }")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
__binding_1, rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
501#[multipart_suggestion(
502 "remove {$count ->
503 [one] this bound
504 *[other] these bounds
505 }"
506)]
507pub(crate) struct BuiltinExplicitOutlivesSuggestion {
508 #[suggestion_part(code = "")]
509 pub spans: Vec<Span>,
510 #[applicability]
511 pub applicability: Applicability,
512 pub count: usize,
513}
514
515#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinIncompleteFeatures where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinIncompleteFeatures {
name: __binding_0, note: __binding_1, help: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes")));
;
diag.arg("name", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
516#[diag(
517 "the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes"
518)]
519pub(crate) struct BuiltinIncompleteFeatures {
520 pub name: Symbol,
521 #[subdiagnostic]
522 pub note: Option<BuiltinFeatureIssueNote>,
523 #[subdiagnostic]
524 pub help: Option<BuiltinIncompleteFeaturesHelp>,
525}
526
527#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinInternalFeatures where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinInternalFeatures { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$name}` is internal to the compiler or standard library")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using it is strongly discouraged")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
528#[diag("the feature `{$name}` is internal to the compiler or standard library")]
529#[note("using it is strongly discouraged")]
530pub(crate) struct BuiltinInternalFeatures {
531 pub name: Symbol,
532}
533
534#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BuiltinIncompleteFeaturesHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BuiltinIncompleteFeaturesHelp { 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("consider using `min_{$name}` instead, which is more stable and complete")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
535#[help("consider using `min_{$name}` instead, which is more stable and complete")]
536pub(crate) struct BuiltinIncompleteFeaturesHelp {
537 pub name: Symbol,
538}
539
540#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for BuiltinFeatureIssueNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
BuiltinFeatureIssueNote { n: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("n".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("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
541#[note("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")]
542pub(crate) struct BuiltinFeatureIssueNote {
543 pub n: NonZero<u32>,
544}
545
546pub(crate) struct BuiltinUnpermittedTypeInit<'a> {
547 pub msg: DiagMessage,
548 pub ty: Ty<'a>,
549 pub label: Span,
550 pub sub: BuiltinUnpermittedTypeInitSub,
551 pub tcx: TyCtxt<'a>,
552}
553
554impl<'a> Diagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
555 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
556 let mut diag = Diag::new(dcx, level, self.msg)
557 .with_arg("ty", self.ty)
558 .with_span_label(self.label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this code causes undefined behavior when executed"))msg!("this code causes undefined behavior when executed"));
559 if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
560 diag.span_label(
562 self.label,
563 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done"))msg!("help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done"),
564 );
565 }
566 self.sub.add_to_diag(&mut diag);
567 diag
568 }
569}
570
571pub(crate) struct BuiltinUnpermittedTypeInitSub {
573 pub err: InitError,
574}
575
576impl Subdiagnostic for BuiltinUnpermittedTypeInitSub {
577 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
578 let mut err = self.err;
579 loop {
580 if let Some(span) = err.span {
581 diag.span_note(span, err.message);
582 } else {
583 diag.note(err.message);
584 }
585 if let Some(e) = err.nested {
586 err = *e;
587 } else {
588 break;
589 }
590 }
591 }
592}
593
594#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinClashingExtern<'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 {
BuiltinClashingExtern::SameName {
this: __binding_0,
orig: __binding_1,
previous_decl_label: __binding_2,
mismatch_label: __binding_3,
sub: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$this}` redeclared with a different signature")));
;
diag.arg("this", __binding_0);
diag.arg("orig", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$orig}` previously declared here")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this signature doesn't match the previous declaration")));
diag.subdiagnostic(__binding_4);
diag
}
BuiltinClashingExtern::DiffName {
this: __binding_0,
orig: __binding_1,
previous_decl_label: __binding_2,
mismatch_label: __binding_3,
sub: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$this}` redeclares `{$orig}` with a different signature")));
;
diag.arg("this", __binding_0);
diag.arg("orig", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$orig}` previously declared here")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this signature doesn't match the previous declaration")));
diag.subdiagnostic(__binding_4);
diag
}
}
}
}
};Diagnostic)]
595pub(crate) enum BuiltinClashingExtern<'a> {
596 #[diag("`{$this}` redeclared with a different signature")]
597 SameName {
598 this: Symbol,
599 orig: Symbol,
600 #[label("`{$orig}` previously declared here")]
601 previous_decl_label: Span,
602 #[label("this signature doesn't match the previous declaration")]
603 mismatch_label: Span,
604 #[subdiagnostic]
605 sub: BuiltinClashingExternSub<'a>,
606 },
607 #[diag("`{$this}` redeclares `{$orig}` with a different signature")]
608 DiffName {
609 this: Symbol,
610 orig: Symbol,
611 #[label("`{$orig}` previously declared here")]
612 previous_decl_label: Span,
613 #[label("this signature doesn't match the previous declaration")]
614 mismatch_label: Span,
615 #[subdiagnostic]
616 sub: BuiltinClashingExternSub<'a>,
617 },
618}
619
620pub(crate) struct BuiltinClashingExternSub<'a> {
622 pub tcx: TyCtxt<'a>,
623 pub expected: Ty<'a>,
624 pub found: Ty<'a>,
625}
626
627impl Subdiagnostic for BuiltinClashingExternSub<'_> {
628 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
629 let mut expected_str = DiagStyledString::new();
630 expected_str.push(self.expected.fn_sig(self.tcx).to_string(), false);
631 let mut found_str = DiagStyledString::new();
632 found_str.push(self.found.fn_sig(self.tcx).to_string(), true);
633 diag.note_expected_found("", expected_str, "", found_str);
634 }
635}
636
637#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinDerefNullptr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinDerefNullptr { label: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereferencing a null pointer")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this code causes undefined behavior when executed")));
diag
}
}
}
}
};Diagnostic)]
638#[diag("dereferencing a null pointer")]
639pub(crate) struct BuiltinDerefNullptr {
640 #[label("this code causes undefined behavior when executed")]
641 pub label: Span,
642}
643
644#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinSpecialModuleNameUsed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinSpecialModuleNameUsed::Lib => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found module declaration for lib.rs")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lib.rs is the root of this crate's library target")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to refer to it from other targets, use the library's name as the path")));
;
diag
}
BuiltinSpecialModuleNameUsed::Main => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found module declaration for main.rs")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a binary crate cannot be used as library")));
;
diag
}
}
}
}
};Diagnostic)]
647pub(crate) enum BuiltinSpecialModuleNameUsed {
648 #[diag("found module declaration for lib.rs")]
649 #[note("lib.rs is the root of this crate's library target")]
650 #[help("to refer to it from other targets, use the library's name as the path")]
651 Lib,
652 #[diag("found module declaration for main.rs")]
653 #[note("a binary crate cannot be used as library")]
654 Main,
655}
656
657#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
SupertraitAsDerefTarget<'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 {
SupertraitAsDerefTarget {
self_ty: __binding_0,
supertrait_principal: __binding_1,
target_principal: __binding_2,
label: __binding_3,
label2: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `Deref` implementation is covered by an implicit supertrait coercion")));
;
diag.arg("self_ty", __binding_0);
diag.arg("supertrait_principal", __binding_1);
diag.arg("target_principal", __binding_2);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$self_ty}` implements `Deref<Target = dyn {$target_principal}>` which conflicts with supertrait `{$supertrait_principal}`")));
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag
}
}
}
}
};Diagnostic)]
659#[diag("this `Deref` implementation is covered by an implicit supertrait coercion")]
660pub(crate) struct SupertraitAsDerefTarget<'a> {
661 pub self_ty: Ty<'a>,
662 pub supertrait_principal: PolyExistentialTraitRef<'a>,
663 pub target_principal: PolyExistentialTraitRef<'a>,
664 #[label(
665 "`{$self_ty}` implements `Deref<Target = dyn {$target_principal}>` which conflicts with supertrait `{$supertrait_principal}`"
666 )]
667 pub label: Span,
668 #[subdiagnostic]
669 pub label2: Option<SupertraitAsDerefTargetLabel<'a>>,
670}
671
672#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
SupertraitAsDerefTargetLabel<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SupertraitAsDerefTargetLabel {
label: __binding_0, self_ty: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("self_ty".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("target type is a supertrait of `{$self_ty}`")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
673#[label("target type is a supertrait of `{$self_ty}`")]
674pub(crate) struct SupertraitAsDerefTargetLabel<'a> {
675 #[primary_span]
676 pub label: Span,
677 pub self_ty: Ty<'a>,
678}
679
680#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
EnumIntrinsicsMemDiscriminate<'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 {
EnumIntrinsicsMemDiscriminate {
ty_param: __binding_0, note: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the return value of `mem::discriminant` is unspecified when called with a non-enum type")));
;
diag.arg("ty_param", __binding_0);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `{$ty_param}`, which is not an enum")));
diag
}
}
}
}
};Diagnostic)]
682#[diag("the return value of `mem::discriminant` is unspecified when called with a non-enum type")]
683pub(crate) struct EnumIntrinsicsMemDiscriminate<'a> {
684 pub ty_param: Ty<'a>,
685 #[note(
686 "the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `{$ty_param}`, which is not an enum"
687 )]
688 pub note: Span,
689}
690
691#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
EnumIntrinsicsMemVariant<'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 {
EnumIntrinsicsMemVariant { ty_param: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the return value of `mem::variant_count` is unspecified when called with a non-enum type")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type parameter of `variant_count` should be an enum, but it was instantiated with the type `{$ty_param}`, which is not an enum")));
;
diag.arg("ty_param", __binding_0);
diag
}
}
}
}
};Diagnostic)]
692#[diag("the return value of `mem::variant_count` is unspecified when called with a non-enum type")]
693#[note(
694 "the type parameter of `variant_count` should be an enum, but it was instantiated with the type `{$ty_param}`, which is not an enum"
695)]
696pub(crate) struct EnumIntrinsicsMemVariant<'a> {
697 pub ty_param: Ty<'a>,
698}
699
700#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for Expectation
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
Expectation { rationale: __binding_0, note: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this lint expectation is unfulfilled")));
;
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
if __binding_1 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message")));
}
diag
}
}
}
}
};Diagnostic)]
702#[diag("this lint expectation is unfulfilled")]
703pub(crate) struct Expectation {
704 #[subdiagnostic]
705 pub rationale: Option<ExpectationNote>,
706 #[note(
707 "the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message"
708 )]
709 pub note: bool,
710}
711
712#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectationNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectationNote { rationale: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("rationale".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("{$rationale}")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
713#[note("{$rationale}")]
714pub(crate) struct ExpectationNote {
715 pub rationale: Symbol,
716}
717
718#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UselessPtrNullChecksDiag<'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 {
UselessPtrNullChecksDiag::FnPtr {
orig_ty: __binding_0, label: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointers are not nullable, so checking them for null will always return false")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value")));
;
diag.arg("orig_ty", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expression has type `{$orig_ty}`")));
diag
}
UselessPtrNullChecksDiag::Ref {
orig_ty: __binding_0, label: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are not nullable, so checking them for null will always return false")));
;
diag.arg("orig_ty", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expression has type `{$orig_ty}`")));
diag
}
UselessPtrNullChecksDiag::FnRet { fn_name: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returned pointer of `{$fn_name}` call is never null, so checking it for null will always return false")));
;
diag.arg("fn_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
720pub(crate) enum UselessPtrNullChecksDiag<'a> {
721 #[diag(
722 "function pointers are not nullable, so checking them for null will always return false"
723 )]
724 #[help(
725 "wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value"
726 )]
727 FnPtr {
728 orig_ty: Ty<'a>,
729 #[label("expression has type `{$orig_ty}`")]
730 label: Span,
731 },
732 #[diag("references are not nullable, so checking them for null will always return false")]
733 Ref {
734 orig_ty: Ty<'a>,
735 #[label("expression has type `{$orig_ty}`")]
736 label: Span,
737 },
738 #[diag(
739 "returned pointer of `{$fn_name}` call is never null, so checking it for null will always return false"
740 )]
741 FnRet { fn_name: Ident },
742}
743
744#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidNullArgumentsDiag where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidNullArgumentsDiag::NullPtrInline {
null_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calling this function with a null pointer is undefined behavior, even if the result of the function is unused")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("null pointer originates from here")));
diag
}
InvalidNullArgumentsDiag::NullPtrThroughBinding {
null_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calling this function with a null pointer is undefined behavior, even if the result of the function is unused")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>")));
;
diag.span_note(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("null pointer originates from here")));
diag
}
}
}
}
};Diagnostic)]
745pub(crate) enum InvalidNullArgumentsDiag {
746 #[diag(
747 "calling this function with a null pointer is undefined behavior, even if the result of the function is unused"
748 )]
749 #[help(
750 "for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>"
751 )]
752 NullPtrInline {
753 #[label("null pointer originates from here")]
754 null_span: Span,
755 },
756 #[diag(
757 "calling this function with a null pointer is undefined behavior, even if the result of the function is unused"
758 )]
759 #[help(
760 "for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>"
761 )]
762 NullPtrThroughBinding {
763 #[note("null pointer originates from here")]
764 null_span: Span,
765 },
766}
767
768#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ForLoopsOverFalliblesDiag<'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 {
ForLoopsOverFalliblesDiag {
article: __binding_0,
ref_prefix: __binding_1,
ty: __binding_2,
sub: __binding_3,
question_mark: __binding_4,
suggestion: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement")));
;
diag.arg("article", __binding_0);
diag.arg("ref_prefix", __binding_1);
diag.arg("ty", __binding_2);
diag.subdiagnostic(__binding_3);
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag.subdiagnostic(__binding_5);
diag
}
}
}
}
};Diagnostic)]
770#[diag(
771 "for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement"
772)]
773pub(crate) struct ForLoopsOverFalliblesDiag<'a> {
774 pub article: &'static str,
775 pub ref_prefix: &'static str,
776 pub ty: &'static str,
777 #[subdiagnostic]
778 pub sub: ForLoopsOverFalliblesLoopSub<'a>,
779 #[subdiagnostic]
780 pub question_mark: Option<ForLoopsOverFalliblesQuestionMark>,
781 #[subdiagnostic]
782 pub suggestion: ForLoopsOverFalliblesSuggestion<'a>,
783}
784
785#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
ForLoopsOverFalliblesLoopSub<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ForLoopsOverFalliblesLoopSub::RemoveNext {
suggestion: __binding_0, recv_snip: __binding_1 } => {
let __code_23 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".by_ref()"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("recv_snip".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("to iterate over `{$recv_snip}` remove the call to `next`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_23, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
ForLoopsOverFalliblesLoopSub::UseWhileLet {
start_span: __binding_0,
end_span: __binding_1,
var: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_24 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("while let {0}(",
__binding_2))
});
let __code_25 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(") = "))
});
suggestions.push((__binding_0, __code_24));
suggestions.push((__binding_1, __code_25));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("var".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("to check pattern in a loop use `while let`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
786pub(crate) enum ForLoopsOverFalliblesLoopSub<'a> {
787 #[suggestion(
788 "to iterate over `{$recv_snip}` remove the call to `next`",
789 code = ".by_ref()",
790 applicability = "maybe-incorrect"
791 )]
792 RemoveNext {
793 #[primary_span]
794 suggestion: Span,
795 recv_snip: String,
796 },
797 #[multipart_suggestion(
798 "to check pattern in a loop use `while let`",
799 applicability = "maybe-incorrect"
800 )]
801 UseWhileLet {
802 #[suggestion_part(code = "while let {var}(")]
803 start_span: Span,
804 #[suggestion_part(code = ") = ")]
805 end_span: Span,
806 var: &'a str,
807 },
808}
809
810#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ForLoopsOverFalliblesQuestionMark
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ForLoopsOverFalliblesQuestionMark { suggestion: __binding_0
} => {
let __code_26 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("?"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider unwrapping the `Result` with `?` to iterate over its contents")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_26, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
811#[suggestion(
812 "consider unwrapping the `Result` with `?` to iterate over its contents",
813 code = "?",
814 applicability = "maybe-incorrect"
815)]
816pub(crate) struct ForLoopsOverFalliblesQuestionMark {
817 #[primary_span]
818 pub suggestion: Span,
819}
820
821#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
ForLoopsOverFalliblesSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ForLoopsOverFalliblesSuggestion {
var: __binding_0,
start_span: __binding_1,
end_span: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_27 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if let {0}(",
__binding_0))
});
let __code_28 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(") = "))
});
suggestions.push((__binding_1, __code_27));
suggestions.push((__binding_2, __code_28));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("var".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 using `if let` to clear intent")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
822#[multipart_suggestion(
823 "consider using `if let` to clear intent",
824 applicability = "maybe-incorrect"
825)]
826pub(crate) struct ForLoopsOverFalliblesSuggestion<'a> {
827 pub var: &'a str,
828 #[suggestion_part(code = "if let {var}(")]
829 pub start_span: Span,
830 #[suggestion_part(code = ") = ")]
831 pub end_span: Span,
832}
833
834#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UseLetUnderscoreIgnoreSuggestion
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UseLetUnderscoreIgnoreSuggestion::Note => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the expression or result")),
&sub_args);
diag.note(__message);
}
UseLetUnderscoreIgnoreSuggestion::Suggestion {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_29 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let _ = "))
});
let __code_30 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
suggestions.push((__binding_0, __code_29));
suggestions.push((__binding_1, __code_30));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the expression or result")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
835pub(crate) enum UseLetUnderscoreIgnoreSuggestion {
836 #[note("use `let _ = ...` to ignore the expression or result")]
837 Note,
838 #[multipart_suggestion(
839 "use `let _ = ...` to ignore the expression or result",
840 style = "verbose",
841 applicability = "maybe-incorrect"
842 )]
843 Suggestion {
844 #[suggestion_part(code = "let _ = ")]
845 start_span: Span,
846 #[suggestion_part(code = "")]
847 end_span: Span,
848 },
849}
850
851#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DropRefDiag<'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 {
DropRefDiag {
arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::drop` with a reference instead of an owned value does nothing")));
;
diag.arg("arg_ty", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
853#[diag("calls to `std::mem::drop` with a reference instead of an owned value does nothing")]
854pub(crate) struct DropRefDiag<'a> {
855 pub arg_ty: Ty<'a>,
856 #[label("argument has type `{$arg_ty}`")]
857 pub label: Span,
858 #[subdiagnostic]
859 pub sugg: UseLetUnderscoreIgnoreSuggestion,
860}
861
862#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DropCopyDiag<'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 {
DropCopyDiag {
arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::drop` with a value that implements `Copy` does nothing")));
;
diag.arg("arg_ty", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
863#[diag("calls to `std::mem::drop` with a value that implements `Copy` does nothing")]
864pub(crate) struct DropCopyDiag<'a> {
865 pub arg_ty: Ty<'a>,
866 #[label("argument has type `{$arg_ty}`")]
867 pub label: Span,
868 #[subdiagnostic]
869 pub sugg: UseLetUnderscoreIgnoreSuggestion,
870}
871
872#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ForgetRefDiag<'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 {
ForgetRefDiag {
arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::forget` with a reference instead of an owned value does nothing")));
;
diag.arg("arg_ty", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
873#[diag("calls to `std::mem::forget` with a reference instead of an owned value does nothing")]
874pub(crate) struct ForgetRefDiag<'a> {
875 pub arg_ty: Ty<'a>,
876 #[label("argument has type `{$arg_ty}`")]
877 pub label: Span,
878 #[subdiagnostic]
879 pub sugg: UseLetUnderscoreIgnoreSuggestion,
880}
881
882#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ForgetCopyDiag<'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 {
ForgetCopyDiag {
arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::forget` with a value that implements `Copy` does nothing")));
;
diag.arg("arg_ty", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
883#[diag("calls to `std::mem::forget` with a value that implements `Copy` does nothing")]
884pub(crate) struct ForgetCopyDiag<'a> {
885 pub arg_ty: Ty<'a>,
886 #[label("argument has type `{$arg_ty}`")]
887 pub label: Span,
888 #[subdiagnostic]
889 pub sugg: UseLetUnderscoreIgnoreSuggestion,
890}
891
892#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UndroppedManuallyDropsDiag<'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 {
UndroppedManuallyDropsDiag {
arg_ty: __binding_0,
label: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing")));
;
diag.arg("arg_ty", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
893#[diag(
894 "calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing"
895)]
896pub(crate) struct UndroppedManuallyDropsDiag<'a> {
897 pub arg_ty: Ty<'a>,
898 #[label("argument has type `{$arg_ty}`")]
899 pub label: Span,
900 #[subdiagnostic]
901 pub suggestion: UndroppedManuallyDropsSuggestion,
902}
903
904#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UndroppedManuallyDropsSuggestion
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UndroppedManuallyDropsSuggestion {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_31 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("std::mem::ManuallyDrop::into_inner("))
});
let __code_32 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_31));
suggestions.push((__binding_1, __code_32));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `std::mem::ManuallyDrop::into_inner` to get the inner value")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
905#[multipart_suggestion(
906 "use `std::mem::ManuallyDrop::into_inner` to get the inner value",
907 applicability = "machine-applicable"
908)]
909pub(crate) struct UndroppedManuallyDropsSuggestion {
910 #[suggestion_part(code = "std::mem::ManuallyDrop::into_inner(")]
911 pub start_span: Span,
912 #[suggestion_part(code = ")")]
913 pub end_span: Span,
914}
915
916#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidFromUtf8Diag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidFromUtf8Diag::Unchecked {
method: __binding_0,
valid_up_to: __binding_1,
label: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `{$method}` with an invalid literal are undefined behavior")));
;
diag.arg("method", __binding_0);
diag.arg("valid_up_to", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal was valid UTF-8 up to the {$valid_up_to} bytes")));
diag
}
InvalidFromUtf8Diag::Checked {
method: __binding_0,
valid_up_to: __binding_1,
label: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `{$method}` with an invalid literal always return an error")));
;
diag.arg("method", __binding_0);
diag.arg("valid_up_to", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal was valid UTF-8 up to the {$valid_up_to} bytes")));
diag
}
}
}
}
};Diagnostic)]
918pub(crate) enum InvalidFromUtf8Diag {
919 #[diag("calls to `{$method}` with an invalid literal are undefined behavior")]
920 Unchecked {
921 method: String,
922 valid_up_to: usize,
923 #[label("the literal was valid UTF-8 up to the {$valid_up_to} bytes")]
924 label: Span,
925 },
926 #[diag("calls to `{$method}` with an invalid literal always return an error")]
927 Checked {
928 method: String,
929 valid_up_to: usize,
930 #[label("the literal was valid UTF-8 up to the {$valid_up_to} bytes")]
931 label: Span,
932 },
933}
934
935#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
ConstItemInteriorMutationsDiag<'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 {
ConstItemInteriorMutationsDiag {
method_name: __binding_0,
const_name: __binding_1,
const_ty: __binding_2,
receiver_span: __binding_3,
sugg_static: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of an interior mutable `const` item with call to `{$method_name}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("each usage of a `const` item creates a new temporary")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only the temporaries and never the original `const {$const_name}` will be modified")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>")));
;
diag.arg("method_name", __binding_0);
diag.arg("const_name", __binding_1);
diag.arg("const_ty", __binding_2);
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$const_name}` is a interior mutable `const` item of type `{$const_ty}`")));
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag
}
}
}
}
};Diagnostic)]
937#[diag("mutation of an interior mutable `const` item with call to `{$method_name}`")]
938#[note("each usage of a `const` item creates a new temporary")]
939#[note("only the temporaries and never the original `const {$const_name}` will be modified")]
940#[help(
941 "for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>"
942)]
943pub(crate) struct ConstItemInteriorMutationsDiag<'tcx> {
944 pub method_name: Ident,
945 pub const_name: Ident,
946 pub const_ty: Ty<'tcx>,
947 #[label("`{$const_name}` is a interior mutable `const` item of type `{$const_ty}`")]
948 pub receiver_span: Span,
949 #[subdiagnostic]
950 pub sugg_static: Option<ConstItemInteriorMutationsSuggestionStatic>,
951}
952
953#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ConstItemInteriorMutationsSuggestionStatic {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConstItemInteriorMutationsSuggestionStatic::Spanful {
const_: __binding_0,
before: __binding_1,
const_name: __binding_2 } => {
let __code_33 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}static ",
__binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("before".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("const_name".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("for a shared instance of `{$const_name}`, consider making it a `static` item instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_33, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
ConstItemInteriorMutationsSuggestionStatic::Spanless {
const_name: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("const_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("for a shared instance of `{$const_name}`, consider making it a `static` item instead")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
954pub(crate) enum ConstItemInteriorMutationsSuggestionStatic {
955 #[suggestion(
956 "for a shared instance of `{$const_name}`, consider making it a `static` item instead",
957 code = "{before}static ",
958 style = "verbose",
959 applicability = "maybe-incorrect"
960 )]
961 Spanful {
962 #[primary_span]
963 const_: Span,
964 before: &'static str,
965 const_name: Ident,
966 },
967 #[help("for a shared instance of `{$const_name}`, consider making it a `static` item instead")]
968 Spanless { const_name: Ident },
969}
970
971#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidReferenceCastingDiag<'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 {
InvalidReferenceCastingDiag::BorrowAsMut {
orig_cast: __binding_0,
ty_has_interior_mutability: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>")));
;
if let Some(__binding_0) = __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting happened here")));
}
if __binding_1 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`")));
}
diag
}
InvalidReferenceCastingDiag::AssignToRef {
orig_cast: __binding_0,
ty_has_interior_mutability: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("assigning to `&T` is undefined behavior, consider using an `UnsafeCell`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>")));
;
if let Some(__binding_0) = __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting happened here")));
}
if __binding_1 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`")));
}
diag
}
InvalidReferenceCastingDiag::BiggerLayout {
orig_cast: __binding_0,
alloc: __binding_1,
from_ty: __binding_2,
from_size: __binding_3,
to_ty: __binding_4,
to_size: __binding_5 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting from `{$from_ty}` ({$from_size} bytes) to `{$to_ty}` ({$to_size} bytes)")));
;
diag.arg("from_ty", __binding_2);
diag.arg("from_size", __binding_3);
diag.arg("to_ty", __binding_4);
diag.arg("to_size", __binding_5);
if let Some(__binding_0) = __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting happened here")));
}
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("backing allocation comes from here")));
diag
}
}
}
}
};Diagnostic)]
973pub(crate) enum InvalidReferenceCastingDiag<'tcx> {
974 #[diag(
975 "casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`"
976 )]
977 #[note(
978 "for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>"
979 )]
980 BorrowAsMut {
981 #[label("casting happened here")]
982 orig_cast: Option<Span>,
983 #[note(
984 "even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`"
985 )]
986 ty_has_interior_mutability: bool,
987 },
988 #[diag("assigning to `&T` is undefined behavior, consider using an `UnsafeCell`")]
989 #[note(
990 "for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>"
991 )]
992 AssignToRef {
993 #[label("casting happened here")]
994 orig_cast: Option<Span>,
995 #[note(
996 "even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`"
997 )]
998 ty_has_interior_mutability: bool,
999 },
1000 #[diag(
1001 "casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused"
1002 )]
1003 #[note("casting from `{$from_ty}` ({$from_size} bytes) to `{$to_ty}` ({$to_size} bytes)")]
1004 BiggerLayout {
1005 #[label("casting happened here")]
1006 orig_cast: Option<Span>,
1007 #[label("backing allocation comes from here")]
1008 alloc: Span,
1009 from_ty: Ty<'tcx>,
1010 from_size: u64,
1011 to_ty: Ty<'tcx>,
1012 to_size: u64,
1013 },
1014}
1015
1016#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MappingToUnit
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MappingToUnit {
function_label: __binding_0,
argument_label: __binding_1,
map_label: __binding_2,
suggestion: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Iterator::map` call that discard the iterator's values")));
let __code_34 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("for_each"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this function returns `()`, which is likely not what you wanted")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("called `Iterator::map` with callable that returns `()`")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items")));
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to use `Iterator::for_each`")),
__code_34, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag
}
}
}
}
};Diagnostic)]
1018#[diag("`Iterator::map` call that discard the iterator's values")]
1019#[note(
1020 "`Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated"
1021)]
1022pub(crate) struct MappingToUnit {
1023 #[label("this function returns `()`, which is likely not what you wanted")]
1024 pub function_label: Span,
1025 #[label("called `Iterator::map` with callable that returns `()`")]
1026 pub argument_label: Span,
1027 #[label(
1028 "after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items"
1029 )]
1030 pub map_label: Span,
1031 #[suggestion(
1032 "you might have meant to use `Iterator::for_each`",
1033 style = "verbose",
1034 code = "for_each",
1035 applicability = "maybe-incorrect"
1036 )]
1037 pub suggestion: Span,
1038}
1039
1040#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DefaultHashTypesDiag<'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 {
DefaultHashTypesDiag {
preferred: __binding_0, used: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefer `{$preferred}` over `{$used}`, it has better performance")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `use rustc_data_structures::fx::{$preferred}` may be necessary")));
;
diag.arg("preferred", __binding_0);
diag.arg("used", __binding_1);
diag
}
}
}
}
};Diagnostic)]
1042#[diag("prefer `{$preferred}` over `{$used}`, it has better performance")]
1043#[note("a `use rustc_data_structures::fx::{$preferred}` may be necessary")]
1044pub(crate) struct DefaultHashTypesDiag<'a> {
1045 pub preferred: &'a str,
1046 pub used: Symbol,
1047}
1048
1049#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
QueryInstability where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
QueryInstability { query: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `{$query}` can result in unstable query results")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you believe this case to be fine, allow this lint and add a comment explaining your rationale")));
;
diag.arg("query", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1050#[diag("using `{$query}` can result in unstable query results")]
1051#[note(
1052 "if you believe this case to be fine, allow this lint and add a comment explaining your rationale"
1053)]
1054pub(crate) struct QueryInstability {
1055 pub query: Symbol,
1056}
1057
1058#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for QueryUntracked
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
QueryUntracked { method: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$method}` accesses information that is not tracked by the query system")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you believe this case to be fine, allow this lint and add a comment explaining your rationale")));
;
diag.arg("method", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1059#[diag("`{$method}` accesses information that is not tracked by the query system")]
1060#[note(
1061 "if you believe this case to be fine, allow this lint and add a comment explaining your rationale"
1062)]
1063pub(crate) struct QueryUntracked {
1064 pub method: Symbol,
1065}
1066
1067#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SpanUseEqCtxtDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SpanUseEqCtxtDiag => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`")));
;
diag
}
}
}
}
};Diagnostic)]
1068#[diag("use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`")]
1069pub(crate) struct SpanUseEqCtxtDiag;
1070
1071#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SymbolInternStringLiteralDiag where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SymbolInternStringLiteralDiag => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `Symbol::intern` on a string literal")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding the symbol to `compiler/rustc_span/src/symbol.rs`")));
;
diag
}
}
}
}
};Diagnostic)]
1072#[diag("using `Symbol::intern` on a string literal")]
1073#[help("consider adding the symbol to `compiler/rustc_span/src/symbol.rs`")]
1074pub(crate) struct SymbolInternStringLiteralDiag;
1075
1076#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TykindKind
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TykindKind { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of `ty::TyKind::<kind>`")));
let __code_35 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ty"))
})].into_iter();
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `ty::<kind>` directly")),
__code_35, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1077#[diag("usage of `ty::TyKind::<kind>`")]
1078pub(crate) struct TykindKind {
1079 #[suggestion(
1080 "try using `ty::<kind>` directly",
1081 code = "ty",
1082 applicability = "maybe-incorrect"
1083 )]
1084 pub suggestion: Span,
1085}
1086
1087#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TykindDiag
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TykindDiag => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of `ty::TyKind`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `Ty` instead")));
;
diag
}
}
}
}
};Diagnostic)]
1088#[diag("usage of `ty::TyKind`")]
1089#[help("try using `Ty` instead")]
1090pub(crate) struct TykindDiag;
1091
1092#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TyQualified
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TyQualified { ty: __binding_0, suggestion: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of qualified `ty::{$ty}`")));
let __code_36 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_0))
})].into_iter();
;
diag.arg("ty", __binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try importing it and using it unqualified")),
__code_36, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1093#[diag("usage of qualified `ty::{$ty}`")]
1094pub(crate) struct TyQualified {
1095 pub ty: String,
1096 #[suggestion(
1097 "try importing it and using it unqualified",
1098 code = "{ty}",
1099 applicability = "maybe-incorrect"
1100 )]
1101 pub suggestion: Span,
1102}
1103
1104#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TypeIrInherentUsage where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TypeIrInherentUsage => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("do not use `rustc_type_ir::inherent` unless you're inside of the trait solver")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the method or struct you're looking for is likely defined somewhere else downstream in the compiler")));
;
diag
}
}
}
}
};Diagnostic)]
1105#[diag("do not use `rustc_type_ir::inherent` unless you're inside of the trait solver")]
1106#[note(
1107 "the method or struct you're looking for is likely defined somewhere else downstream in the compiler"
1108)]
1109pub(crate) struct TypeIrInherentUsage;
1110
1111#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TypeIrTraitUsage where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TypeIrTraitUsage => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the method or struct you're looking for is likely defined somewhere else downstream in the compiler")));
;
diag
}
}
}
}
};Diagnostic)]
1112#[diag(
1113 "do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver"
1114)]
1115#[note(
1116 "the method or struct you're looking for is likely defined somewhere else downstream in the compiler"
1117)]
1118pub(crate) struct TypeIrTraitUsage;
1119
1120#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TypeIrDirectUse where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TypeIrDirectUse => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("do not use `rustc_type_ir` unless you are implementing type system internals")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `rustc_middle::ty` instead")));
;
diag
}
}
}
}
};Diagnostic)]
1121#[diag("do not use `rustc_type_ir` unless you are implementing type system internals")]
1122#[note("use `rustc_middle::ty` instead")]
1123pub(crate) struct TypeIrDirectUse;
1124
1125#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NonGlobImportTypeIrInherent where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonGlobImportTypeIrInherent {
suggestion: __binding_0, snippet: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-glob import of `rustc_type_ir::inherent`")));
let __code_37 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
;
diag.arg("snippet", __binding_1);
if let Some(__binding_0) = __binding_0 {
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using a glob import instead")),
__code_37, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
1126#[diag("non-glob import of `rustc_type_ir::inherent`")]
1127pub(crate) struct NonGlobImportTypeIrInherent {
1128 #[suggestion(
1129 "try using a glob import instead",
1130 code = "{snippet}",
1131 applicability = "maybe-incorrect"
1132 )]
1133 pub suggestion: Option<Span>,
1134 pub snippet: &'static str,
1135}
1136
1137#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LintPassByHand
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LintPassByHand => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `LintPass` by hand")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `declare_lint_pass!` or `impl_lint_pass!` instead")));
;
diag
}
}
}
}
};Diagnostic)]
1138#[diag("implementing `LintPass` by hand")]
1139#[help("try using `declare_lint_pass!` or `impl_lint_pass!` instead")]
1140pub(crate) struct LintPassByHand;
1141
1142#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
BadOptAccessDiag<'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 {
BadOptAccessDiag { msg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$msg}")));
;
diag.arg("msg", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1143#[diag("{$msg}")]
1144pub(crate) struct BadOptAccessDiag<'a> {
1145 pub msg: &'a str,
1146}
1147
1148#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ImplicitSysrootCrateImportDiag<'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 {
ImplicitSysrootCrateImportDiag { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dangerous use of `extern crate {$name}` which is not guaranteed to exist exactly once in the sysroot")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using a cargo dependency or using a re-export of the dependency provided by a rustc_* crate")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1149#[diag(
1150 "dangerous use of `extern crate {$name}` which is not guaranteed to exist exactly once in the sysroot"
1151)]
1152#[help(
1153 "try using a cargo dependency or using a re-export of the dependency provided by a rustc_* crate"
1154)]
1155pub(crate) struct ImplicitSysrootCrateImportDiag<'a> {
1156 pub name: &'a str,
1157}
1158
1159#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttributeKindInFindAttr where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttributeKindInFindAttr => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of `AttributeKind` in `find_attr!(...)` invocation")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`find_attr!(...)` already imports `AttributeKind::*`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove `AttributeKind`")));
;
diag
}
}
}
}
};Diagnostic)]
1160#[diag("use of `AttributeKind` in `find_attr!(...)` invocation")]
1161#[note("`find_attr!(...)` already imports `AttributeKind::*`")]
1162#[help("remove `AttributeKind`")]
1163pub(crate) struct AttributeKindInFindAttr;
1164
1165#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RustcMustMatchExhaustivelyNotExhaustive where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RustcMustMatchExhaustivelyNotExhaustive {
attr_span: __binding_0,
pat_span: __binding_1,
message: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("match is not exhaustive")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly list all variants of the enum in a `match`")));
;
diag.arg("message", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required because of this attribute")));
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$message}")));
diag
}
}
}
}
};Diagnostic)]
1166#[diag("match is not exhaustive")]
1167#[help("explicitly list all variants of the enum in a `match`")]
1168pub(crate) struct RustcMustMatchExhaustivelyNotExhaustive {
1169 #[label("required because of this attribute")]
1170 pub attr_span: Span,
1171
1172 #[note("{$message}")]
1173 pub pat_span: Span,
1174 pub message: &'static str,
1175}
1176
1177#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NonBindingLet
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonBindingLet::SyncLock { pat: __binding_0, sub: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-binding let on a synchronization lock")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this lock is not assigned to a binding and is immediately dropped")));
diag.subdiagnostic(__binding_1);
diag
}
NonBindingLet::DropType { sub: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-binding let on a type that has a destructor")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1179pub(crate) enum NonBindingLet {
1180 #[diag("non-binding let on a synchronization lock")]
1181 SyncLock {
1182 #[label("this lock is not assigned to a binding and is immediately dropped")]
1183 pat: Span,
1184 #[subdiagnostic]
1185 sub: NonBindingLetSub,
1186 },
1187 #[diag("non-binding let on a type that has a destructor")]
1188 DropType {
1189 #[subdiagnostic]
1190 sub: NonBindingLetSub,
1191 },
1192}
1193
1194pub(crate) struct NonBindingLetSub {
1195 pub suggestion: Span,
1196 pub drop_fn_start_end: Option<(Span, Span)>,
1197 pub is_assign_desugar: bool,
1198}
1199
1200impl Subdiagnostic for NonBindingLetSub {
1201 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1202 let can_suggest_binding = self.drop_fn_start_end.is_some() || !self.is_assign_desugar;
1203
1204 if can_suggest_binding {
1205 let prefix = if self.is_assign_desugar { "let " } else { "" };
1206 diag.span_suggestion_verbose(
1207 self.suggestion,
1208 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider binding to an unused variable to avoid immediately dropping the value"))msg!(
1209 "consider binding to an unused variable to avoid immediately dropping the value"
1210 ),
1211 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}_unused", prefix))
})format!("{prefix}_unused"),
1212 Applicability::MachineApplicable,
1213 );
1214 } else {
1215 diag.span_help(
1216 self.suggestion,
1217 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider binding to an unused variable to avoid immediately dropping the value"))msg!(
1218 "consider binding to an unused variable to avoid immediately dropping the value"
1219 ),
1220 );
1221 }
1222 if let Some(drop_fn_start_end) = self.drop_fn_start_end {
1223 diag.multipart_suggestion(
1224 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider immediately dropping the value"))msg!("consider immediately dropping the value"),
1225 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[(drop_fn_start_end.0, "drop(".to_string()),
(drop_fn_start_end.1, ")".to_string())]))vec![
1226 (drop_fn_start_end.0, "drop(".to_string()),
1227 (drop_fn_start_end.1, ")".to_string()),
1228 ],
1229 Applicability::MachineApplicable,
1230 );
1231 } else {
1232 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider immediately dropping the value using `drop(..)` after the `let` statement"))msg!(
1233 "consider immediately dropping the value using `drop(..)` after the `let` statement"
1234 ));
1235 }
1236 }
1237}
1238
1239#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
OverruledAttributeLint<'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 {
OverruledAttributeLint {
overruled: __binding_0,
lint_level: __binding_1,
lint_source: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$lint_level}({$lint_source}) incompatible with previous forbid")));
;
diag.arg("lint_level", __binding_1);
diag.arg("lint_source", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overruled by previous forbid")));
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
1241#[diag("{$lint_level}({$lint_source}) incompatible with previous forbid")]
1242pub(crate) struct OverruledAttributeLint<'a> {
1243 #[label("overruled by previous forbid")]
1244 pub overruled: Span,
1245 pub lint_level: &'a str,
1246 pub lint_source: Symbol,
1247 #[subdiagnostic]
1248 pub sub: OverruledAttributeSub,
1249}
1250
1251#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DeprecatedLintName<'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 {
DeprecatedLintName {
name: __binding_0,
suggestion: __binding_1,
replace: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint name `{$name}` is deprecated and may not have an effect in the future")));
let __code_38 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
;
diag.arg("name", __binding_0);
diag.arg("replace", __binding_2);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("change it to")),
__code_38, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1252#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
1253pub(crate) struct DeprecatedLintName<'a> {
1254 pub name: String,
1255 #[suggestion("change it to", code = "{replace}", applicability = "machine-applicable")]
1256 pub suggestion: Span,
1257 pub replace: &'a str,
1258}
1259
1260#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
DeprecatedLintNameFromCommandLine<'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 {
DeprecatedLintNameFromCommandLine {
name: __binding_0,
replace: __binding_1,
requested_level: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint name `{$name}` is deprecated and may not have an effect in the future")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("change it to {$replace}")));
;
diag.arg("name", __binding_0);
diag.arg("replace", __binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1261#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
1262#[help("change it to {$replace}")]
1263pub(crate) struct DeprecatedLintNameFromCommandLine<'a> {
1264 pub name: String,
1265 pub replace: &'a str,
1266 #[subdiagnostic]
1267 pub requested_level: RequestedLevel<'a>,
1268}
1269
1270#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
RenamedLint<'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 {
RenamedLint {
name: __binding_0,
replace: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been renamed to `{$replace}`")));
;
diag.arg("name", __binding_0);
diag.arg("replace", __binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1271#[diag("lint `{$name}` has been renamed to `{$replace}`")]
1272pub(crate) struct RenamedLint<'a> {
1273 pub name: &'a str,
1274 pub replace: &'a str,
1275 #[subdiagnostic]
1276 pub suggestion: RenamedLintSuggestion<'a>,
1277}
1278
1279#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for RenamedLintSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RenamedLintSuggestion::WithSpan {
suggestion: __binding_0, replace: __binding_1 } => {
let __code_39 =
[::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("replace".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("use the new name")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_39, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
RenamedLintSuggestion::WithoutSpan { replace: __binding_0 }
=> {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("replace".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("use the new name `{$replace}`")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
1280pub(crate) enum RenamedLintSuggestion<'a> {
1281 #[suggestion("use the new name", code = "{replace}", applicability = "machine-applicable")]
1282 WithSpan {
1283 #[primary_span]
1284 suggestion: Span,
1285 replace: &'a str,
1286 },
1287 #[help("use the new name `{$replace}`")]
1288 WithoutSpan { replace: &'a str },
1289}
1290
1291#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
RenamedLintFromCommandLine<'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 {
RenamedLintFromCommandLine {
name: __binding_0,
replace: __binding_1,
suggestion: __binding_2,
requested_level: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been renamed to `{$replace}`")));
;
diag.arg("name", __binding_0);
diag.arg("replace", __binding_1);
diag.subdiagnostic(__binding_2);
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
1292#[diag("lint `{$name}` has been renamed to `{$replace}`")]
1293pub(crate) struct RenamedLintFromCommandLine<'a> {
1294 pub name: &'a str,
1295 pub replace: &'a str,
1296 #[subdiagnostic]
1297 pub suggestion: RenamedLintSuggestion<'a>,
1298 #[subdiagnostic]
1299 pub requested_level: RequestedLevel<'a>,
1300}
1301
1302#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
RemovedLint<'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 {
RemovedLint { name: __binding_0, reason: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been removed: {$reason}")));
;
diag.arg("name", __binding_0);
diag.arg("reason", __binding_1);
diag
}
}
}
}
};Diagnostic)]
1303#[diag("lint `{$name}` has been removed: {$reason}")]
1304pub(crate) struct RemovedLint<'a> {
1305 pub name: &'a str,
1306 pub reason: &'a str,
1307}
1308
1309#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
RemovedLintFromCommandLine<'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 {
RemovedLintFromCommandLine {
name: __binding_0,
reason: __binding_1,
requested_level: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been removed: {$reason}")));
;
diag.arg("name", __binding_0);
diag.arg("reason", __binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1310#[diag("lint `{$name}` has been removed: {$reason}")]
1311pub(crate) struct RemovedLintFromCommandLine<'a> {
1312 pub name: &'a str,
1313 pub reason: &'a str,
1314 #[subdiagnostic]
1315 pub requested_level: RequestedLevel<'a>,
1316}
1317
1318#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnknownLint
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownLint { name: __binding_0, suggestion: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown lint: `{$name}`")));
;
diag.arg("name", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1319#[diag("unknown lint: `{$name}`")]
1320pub(crate) struct UnknownLint {
1321 pub name: String,
1322 #[subdiagnostic]
1323 pub suggestion: Option<UnknownLintSuggestion>,
1324}
1325
1326#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnknownLintSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownLintSuggestion::WithSpan {
suggestion: __binding_0,
replace: __binding_1,
from_rustc: __binding_2 } => {
let __code_40 =
[::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("replace".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("from_rustc".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("{$from_rustc ->\n [true] a lint with a similar name exists in `rustc` lints\n *[false] did you mean\n }")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_40, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
UnknownLintSuggestion::WithoutSpan {
replace: __binding_0, from_rustc: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("replace".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("from_rustc".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("{$from_rustc ->\n [true] a lint with a similar name exists in `rustc` lints: `{$replace}`\n *[false] did you mean: `{$replace}`\n }")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
1327pub(crate) enum UnknownLintSuggestion {
1328 #[suggestion(
1329 "{$from_rustc ->
1330 [true] a lint with a similar name exists in `rustc` lints
1331 *[false] did you mean
1332 }",
1333 code = "{replace}",
1334 applicability = "maybe-incorrect"
1335 )]
1336 WithSpan {
1337 #[primary_span]
1338 suggestion: Span,
1339 replace: Symbol,
1340 from_rustc: bool,
1341 },
1342 #[help(
1343 "{$from_rustc ->
1344 [true] a lint with a similar name exists in `rustc` lints: `{$replace}`
1345 *[false] did you mean: `{$replace}`
1346 }"
1347 )]
1348 WithoutSpan { replace: Symbol, from_rustc: bool },
1349}
1350
1351#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownLintFromCommandLine<'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 {
UnknownLintFromCommandLine {
name: __binding_0,
suggestion: __binding_1,
requested_level: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown lint: `{$name}`")));
diag.code(E0602);
;
diag.arg("name", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1352#[diag("unknown lint: `{$name}`", code = E0602)]
1353pub(crate) struct UnknownLintFromCommandLine<'a> {
1354 pub name: String,
1355 #[subdiagnostic]
1356 pub suggestion: Option<UnknownLintSuggestion>,
1357 #[subdiagnostic]
1358 pub requested_level: RequestedLevel<'a>,
1359}
1360
1361#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
IgnoredUnlessCrateSpecified<'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 {
IgnoredUnlessCrateSpecified {
level: __binding_0, name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$level}({$name}) is ignored unless specified at crate level")));
;
diag.arg("level", __binding_0);
diag.arg("name", __binding_1);
diag
}
}
}
}
};Diagnostic)]
1362#[diag("{$level}({$name}) is ignored unless specified at crate level")]
1363pub(crate) struct IgnoredUnlessCrateSpecified<'a> {
1364 pub level: &'a str,
1365 pub name: Symbol,
1366}
1367
1368#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
DanglingPointersFromTemporaries<'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 {
DanglingPointersFromTemporaries {
callee: __binding_0,
ty: __binding_1,
ptr_span: __binding_2,
temporary_span: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this creates a dangling pointer because temporary `{$ty}` is dropped at end of statement")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a dangling pointer is safe, but dereferencing one is undefined behavior")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returning a pointer to a local variable will always result in a dangling pointer")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")));
;
diag.arg("callee", __binding_0);
diag.arg("ty", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pointer created here")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `{$ty}` is dropped at end of statement")));
diag
}
}
}
}
};Diagnostic)]
1370#[diag("this creates a dangling pointer because temporary `{$ty}` is dropped at end of statement")]
1371#[help("bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`")]
1372#[note("a dangling pointer is safe, but dereferencing one is undefined behavior")]
1373#[note("returning a pointer to a local variable will always result in a dangling pointer")]
1374#[note("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")]
1375pub(crate) struct DanglingPointersFromTemporaries<'tcx> {
1377 pub callee: Ident,
1378 pub ty: Ty<'tcx>,
1379 #[label("pointer created here")]
1380 pub ptr_span: Span,
1381 #[label("this `{$ty}` is dropped at end of statement")]
1382 pub temporary_span: Span,
1383}
1384
1385#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
DanglingPointersFromLocals<'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 {
DanglingPointersFromLocals {
ret_ty: __binding_0,
ret_ty_span: __binding_1,
fn_kind: __binding_2,
local_var: __binding_3,
local_var_name: __binding_4,
local_var_ty: __binding_5,
created_at: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a dangling pointer is safe, but dereferencing one is undefined behavior")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")));
;
diag.arg("ret_ty", __binding_0);
diag.arg("fn_kind", __binding_2);
diag.arg("local_var_name", __binding_4);
diag.arg("local_var_ty", __binding_5);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type is `{$ret_ty}`")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}")));
if let Some(__binding_6) = __binding_6 {
diag.span_label(__binding_6,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dangling pointer created here")));
}
diag
}
}
}
}
};Diagnostic)]
1386#[diag("{$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`")]
1387#[note("a dangling pointer is safe, but dereferencing one is undefined behavior")]
1388#[note("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")]
1389pub(crate) struct DanglingPointersFromLocals<'tcx> {
1390 pub ret_ty: Ty<'tcx>,
1391 #[label("return type is `{$ret_ty}`")]
1392 pub ret_ty_span: Span,
1393 pub fn_kind: &'static str,
1394 #[label("local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}")]
1395 pub local_var: Span,
1396 pub local_var_name: Ident,
1397 pub local_var_ty: Ty<'tcx>,
1398 #[label("dangling pointer created here")]
1399 pub created_at: Option<Span>,
1400}
1401
1402#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MultipleSupertraitUpcastable where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MultipleSupertraitUpcastable { ident: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is dyn-compatible and has multiple supertraits")));
;
diag.arg("ident", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1404#[diag("`{$ident}` is dyn-compatible and has multiple supertraits")]
1405pub(crate) struct MultipleSupertraitUpcastable {
1406 pub ident: Ident,
1407}
1408
1409#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IdentifierNonAsciiChar where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IdentifierNonAsciiChar => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("identifier contains non-ASCII characters")));
;
diag
}
}
}
}
};Diagnostic)]
1411#[diag("identifier contains non-ASCII characters")]
1412pub(crate) struct IdentifierNonAsciiChar;
1413
1414#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IdentifierUncommonCodepoints where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IdentifierUncommonCodepoints {
codepoints: __binding_0,
codepoints_len: __binding_1,
identifier_type: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("identifier contains {$codepoints_len ->\n [one] { $identifier_type ->\n [Exclusion] a character from an archaic script\n [Technical] a character that is for non-linguistic, specialized usage\n [Limited_Use] a character from a script in limited use\n [Not_NFKC] a non normalized (NFKC) character\n *[other] an uncommon character\n }\n *[other] { $identifier_type ->\n [Exclusion] {$codepoints_len} characters from archaic scripts\n [Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage\n [Limited_Use] {$codepoints_len} characters from scripts in limited use\n [Not_NFKC] {$codepoints_len} non normalized (NFKC) characters\n *[other] uncommon characters\n }\n }: {$codepoints}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$codepoints_len ->\n [one] this character is\n *[other] these characters are\n } included in the{$identifier_type ->\n [Restricted] {\"\"}\n *[other] {\" \"}{$identifier_type}\n } Unicode general security profile")));
;
diag.arg("codepoints", __binding_0);
diag.arg("codepoints_len", __binding_1);
diag.arg("identifier_type", __binding_2);
diag
}
}
}
}
};Diagnostic)]
1415#[diag(
1416 "identifier contains {$codepoints_len ->
1417 [one] { $identifier_type ->
1418 [Exclusion] a character from an archaic script
1419 [Technical] a character that is for non-linguistic, specialized usage
1420 [Limited_Use] a character from a script in limited use
1421 [Not_NFKC] a non normalized (NFKC) character
1422 *[other] an uncommon character
1423 }
1424 *[other] { $identifier_type ->
1425 [Exclusion] {$codepoints_len} characters from archaic scripts
1426 [Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage
1427 [Limited_Use] {$codepoints_len} characters from scripts in limited use
1428 [Not_NFKC] {$codepoints_len} non normalized (NFKC) characters
1429 *[other] uncommon characters
1430 }
1431 }: {$codepoints}"
1432)]
1433#[note(
1434 r#"{$codepoints_len ->
1435 [one] this character is
1436 *[other] these characters are
1437 } included in the{$identifier_type ->
1438 [Restricted] {""}
1439 *[other] {" "}{$identifier_type}
1440 } Unicode general security profile"#
1441)]
1442pub(crate) struct IdentifierUncommonCodepoints {
1443 pub codepoints: Vec<char>,
1444 pub codepoints_len: usize,
1445 pub identifier_type: &'static str,
1446}
1447
1448#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConfusableIdentifierPair where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConfusableIdentifierPair {
existing_sym: __binding_0,
sym: __binding_1,
label: __binding_2,
main_label: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found both `{$existing_sym}` and `{$sym}` as identifiers, which look alike")));
;
diag.arg("existing_sym", __binding_0);
diag.arg("sym", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("other identifier used here")));
diag.span_label(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this identifier can be confused with `{$existing_sym}`")));
diag
}
}
}
}
};Diagnostic)]
1449#[diag("found both `{$existing_sym}` and `{$sym}` as identifiers, which look alike")]
1450pub(crate) struct ConfusableIdentifierPair {
1451 pub existing_sym: Symbol,
1452 pub sym: Symbol,
1453 #[label("other identifier used here")]
1454 pub label: Span,
1455 #[label("this identifier can be confused with `{$existing_sym}`")]
1456 pub main_label: Span,
1457}
1458
1459#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MixedScriptConfusables where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MixedScriptConfusables {
set: __binding_0, includes: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the usage of Script Group `{$set}` in this crate consists solely of mixed script confusables")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the usage includes {$includes}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("please recheck to make sure their usages are indeed what you want")));
;
diag.arg("set", __binding_0);
diag.arg("includes", __binding_1);
diag
}
}
}
}
};Diagnostic)]
1460#[diag(
1461 "the usage of Script Group `{$set}` in this crate consists solely of mixed script confusables"
1462)]
1463#[note("the usage includes {$includes}")]
1464#[note("please recheck to make sure their usages are indeed what you want")]
1465pub(crate) struct MixedScriptConfusables {
1466 pub set: String,
1467 pub includes: String,
1468}
1469
1470pub(crate) struct NonFmtPanicUnused {
1472 pub count: usize,
1473 pub suggestion: Option<Span>,
1474}
1475
1476impl<'a> Diagnostic<'a, ()> for NonFmtPanicUnused {
1478 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1479 let mut diag = Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("panic message contains {$count ->\n [one] an unused\n *[other] unused\n } formatting {$count ->\n [one] placeholder\n *[other] placeholders\n }"))msg!(
1480 "panic message contains {$count ->
1481 [one] an unused
1482 *[other] unused
1483 } formatting {$count ->
1484 [one] placeholder
1485 *[other] placeholders
1486 }"
1487 ))
1488 .with_arg("count", self.count)
1489 .with_note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this message is not used as a format string when given without arguments, but will be in Rust 2021"))msg!("this message is not used as a format string when given without arguments, but will be in Rust 2021"));
1490 if let Some(span) = self.suggestion {
1491 diag.span_suggestion(
1492 span.shrink_to_hi(),
1493 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add the missing {$count ->\n [one] argument\n *[other] arguments\n }"))msg!(
1494 "add the missing {$count ->
1495 [one] argument
1496 *[other] arguments
1497 }"
1498 ),
1499 ", ...",
1500 Applicability::HasPlaceholders,
1501 );
1502 diag.span_suggestion(
1503 span.shrink_to_lo(),
1504 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or add a \"{\"{\"}{\"}\"}\" format string to use the message literally"))msg!(r#"or add a "{"{"}{"}"}" format string to use the message literally"#),
1505 "\"{}\", ",
1506 Applicability::MachineApplicable,
1507 );
1508 }
1509 diag
1510 }
1511}
1512
1513#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NonFmtPanicBraces where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonFmtPanicBraces {
count: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("panic message contains {$count ->\n [one] a brace\n *[other] braces\n }")));
let __code_41 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\"{{}}\", "))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this message is not used as a format string, but will be in Rust 2021")));
;
diag.arg("count", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a \"{\"{\"}{\"}\"}\" format string to use the message literally")),
__code_41, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
1514#[diag(
1515 "panic message contains {$count ->
1516 [one] a brace
1517 *[other] braces
1518 }"
1519)]
1520#[note("this message is not used as a format string, but will be in Rust 2021")]
1521pub(crate) struct NonFmtPanicBraces {
1522 pub count: usize,
1523 #[suggestion(
1524 "add a \"{\"{\"}{\"}\"}\" format string to use the message literally",
1525 code = "\"{{}}\", ",
1526 applicability = "machine-applicable"
1527 )]
1528 pub suggestion: Option<Span>,
1529}
1530
1531#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
NonCamelCaseType<'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 {
NonCamelCaseType {
sort: __binding_0, name: __binding_1, sub: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$sort} `{$name}` should have an upper camel case name")));
;
diag.arg("sort", __binding_0);
diag.arg("name", __binding_1);
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
1533#[diag("{$sort} `{$name}` should have an upper camel case name")]
1534pub(crate) struct NonCamelCaseType<'a> {
1535 pub sort: &'a str,
1536 pub name: &'a str,
1537 #[subdiagnostic]
1538 pub sub: NonCamelCaseTypeSub,
1539}
1540
1541#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NonCamelCaseTypeSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NonCamelCaseTypeSub::Label { 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("should have an UpperCamelCase name")),
&sub_args);
diag.span_label(__binding_0, __message);
}
NonCamelCaseTypeSub::Suggestion {
span: __binding_0, replace: __binding_1 } => {
let __code_42 =
[::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("replace".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("convert the identifier to upper camel case")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_42, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1542pub(crate) enum NonCamelCaseTypeSub {
1543 #[label("should have an UpperCamelCase name")]
1544 Label {
1545 #[primary_span]
1546 span: Span,
1547 },
1548 #[suggestion(
1549 "convert the identifier to upper camel case",
1550 code = "{replace}",
1551 applicability = "maybe-incorrect"
1552 )]
1553 Suggestion {
1554 #[primary_span]
1555 span: Span,
1556 replace: String,
1557 },
1558}
1559
1560#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
NonSnakeCaseDiag<'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 {
NonSnakeCaseDiag {
sort: __binding_0,
name: __binding_1,
sc: __binding_2,
sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$sort} `{$name}` should have a snake case name")));
;
diag.arg("sort", __binding_0);
diag.arg("name", __binding_1);
diag.arg("sc", __binding_2);
diag.subdiagnostic(__binding_3);
diag
}
}
}
}
};Diagnostic)]
1561#[diag("{$sort} `{$name}` should have a snake case name")]
1562pub(crate) struct NonSnakeCaseDiag<'a> {
1563 pub sort: &'a str,
1564 pub name: &'a str,
1565 pub sc: String,
1566 #[subdiagnostic]
1567 pub sub: NonSnakeCaseDiagSub,
1568}
1569
1570pub(crate) enum NonSnakeCaseDiagSub {
1571 Label { span: Span },
1572 Help,
1573 RenameOrConvertSuggestion { span: Span, suggestion: Ident },
1574 ConvertSuggestion { span: Span, suggestion: String },
1575 SuggestionAndNote { span: Span },
1576}
1577
1578impl Subdiagnostic for NonSnakeCaseDiagSub {
1579 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1580 match self {
1581 NonSnakeCaseDiagSub::Label { span } => {
1582 diag.span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("should have a snake_case name"))msg!("should have a snake_case name"));
1583 }
1584 NonSnakeCaseDiagSub::Help => {
1585 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert the identifier to snake case: `{$sc}`"))msg!("convert the identifier to snake case: `{$sc}`"));
1586 }
1587 NonSnakeCaseDiagSub::ConvertSuggestion { span, suggestion } => {
1588 diag.span_suggestion(
1589 span,
1590 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert the identifier to snake case"))msg!("convert the identifier to snake case"),
1591 suggestion,
1592 Applicability::MaybeIncorrect,
1593 );
1594 }
1595 NonSnakeCaseDiagSub::RenameOrConvertSuggestion { span, suggestion } => {
1596 diag.span_suggestion(
1597 span,
1598 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rename the identifier or convert it to a snake case raw identifier"))msg!("rename the identifier or convert it to a snake case raw identifier"),
1599 suggestion,
1600 Applicability::MaybeIncorrect,
1601 );
1602 }
1603 NonSnakeCaseDiagSub::SuggestionAndNote { span } => {
1604 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$sc}` cannot be used as a raw identifier"))msg!("`{$sc}` cannot be used as a raw identifier"));
1605 diag.span_suggestion(
1606 span,
1607 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rename the identifier"))msg!("rename the identifier"),
1608 "",
1609 Applicability::MaybeIncorrect,
1610 );
1611 }
1612 }
1613 }
1614}
1615
1616#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
NonUpperCaseGlobal<'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 {
NonUpperCaseGlobal {
sort: __binding_0,
name: __binding_1,
sub: __binding_2,
usages: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$sort} `{$name}` should have an upper case name")));
;
diag.arg("sort", __binding_0);
diag.arg("name", __binding_1);
diag.subdiagnostic(__binding_2);
for __binding_3 in __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
1617#[diag("{$sort} `{$name}` should have an upper case name")]
1618pub(crate) struct NonUpperCaseGlobal<'a> {
1619 pub sort: &'a str,
1620 pub name: &'a str,
1621 #[subdiagnostic]
1622 pub sub: NonUpperCaseGlobalSub,
1623 #[subdiagnostic]
1624 pub usages: Vec<NonUpperCaseGlobalSubTool>,
1625}
1626
1627#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NonUpperCaseGlobalSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NonUpperCaseGlobalSub::Label { 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("should have an UPPER_CASE name")),
&sub_args);
diag.span_label(__binding_0, __message);
}
NonUpperCaseGlobalSub::Suggestion {
span: __binding_0,
applicability: __binding_1,
replace: __binding_2 } => {
let __code_43 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("replace".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("convert the identifier to upper case")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_43, __binding_1,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1628pub(crate) enum NonUpperCaseGlobalSub {
1629 #[label("should have an UPPER_CASE name")]
1630 Label {
1631 #[primary_span]
1632 span: Span,
1633 },
1634 #[suggestion("convert the identifier to upper case", code = "{replace}")]
1635 Suggestion {
1636 #[primary_span]
1637 span: Span,
1638 #[applicability]
1639 applicability: Applicability,
1640 replace: String,
1641 },
1642}
1643
1644#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NonUpperCaseGlobalSubTool {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NonUpperCaseGlobalSubTool {
span: __binding_0, replace: __binding_1 } => {
let __code_44 =
[::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("replace".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("convert the identifier to upper case")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_44, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
}
}
}
}
};Subdiagnostic)]
1645#[suggestion(
1646 "convert the identifier to upper case",
1647 code = "{replace}",
1648 applicability = "machine-applicable",
1649 style = "tool-only"
1650)]
1651pub(crate) struct NonUpperCaseGlobalSubTool {
1652 #[primary_span]
1653 pub(crate) span: Span,
1654 pub(crate) replace: String,
1655}
1656
1657#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
NoopMethodCallDiag<'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 {
NoopMethodCallDiag {
method: __binding_0,
orig_ty: __binding_1,
trait_: __binding_2,
label: __binding_3,
suggest_derive: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to `.{$method}()` on a reference in this situation does nothing")));
let __code_45 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let __code_46 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#[derive(Clone)]\n"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed")));
;
diag.arg("method", __binding_0);
diag.arg("orig_ty", __binding_1);
diag.arg("trait_", __binding_2);
diag.span_suggestions_with_style(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this redundant call")),
__code_45, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
if let Some(__binding_4) = __binding_4 {
diag.span_suggestions_with_style(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to clone `{$orig_ty}`, implement `Clone` for it")),
__code_46, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
1659#[diag("call to `.{$method}()` on a reference in this situation does nothing")]
1660#[note(
1661 "the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed"
1662)]
1663pub(crate) struct NoopMethodCallDiag<'a> {
1664 pub method: Ident,
1665 pub orig_ty: Ty<'a>,
1666 pub trait_: Symbol,
1667 #[suggestion("remove this redundant call", code = "", applicability = "machine-applicable")]
1668 pub label: Span,
1669 #[suggestion(
1670 "if you meant to clone `{$orig_ty}`, implement `Clone` for it",
1671 code = "#[derive(Clone)]\n",
1672 applicability = "maybe-incorrect"
1673 )]
1674 pub suggest_derive: Option<Span>,
1675}
1676
1677#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
SuspiciousDoubleRefDerefDiag<'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 {
SuspiciousDoubleRefDerefDiag { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type")));
;
diag.arg("ty", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1678#[diag(
1679 "using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type"
1680)]
1681pub(crate) struct SuspiciousDoubleRefDerefDiag<'a> {
1682 pub ty: Ty<'a>,
1683}
1684
1685#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
SuspiciousDoubleRefCloneDiag<'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 {
SuspiciousDoubleRefCloneDiag { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type")));
;
diag.arg("ty", __binding_0);
diag
}
}
}
}
};Diagnostic)]
1686#[diag(
1687 "using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type"
1688)]
1689pub(crate) struct SuspiciousDoubleRefCloneDiag<'a> {
1690 pub ty: Ty<'a>,
1691}
1692
1693pub(crate) enum NonLocalDefinitionsDiag {
1695 Impl {
1696 depth: u32,
1697 body_kind_descr: &'static str,
1698 body_name: String,
1699 cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
1700 const_anon: Option<Option<Span>>,
1701 doctest: bool,
1702 macro_to_change: Option<(String, &'static str)>,
1703 },
1704 MacroRules {
1705 depth: u32,
1706 body_kind_descr: &'static str,
1707 body_name: String,
1708 doctest: bool,
1709 cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
1710 },
1711}
1712
1713impl<'a> Diagnostic<'a, ()> for NonLocalDefinitionsDiag {
1714 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1715 let mut diag = Diag::new(dcx, level, "");
1716 match self {
1717 NonLocalDefinitionsDiag::Impl {
1718 depth,
1719 body_kind_descr,
1720 body_name,
1721 cargo_update,
1722 const_anon,
1723 doctest,
1724 macro_to_change,
1725 } => {
1726 diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-local `impl` definition, `impl` blocks should be written at the same level as their item"))msg!("non-local `impl` definition, `impl` blocks should be written at the same level as their item"));
1727 diag.arg("depth", depth);
1728 diag.arg("body_kind_descr", body_kind_descr);
1729 diag.arg("body_name", body_name);
1730
1731 if let Some((macro_to_change, macro_kind)) = macro_to_change {
1732 diag.arg("macro_to_change", macro_to_change);
1733 diag.arg("macro_kind", macro_kind);
1734 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed"))msg!("the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed"));
1735 }
1736 if let Some(cargo_update) = cargo_update {
1737 diag.subdiagnostic(cargo_update);
1738 }
1739
1740 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`"))msg!("an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`"));
1741
1742 if doctest {
1743 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("make this doc-test a standalone test with its own `fn main() {\"{\"} ... {\"}\"}`"))msg!("make this doc-test a standalone test with its own `fn main() {\"{\"} ... {\"}\"}`"));
1744 }
1745
1746 if let Some(const_anon) = const_anon {
1747 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items in an anonymous const item (`const _: () = {\"{\"} ... {\"}\"}`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint"))msg!("items in an anonymous const item (`const _: () = {\"{\"} ... {\"}\"}`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint"));
1748 if let Some(const_anon) = const_anon {
1749 diag.span_suggestion(
1750 const_anon,
1751 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a const-anon item to suppress this lint"))msg!("use a const-anon item to suppress this lint"),
1752 "_",
1753 Applicability::MachineApplicable,
1754 );
1755 }
1756 }
1757 }
1758 NonLocalDefinitionsDiag::MacroRules {
1759 depth,
1760 body_kind_descr,
1761 body_name,
1762 doctest,
1763 cargo_update,
1764 } => {
1765 diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module"))msg!("non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module"));
1766 diag.arg("depth", depth);
1767 diag.arg("body_kind_descr", body_kind_descr);
1768 diag.arg("body_name", body_name);
1769
1770 if doctest {
1771 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() {\"{\"} ... {\"}\"}`"))msg!(r#"remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() {"{"} ... {"}"}`"#));
1772 } else {
1773 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth ->\n [one] `{$body_name}`\n *[other] `{$body_name}` and up {$depth} bodies\n }"))msg!(
1774 "remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth ->
1775 [one] `{$body_name}`
1776 *[other] `{$body_name}` and up {$depth} bodies
1777 }"
1778 ));
1779 }
1780
1781 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute"))msg!("a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute"));
1782
1783 if let Some(cargo_update) = cargo_update {
1784 diag.subdiagnostic(cargo_update);
1785 }
1786 }
1787 }
1788 diag
1789 }
1790}
1791
1792#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
NonLocalDefinitionsCargoUpdateNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NonLocalDefinitionsCargoUpdateNote {
macro_kind: __binding_0,
macro_name: __binding_1,
crate_name: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("macro_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("macro_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("crate_name".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("the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}`")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
1793#[note(
1794 "the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}`"
1795)]
1796pub(crate) struct NonLocalDefinitionsCargoUpdateNote {
1797 pub macro_kind: &'static str,
1798 pub macro_name: Symbol,
1799 pub crate_name: Symbol,
1800}
1801
1802#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AmbiguousNegativeLiteralsDiag where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AmbiguousNegativeLiteralsDiag {
negative_literal: __binding_0, current_behavior: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-` has lower precedence than method calls, which might be unexpected")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`")));
;
diag.subdiagnostic(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1804#[diag("`-` has lower precedence than method calls, which might be unexpected")]
1805#[note("e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`")]
1806pub(crate) struct AmbiguousNegativeLiteralsDiag {
1807 #[subdiagnostic]
1808 pub negative_literal: AmbiguousNegativeLiteralsNegativeLiteralSuggestion,
1809 #[subdiagnostic]
1810 pub current_behavior: AmbiguousNegativeLiteralsCurrentBehaviorSuggestion,
1811}
1812
1813#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AmbiguousNegativeLiteralsNegativeLiteralSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousNegativeLiteralsNegativeLiteralSuggestion {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_47 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_48 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_47));
suggestions.push((__binding_1, __code_48));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses around the `-` and the literal to call the method on a negative literal")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1814#[multipart_suggestion(
1815 "add parentheses around the `-` and the literal to call the method on a negative literal",
1816 applicability = "maybe-incorrect"
1817)]
1818pub(crate) struct AmbiguousNegativeLiteralsNegativeLiteralSuggestion {
1819 #[suggestion_part(code = "(")]
1820 pub start_span: Span,
1821 #[suggestion_part(code = ")")]
1822 pub end_span: Span,
1823}
1824
1825#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
start_span: __binding_0, end_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_49 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_50 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_49));
suggestions.push((__binding_1, __code_50));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses around the literal and the method call to keep the current behavior")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1826#[multipart_suggestion(
1827 "add parentheses around the literal and the method call to keep the current behavior",
1828 applicability = "maybe-incorrect"
1829)]
1830pub(crate) struct AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
1831 #[suggestion_part(code = "(")]
1832 pub start_span: Span,
1833 #[suggestion_part(code = ")")]
1834 pub end_span: Span,
1835}
1836
1837#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DisallowedPassByRefDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DisallowedPassByRefDiag {
ty: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("passing `{$ty}` by reference")));
let __code_51 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_0))
})].into_iter();
;
diag.arg("ty", __binding_0);
diag.span_suggestions_with_style(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try passing by value")),
__code_51, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
1839#[diag("passing `{$ty}` by reference")]
1840pub(crate) struct DisallowedPassByRefDiag {
1841 pub ty: String,
1842 #[suggestion("try passing by value", code = "{ty}", applicability = "maybe-incorrect")]
1843 pub suggestion: Span,
1844}
1845
1846#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
RedundantSemicolonsDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
RedundantSemicolonsDiag {
multiple: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary trailing {$multiple ->\n [true] semicolons\n *[false] semicolon\n }")));
;
diag.arg("multiple", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
1848#[diag(
1849 "unnecessary trailing {$multiple ->
1850 [true] semicolons
1851 *[false] semicolon
1852 }"
1853)]
1854pub(crate) struct RedundantSemicolonsDiag {
1855 pub multiple: bool,
1856 #[subdiagnostic]
1857 pub suggestion: Option<RedundantSemicolonsSuggestion>,
1858}
1859
1860#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RedundantSemicolonsSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RedundantSemicolonsSuggestion {
multiple_semicolons: __binding_0, span: __binding_1 } => {
let __code_52 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("multiple_semicolons".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("remove {$multiple_semicolons ->\n [true] these semicolons\n *[false] this semicolon\n }")),
&sub_args);
diag.span_suggestions_with_style(__binding_1, __message,
__code_52, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1861#[suggestion(
1862 "remove {$multiple_semicolons ->
1863 [true] these semicolons
1864 *[false] this semicolon
1865 }",
1866 code = "",
1867 applicability = "maybe-incorrect"
1868)]
1869pub(crate) struct RedundantSemicolonsSuggestion {
1870 pub multiple_semicolons: bool,
1871 #[primary_span]
1872 pub span: Span,
1873}
1874
1875pub(crate) struct DropTraitConstraintsDiag<'a> {
1877 pub predicate: Clause<'a>,
1878 pub tcx: TyCtxt<'a>,
1879 pub def_id: DefId,
1880}
1881
1882impl<'a> Diagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
1884 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1885 Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped"))msg!("bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped"))
1886 .with_arg("predicate", self.predicate)
1887 .with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
1888 }
1889}
1890
1891pub(crate) struct DropGlue<'a> {
1892 pub tcx: TyCtxt<'a>,
1893 pub def_id: DefId,
1894}
1895
1896impl<'a> Diagnostic<'a, ()> for DropGlue<'_> {
1898 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1899 Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped"))msg!("types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped"))
1900 .with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
1901 }
1902}
1903
1904#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
IntegerToPtrTransmutes<'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 {
IntegerToPtrTransmutes { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("transmuting an integer to a pointer creates a pointer without provenance")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is dangerous because dereferencing the resulting pointer is undefined behavior")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("exposed provenance semantics can be used to create a pointer based on some previously exposed provenance")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>")));
;
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
1906#[diag("transmuting an integer to a pointer creates a pointer without provenance")]
1907#[note("this is dangerous because dereferencing the resulting pointer is undefined behavior")]
1908#[note(
1909 "exposed provenance semantics can be used to create a pointer based on some previously exposed provenance"
1910)]
1911#[help(
1912 "if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`"
1913)]
1914#[help(
1915 "for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>"
1916)]
1917#[help(
1918 "for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>"
1919)]
1920pub(crate) struct IntegerToPtrTransmutes<'tcx> {
1921 #[subdiagnostic]
1922 pub suggestion: Option<IntegerToPtrTransmutesSuggestion<'tcx>>,
1923}
1924
1925#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for
IntegerToPtrTransmutesSuggestion<'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IntegerToPtrTransmutesSuggestion::ToPtr {
dst: __binding_0,
suffix: __binding_1,
start_call: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_53 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("std::ptr::with_exposed_provenance{1}::<{0}>(",
__binding_0, __binding_1))
});
suggestions.push((__binding_2, __code_53));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("dst".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("suffix".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("use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
IntegerToPtrTransmutesSuggestion::ToRef {
dst: __binding_0,
suffix: __binding_1,
ref_mutbl: __binding_2,
start_call: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_54 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&{1}*std::ptr::with_exposed_provenance{2}::<{0}>(",
__binding_0, __binding_2, __binding_1))
});
suggestions.push((__binding_3, __code_54));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("dst".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("suffix".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("ref_mutbl".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("use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1926pub(crate) enum IntegerToPtrTransmutesSuggestion<'tcx> {
1927 #[multipart_suggestion(
1928 "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance",
1929 applicability = "machine-applicable",
1930 style = "verbose"
1931 )]
1932 ToPtr {
1933 dst: Ty<'tcx>,
1934 suffix: &'static str,
1935 #[suggestion_part(code = "std::ptr::with_exposed_provenance{suffix}::<{dst}>(")]
1936 start_call: Span,
1937 },
1938 #[multipart_suggestion(
1939 "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance",
1940 applicability = "machine-applicable",
1941 style = "verbose"
1942 )]
1943 ToRef {
1944 dst: Ty<'tcx>,
1945 suffix: &'static str,
1946 ref_mutbl: &'static str,
1947 #[suggestion_part(
1948 code = "&{ref_mutbl}*std::ptr::with_exposed_provenance{suffix}::<{dst}>("
1949 )]
1950 start_call: Span,
1951 },
1952}
1953
1954#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
RangeEndpointOutOfRange<'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 {
RangeEndpointOutOfRange { ty: __binding_0, sub: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("range endpoint is out of range for `{$ty}`")));
;
diag.arg("ty", __binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1956#[diag("range endpoint is out of range for `{$ty}`")]
1957pub(crate) struct RangeEndpointOutOfRange<'a> {
1958 pub ty: &'a str,
1959 #[subdiagnostic]
1960 pub sub: UseInclusiveRange<'a>,
1961}
1962
1963#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for UseInclusiveRange<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UseInclusiveRange::WithoutParen {
sugg: __binding_0,
start: __binding_1,
literal: __binding_2,
suffix: __binding_3 } => {
let __code_55 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}..={0}{2}",
__binding_2, __binding_1, __binding_3))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("start".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("literal".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("suffix".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use an inclusive range instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_55, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
UseInclusiveRange::WithParen {
eq_sugg: __binding_0,
lit_sugg: __binding_1,
literal: __binding_2,
suffix: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_56 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("="))
});
let __code_57 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", __binding_2,
__binding_3))
});
suggestions.push((__binding_0, __code_56));
suggestions.push((__binding_1, __code_57));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("literal".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("suffix".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use an inclusive range instead")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1964pub(crate) enum UseInclusiveRange<'a> {
1965 #[suggestion(
1966 "use an inclusive range instead",
1967 code = "{start}..={literal}{suffix}",
1968 applicability = "machine-applicable"
1969 )]
1970 WithoutParen {
1971 #[primary_span]
1972 sugg: Span,
1973 start: String,
1974 literal: u128,
1975 suffix: &'a str,
1976 },
1977 #[multipart_suggestion("use an inclusive range instead", applicability = "machine-applicable")]
1978 WithParen {
1979 #[suggestion_part(code = "=")]
1980 eq_sugg: Span,
1981 #[suggestion_part(code = "{literal}{suffix}")]
1982 lit_sugg: Span,
1983 literal: u128,
1984 suffix: &'a str,
1985 },
1986}
1987
1988#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
OverflowingBinHex<'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 {
OverflowingBinHex {
ty: __binding_0,
sign: __binding_1,
sub: __binding_2,
sign_bit_sub: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
;
diag.arg("ty", __binding_0);
diag.subdiagnostic(__binding_1);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
1989#[diag("literal out of range for `{$ty}`")]
1990pub(crate) struct OverflowingBinHex<'a> {
1991 pub ty: &'a str,
1992 #[subdiagnostic]
1993 pub sign: OverflowingBinHexSign<'a>,
1994 #[subdiagnostic]
1995 pub sub: Option<OverflowingBinHexSub<'a>>,
1996 #[subdiagnostic]
1997 pub sign_bit_sub: Option<OverflowingBinHexSignBitSub<'a>>,
1998}
1999
2000#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OverflowingBinHexSign<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OverflowingBinHexSign::Positive {
lit: __binding_0,
ty: __binding_1,
actually: __binding_2,
dec: __binding_3 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("lit".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("actually".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("dec".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`")),
&sub_args);
diag.note(__message);
}
OverflowingBinHexSign::Negative {
lit: __binding_0,
ty: __binding_1,
actually: __binding_2,
dec: __binding_3 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("lit".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("actually".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("dec".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("and the value `-{$lit}` will become `{$actually}{$ty}`")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
2001pub(crate) enum OverflowingBinHexSign<'a> {
2002 #[note(
2003 "the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`"
2004 )]
2005 Positive { lit: String, ty: &'a str, actually: String, dec: u128 },
2006 #[note("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`")]
2007 #[note("and the value `-{$lit}` will become `{$actually}{$ty}`")]
2008 Negative { lit: String, ty: &'a str, actually: String, dec: u128 },
2009}
2010
2011#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OverflowingBinHexSub<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OverflowingBinHexSub::Suggestion {
span: __binding_0,
suggestion_ty: __binding_1,
sans_suffix: __binding_2 } => {
let __code_58 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", __binding_2,
__binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggestion_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("sans_suffix".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("consider using the type `{$suggestion_ty}` instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_58, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
OverflowingBinHexSub::Help { suggestion_ty: __binding_0 } =>
{
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggestion_ty".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 using the type `{$suggestion_ty}` instead")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2012pub(crate) enum OverflowingBinHexSub<'a> {
2013 #[suggestion(
2014 "consider using the type `{$suggestion_ty}` instead",
2015 code = "{sans_suffix}{suggestion_ty}",
2016 applicability = "machine-applicable"
2017 )]
2018 Suggestion {
2019 #[primary_span]
2020 span: Span,
2021 suggestion_ty: &'a str,
2022 sans_suffix: &'a str,
2023 },
2024 #[help("consider using the type `{$suggestion_ty}` instead")]
2025 Help { suggestion_ty: &'a str },
2026}
2027
2028#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
OverflowingBinHexSignBitSub<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OverflowingBinHexSignBitSub {
span: __binding_0,
lit_no_suffix: __binding_1,
negative_val: __binding_2,
uint_ty: __binding_3,
int_ty: __binding_4 } => {
let __code_59 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}{2} as {0}",
__binding_4, __binding_1, __binding_3))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("lit_no_suffix".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("negative_val".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("uint_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("int_ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_59, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2029#[suggestion(
2030 "to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`",
2031 code = "{lit_no_suffix}{uint_ty} as {int_ty}",
2032 applicability = "maybe-incorrect"
2033)]
2034pub(crate) struct OverflowingBinHexSignBitSub<'a> {
2035 #[primary_span]
2036 pub span: Span,
2037 pub lit_no_suffix: &'a str,
2038 pub negative_val: String,
2039 pub uint_ty: &'a str,
2040 pub int_ty: &'a str,
2041}
2042
2043#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
OverflowingInt<'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 {
OverflowingInt {
ty: __binding_0,
lit: __binding_1,
min: __binding_2,
max: __binding_3,
help: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")));
;
diag.arg("ty", __binding_0);
diag.arg("lit", __binding_1);
diag.arg("min", __binding_2);
diag.arg("max", __binding_3);
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag
}
}
}
}
};Diagnostic)]
2044#[diag("literal out of range for `{$ty}`")]
2045#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
2046pub(crate) struct OverflowingInt<'a> {
2047 pub ty: &'a str,
2048 pub lit: String,
2049 pub min: i128,
2050 pub max: u128,
2051 #[subdiagnostic]
2052 pub help: Option<OverflowingIntHelp<'a>>,
2053}
2054
2055#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for OverflowingIntHelp<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
OverflowingIntHelp { suggestion_ty: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggestion_ty".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 using the type `{$suggestion_ty}` instead")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2056#[help("consider using the type `{$suggestion_ty}` instead")]
2057pub(crate) struct OverflowingIntHelp<'a> {
2058 pub suggestion_ty: &'a str,
2059}
2060
2061#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OnlyCastu8ToChar where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OnlyCastu8ToChar { span: __binding_0, literal: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `u8` can be cast into `char`")));
let __code_60 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\'\\u{{{0:X}}}\'",
__binding_1))
})].into_iter();
;
diag.arg("literal", __binding_1);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a `char` literal instead")),
__code_60, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
2062#[diag("only `u8` can be cast into `char`")]
2063pub(crate) struct OnlyCastu8ToChar {
2064 #[suggestion(
2065 "use a `char` literal instead",
2066 code = "'\\u{{{literal:X}}}'",
2067 applicability = "machine-applicable"
2068 )]
2069 pub span: Span,
2070 pub literal: u128,
2071}
2072
2073#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
OverflowingUInt<'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 {
OverflowingUInt {
ty: __binding_0,
lit: __binding_1,
min: __binding_2,
max: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")));
;
diag.arg("ty", __binding_0);
diag.arg("lit", __binding_1);
diag.arg("min", __binding_2);
diag.arg("max", __binding_3);
diag
}
}
}
}
};Diagnostic)]
2074#[diag("literal out of range for `{$ty}`")]
2075#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
2076pub(crate) struct OverflowingUInt<'a> {
2077 pub ty: &'a str,
2078 pub lit: String,
2079 pub min: u128,
2080 pub max: u128,
2081}
2082
2083#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
OverflowingLiteral<'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 {
OverflowingLiteral { ty: __binding_0, lit: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` does not fit into the type `{$ty}` and will be converted to `{$ty}::INFINITY`")));
;
diag.arg("ty", __binding_0);
diag.arg("lit", __binding_1);
diag
}
}
}
}
};Diagnostic)]
2084#[diag("literal out of range for `{$ty}`")]
2085#[note(
2086 "the literal `{$lit}` does not fit into the type `{$ty}` and will be converted to `{$ty}::INFINITY`"
2087)]
2088pub(crate) struct OverflowingLiteral<'a> {
2089 pub ty: &'a str,
2090 pub lit: String,
2091}
2092
2093#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SurrogateCharCast where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
SurrogateCharCast { literal: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surrogate values are not valid for `char`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values")));
;
diag.arg("literal", __binding_0);
diag
}
}
}
}
};Diagnostic)]
2094#[diag("surrogate values are not valid for `char`")]
2095#[note("`0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values")]
2096pub(crate) struct SurrogateCharCast {
2097 pub literal: u128,
2098}
2099
2100#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TooLargeCharCast where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TooLargeCharCast { literal: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value exceeds maximum `char` value")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("maximum valid `char` value is `0x10FFFF`")));
;
diag.arg("literal", __binding_0);
diag
}
}
}
}
};Diagnostic)]
2101#[diag("value exceeds maximum `char` value")]
2102#[note("maximum valid `char` value is `0x10FFFF`")]
2103pub(crate) struct TooLargeCharCast {
2104 pub literal: u128,
2105}
2106
2107#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UsesPowerAlignment where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UsesPowerAlignment => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type")));
;
diag
}
}
}
}
};Diagnostic)]
2108#[diag(
2109 "repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type"
2110)]
2111pub(crate) struct UsesPowerAlignment;
2112
2113#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedComparisons where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnusedComparisons => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("comparison is useless due to type limits")));
;
diag
}
}
}
}
};Diagnostic)]
2114#[diag("comparison is useless due to type limits")]
2115pub(crate) struct UnusedComparisons;
2116
2117#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidNanComparisons where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidNanComparisons::EqNe { suggestion: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect NaN comparison, NaN cannot be directly compared to itself")));
;
diag.subdiagnostic(__binding_0);
diag
}
InvalidNanComparisons::LtLeGtGe => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect NaN comparison, NaN is not orderable")));
;
diag
}
}
}
}
};Diagnostic)]
2118pub(crate) enum InvalidNanComparisons {
2119 #[diag("incorrect NaN comparison, NaN cannot be directly compared to itself")]
2120 EqNe {
2121 #[subdiagnostic]
2122 suggestion: InvalidNanComparisonsSuggestion,
2123 },
2124 #[diag("incorrect NaN comparison, NaN is not orderable")]
2125 LtLeGtGe,
2126}
2127
2128#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvalidNanComparisonsSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidNanComparisonsSuggestion::Spanful {
neg: __binding_0,
float: __binding_1,
nan_plus_binop: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_61 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("!"))
});
let __code_62 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".is_nan()"))
});
let __code_63 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
if let Some(__binding_0) = __binding_0 {
suggestions.push((__binding_0, __code_61));
}
suggestions.push((__binding_1, __code_62));
suggestions.push((__binding_2, __code_63));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `f32::is_nan()` or `f64::is_nan()` instead")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
InvalidNanComparisonsSuggestion::Spanless => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `f32::is_nan()` or `f64::is_nan()` instead")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2129pub(crate) enum InvalidNanComparisonsSuggestion {
2130 #[multipart_suggestion(
2131 "use `f32::is_nan()` or `f64::is_nan()` instead",
2132 style = "verbose",
2133 applicability = "machine-applicable"
2134 )]
2135 Spanful {
2136 #[suggestion_part(code = "!")]
2137 neg: Option<Span>,
2138 #[suggestion_part(code = ".is_nan()")]
2139 float: Span,
2140 #[suggestion_part(code = "")]
2141 nan_plus_binop: Span,
2142 },
2143 #[help("use `f32::is_nan()` or `f64::is_nan()` instead")]
2144 Spanless,
2145}
2146
2147#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
AmbiguousWidePointerComparisons<'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 {
AmbiguousWidePointerComparisons::SpanfulEq {
addr_suggestion: __binding_0,
addr_metadata_suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous wide pointer comparison, the comparison includes metadata which may not be expected")));
;
diag.subdiagnostic(__binding_0);
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
AmbiguousWidePointerComparisons::SpanfulCmp {
cast_suggestion: __binding_0, expect_suggestion: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous wide pointer comparison, the comparison includes metadata which may not be expected")));
;
diag.subdiagnostic(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
AmbiguousWidePointerComparisons::Spanless => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous wide pointer comparison, the comparison includes metadata which may not be expected")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use explicit `std::ptr::eq` method to compare metadata and addresses")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")));
;
diag
}
}
}
}
};Diagnostic)]
2148pub(crate) enum AmbiguousWidePointerComparisons<'a> {
2149 #[diag(
2150 "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2151 )]
2152 SpanfulEq {
2153 #[subdiagnostic]
2154 addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion<'a>,
2155 #[subdiagnostic]
2156 addr_metadata_suggestion: Option<AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a>>,
2157 },
2158 #[diag(
2159 "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2160 )]
2161 SpanfulCmp {
2162 #[subdiagnostic]
2163 cast_suggestion: AmbiguousWidePointerComparisonsCastSuggestion<'a>,
2164 #[subdiagnostic]
2165 expect_suggestion: AmbiguousWidePointerComparisonsExpectSuggestion<'a>,
2166 },
2167 #[diag(
2168 "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2169 )]
2170 #[help("use explicit `std::ptr::eq` method to compare metadata and addresses")]
2171 #[help("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")]
2172 Spanless,
2173}
2174
2175#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousWidePointerComparisonsAddrMetadataSuggestion {
ne: __binding_0,
deref_left: __binding_1,
deref_right: __binding_2,
l_modifiers: __binding_3,
r_modifiers: __binding_4,
left: __binding_5,
middle: __binding_6,
right: __binding_7 } => {
let mut suggestions = Vec::new();
let __code_64 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}std::ptr::eq({0}",
__binding_1, __binding_0))
});
let __code_65 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}, {0}", __binding_2,
__binding_3))
});
let __code_66 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0})", __binding_4))
});
suggestions.push((__binding_5, __code_64));
suggestions.push((__binding_6, __code_65));
suggestions.push((__binding_7, __code_66));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ne".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("deref_left".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("deref_right".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("l_modifiers".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("r_modifiers".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use explicit `std::ptr::eq` method to compare metadata and addresses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2176#[multipart_suggestion(
2177 "use explicit `std::ptr::eq` method to compare metadata and addresses",
2178 style = "verbose",
2179 applicability = "maybe-incorrect"
2181)]
2182pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
2183 pub ne: &'a str,
2184 pub deref_left: &'a str,
2185 pub deref_right: &'a str,
2186 pub l_modifiers: &'a str,
2187 pub r_modifiers: &'a str,
2188 #[suggestion_part(code = "{ne}std::ptr::eq({deref_left}")]
2189 pub left: Span,
2190 #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
2191 pub middle: Span,
2192 #[suggestion_part(code = "{r_modifiers})")]
2193 pub right: Span,
2194}
2195
2196#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousWidePointerComparisonsAddrSuggestion {
ne: __binding_0,
deref_left: __binding_1,
deref_right: __binding_2,
l_modifiers: __binding_3,
r_modifiers: __binding_4,
left: __binding_5,
middle: __binding_6,
right: __binding_7 } => {
let mut suggestions = Vec::new();
let __code_67 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}std::ptr::addr_eq({0}",
__binding_1, __binding_0))
});
let __code_68 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}, {0}", __binding_2,
__binding_3))
});
let __code_69 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0})", __binding_4))
});
suggestions.push((__binding_5, __code_67));
suggestions.push((__binding_6, __code_68));
suggestions.push((__binding_7, __code_69));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ne".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("deref_left".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("deref_right".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("l_modifiers".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("r_modifiers".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2197#[multipart_suggestion(
2198 "use `std::ptr::addr_eq` or untyped pointers to only compare their addresses",
2199 style = "verbose",
2200 applicability = "maybe-incorrect"
2202)]
2203pub(crate) struct AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
2204 pub(crate) ne: &'a str,
2205 pub(crate) deref_left: &'a str,
2206 pub(crate) deref_right: &'a str,
2207 pub(crate) l_modifiers: &'a str,
2208 pub(crate) r_modifiers: &'a str,
2209 #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")]
2210 pub(crate) left: Span,
2211 #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
2212 pub(crate) middle: Span,
2213 #[suggestion_part(code = "{r_modifiers})")]
2214 pub(crate) right: Span,
2215}
2216
2217#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AmbiguousWidePointerComparisonsCastSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousWidePointerComparisonsCastSuggestion {
deref_left: __binding_0,
deref_right: __binding_1,
paren_left: __binding_2,
paren_right: __binding_3,
l_modifiers: __binding_4,
r_modifiers: __binding_5,
left_before: __binding_6,
left_after: __binding_7,
right_before: __binding_8,
right_after: __binding_9 } => {
let mut suggestions = Vec::new();
let __code_70 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("({0}", __binding_0))
});
let __code_71 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}.cast::<()>()",
__binding_4, __binding_2))
});
let __code_72 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("({0}", __binding_1))
});
let __code_73 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}{0}.cast::<()>()",
__binding_3, __binding_5))
});
if let Some(__binding_6) = __binding_6 {
suggestions.push((__binding_6, __code_70));
}
suggestions.push((__binding_7, __code_71));
if let Some(__binding_8) = __binding_8 {
suggestions.push((__binding_8, __code_72));
}
suggestions.push((__binding_9, __code_73));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("deref_left".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("deref_right".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("paren_left".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("paren_right".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("l_modifiers".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
sub_args.insert("r_modifiers".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_5,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use untyped pointers to only compare their addresses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2218#[multipart_suggestion(
2219 "use untyped pointers to only compare their addresses",
2220 style = "verbose",
2221 applicability = "maybe-incorrect"
2223)]
2224pub(crate) struct AmbiguousWidePointerComparisonsCastSuggestion<'a> {
2225 pub(crate) deref_left: &'a str,
2226 pub(crate) deref_right: &'a str,
2227 pub(crate) paren_left: &'a str,
2228 pub(crate) paren_right: &'a str,
2229 pub(crate) l_modifiers: &'a str,
2230 pub(crate) r_modifiers: &'a str,
2231 #[suggestion_part(code = "({deref_left}")]
2232 pub(crate) left_before: Option<Span>,
2233 #[suggestion_part(code = "{l_modifiers}{paren_left}.cast::<()>()")]
2234 pub(crate) left_after: Span,
2235 #[suggestion_part(code = "({deref_right}")]
2236 pub(crate) right_before: Option<Span>,
2237 #[suggestion_part(code = "{r_modifiers}{paren_right}.cast::<()>()")]
2238 pub(crate) right_after: Span,
2239}
2240
2241#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for
AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
AmbiguousWidePointerComparisonsExpectSuggestion {
paren_left: __binding_0,
paren_right: __binding_1,
before: __binding_2,
after: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_74 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{ #[expect(ambiguous_wide_pointer_comparisons, reason = \"...\")] {0}",
__binding_0))
});
let __code_75 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} }}", __binding_1))
});
suggestions.push((__binding_2, __code_74));
suggestions.push((__binding_3, __code_75));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("paren_left".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("paren_right".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("or expect the lint to compare the pointers metadata and addresses")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2242#[multipart_suggestion(
2243 "or expect the lint to compare the pointers metadata and addresses",
2244 style = "verbose",
2245 applicability = "maybe-incorrect"
2247)]
2248pub(crate) struct AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
2249 pub(crate) paren_left: &'a str,
2250 pub(crate) paren_right: &'a str,
2251 #[suggestion_part(
2253 code = r#"{{ #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] {paren_left}"#
2254 )]
2255 pub(crate) before: Span,
2256 #[suggestion_part(code = "{paren_right} }}")]
2257 pub(crate) after: Span,
2258}
2259
2260#[derive(const _: () =
{
impl<'_sess, 'a, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
UnpredictableFunctionPointerComparisons<'a, '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 {
UnpredictableFunctionPointerComparisons::Suggestion {
sugg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the address of the same function can vary between different codegen units")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("furthermore, different functions could have the same address after being merged together")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>")));
;
diag.subdiagnostic(__binding_0);
diag
}
UnpredictableFunctionPointerComparisons::Warn => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the address of the same function can vary between different codegen units")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("furthermore, different functions could have the same address after being merged together")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>")));
;
diag
}
}
}
}
};Diagnostic)]
2261pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> {
2262 #[diag(
2263 "function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique"
2264 )]
2265 #[note("the address of the same function can vary between different codegen units")]
2266 #[note(
2267 "furthermore, different functions could have the same address after being merged together"
2268 )]
2269 #[note(
2270 "for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>"
2271 )]
2272 Suggestion {
2273 #[subdiagnostic]
2274 sugg: UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx>,
2275 },
2276 #[diag(
2277 "function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique"
2278 )]
2279 #[note("the address of the same function can vary between different codegen units")]
2280 #[note(
2281 "furthermore, different functions could have the same address after being merged together"
2282 )]
2283 #[note(
2284 "for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>"
2285 )]
2286 Warn,
2287}
2288
2289#[derive(const _: () =
{
impl<'a, 'tcx> rustc_errors::Subdiagnostic for
UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEq {
ne: __binding_0,
deref_left: __binding_1,
deref_right: __binding_2,
left: __binding_3,
middle: __binding_4,
right: __binding_5 } => {
let mut suggestions = Vec::new();
let __code_76 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}std::ptr::fn_addr_eq({0}",
__binding_1, __binding_0))
});
let __code_77 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(", {0}", __binding_2))
});
let __code_78 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_3, __code_76));
suggestions.push((__binding_4, __code_77));
suggestions.push((__binding_5, __code_78));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ne".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("deref_left".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("deref_right".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("refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEqWithCast {
ne: __binding_0,
deref_left: __binding_1,
deref_right: __binding_2,
fn_sig: __binding_3,
left: __binding_4,
middle: __binding_5,
right: __binding_6 } => {
let mut suggestions = Vec::new();
let __code_79 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}std::ptr::fn_addr_eq({0}",
__binding_1, __binding_0))
});
let __code_80 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(", {0}", __binding_2))
});
let __code_81 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" as {0})", __binding_3))
});
suggestions.push((__binding_4, __code_79));
suggestions.push((__binding_5, __code_80));
suggestions.push((__binding_6, __code_81));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ne".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("deref_left".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("deref_right".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("fn_sig".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2290pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> {
2291 #[multipart_suggestion(
2292 "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint",
2293 style = "verbose",
2294 applicability = "maybe-incorrect"
2295 )]
2296 FnAddrEq {
2297 ne: &'a str,
2298 deref_left: &'a str,
2299 deref_right: &'a str,
2300 #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
2301 left: Span,
2302 #[suggestion_part(code = ", {deref_right}")]
2303 middle: Span,
2304 #[suggestion_part(code = ")")]
2305 right: Span,
2306 },
2307 #[multipart_suggestion(
2308 "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint",
2309 style = "verbose",
2310 applicability = "maybe-incorrect"
2311 )]
2312 FnAddrEqWithCast {
2313 ne: &'a str,
2314 deref_left: &'a str,
2315 deref_right: &'a str,
2316 fn_sig: rustc_middle::ty::PolyFnSig<'tcx>,
2317 #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
2318 left: Span,
2319 #[suggestion_part(code = ", {deref_right}")]
2320 middle: Span,
2321 #[suggestion_part(code = " as {fn_sig})")]
2322 right: Span,
2323 },
2324}
2325
2326pub(crate) struct ImproperCTypes<'a> {
2327 pub ty: Ty<'a>,
2328 pub desc: &'a str,
2329 pub label: Span,
2330 pub help: Option<DiagMessage>,
2331 pub note: DiagMessage,
2332 pub span_note: Option<Span>,
2333}
2334
2335impl<'a> Diagnostic<'a, ()> for ImproperCTypes<'_> {
2337 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2338 let mut diag = Diag::new(
2339 dcx,
2340 level,
2341 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern` {$desc} uses type `{$ty}`, which is not FFI-safe"))msg!("`extern` {$desc} uses type `{$ty}`, which is not FFI-safe"),
2342 )
2343 .with_arg("ty", self.ty)
2344 .with_arg("desc", self.desc)
2345 .with_span_label(self.label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not FFI-safe"))msg!("not FFI-safe"));
2346 if let Some(help) = self.help {
2347 diag.help(help);
2348 }
2349 diag.note(self.note);
2350 if let Some(note) = self.span_note {
2351 diag.span_note(note, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type is defined here"))msg!("the type is defined here"));
2352 }
2353 diag
2354 }
2355}
2356
2357#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ImproperGpuKernelArg<'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 {
ImproperGpuKernelArg { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("passing type `{$ty}` to a function with \"gpu-kernel\" ABI may have unexpected behavior")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use primitive types and raw pointers to get reliable behavior")));
;
diag.arg("ty", __binding_0);
diag
}
}
}
}
};Diagnostic)]
2358#[diag("passing type `{$ty}` to a function with \"gpu-kernel\" ABI may have unexpected behavior")]
2359#[help("use primitive types and raw pointers to get reliable behavior")]
2360pub(crate) struct ImproperGpuKernelArg<'a> {
2361 pub ty: Ty<'a>,
2362}
2363
2364#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingGpuKernelExportName where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingGpuKernelExportName => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function with the \"gpu-kernel\" ABI has a mangled name")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `unsafe(no_mangle)` or `unsafe(export_name = \"<name>\")`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mangled names make it hard to find the kernel, this is usually not intended")));
;
diag
}
}
}
}
};Diagnostic)]
2365#[diag("function with the \"gpu-kernel\" ABI has a mangled name")]
2366#[help("use `unsafe(no_mangle)` or `unsafe(export_name = \"<name>\")`")]
2367#[note("mangled names make it hard to find the kernel, this is usually not intended")]
2368pub(crate) struct MissingGpuKernelExportName;
2369
2370#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
VariantSizeDifferencesDiag where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
VariantSizeDifferencesDiag { largest: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enum variant is more than three times larger ({$largest} bytes) than the next largest")));
;
diag.arg("largest", __binding_0);
diag
}
}
}
}
};Diagnostic)]
2371#[diag("enum variant is more than three times larger ({$largest} bytes) than the next largest")]
2372pub(crate) struct VariantSizeDifferencesDiag {
2373 pub largest: u64,
2374}
2375
2376#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtomicOrderingLoad where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtomicOrderingLoad => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("atomic loads cannot have `Release` or `AcqRel` ordering")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using ordering modes `Acquire`, `SeqCst` or `Relaxed`")));
;
diag
}
}
}
}
};Diagnostic)]
2377#[diag("atomic loads cannot have `Release` or `AcqRel` ordering")]
2378#[help("consider using ordering modes `Acquire`, `SeqCst` or `Relaxed`")]
2379pub(crate) struct AtomicOrderingLoad;
2380
2381#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtomicOrderingStore where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtomicOrderingStore => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("atomic stores cannot have `Acquire` or `AcqRel` ordering")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using ordering modes `Release`, `SeqCst` or `Relaxed`")));
;
diag
}
}
}
}
};Diagnostic)]
2382#[diag("atomic stores cannot have `Acquire` or `AcqRel` ordering")]
2383#[help("consider using ordering modes `Release`, `SeqCst` or `Relaxed`")]
2384pub(crate) struct AtomicOrderingStore;
2385
2386#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AtomicOrderingFence where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AtomicOrderingFence => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("memory fences cannot have `Relaxed` ordering")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`")));
;
diag
}
}
}
}
};Diagnostic)]
2387#[diag("memory fences cannot have `Relaxed` ordering")]
2388#[help("consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`")]
2389pub(crate) struct AtomicOrderingFence;
2390
2391#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidAtomicOrderingDiag where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidAtomicOrderingDiag {
method: __binding_0, fail_order_arg_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$method}`'s failure ordering may not be `Release` or `AcqRel`, since a failed `{$method}` does not result in a write")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `Acquire` or `Relaxed` failure ordering instead")));
;
diag.arg("method", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid failure ordering")));
diag
}
}
}
}
};Diagnostic)]
2392#[diag(
2393 "`{$method}`'s failure ordering may not be `Release` or `AcqRel`, since a failed `{$method}` does not result in a write"
2394)]
2395#[help("consider using `Acquire` or `Relaxed` failure ordering instead")]
2396pub(crate) struct InvalidAtomicOrderingDiag {
2397 pub method: Symbol,
2398 #[label("invalid failure ordering")]
2399 pub fail_order_arg_span: Span,
2400}
2401
2402#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedOp<'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 {
UnusedOp {
op: __binding_0, label: __binding_1, suggestion: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$op} that must be used")));
;
diag.arg("op", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$op} produces a value")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
2404#[diag("unused {$op} that must be used")]
2405pub(crate) struct UnusedOp<'a> {
2406 pub op: &'a str,
2407 #[label("the {$op} produces a value")]
2408 pub label: Span,
2409 #[subdiagnostic]
2410 pub suggestion: UnusedOpSuggestion,
2411}
2412
2413#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedOpSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnusedOpSuggestion::NormalExpr { span: __binding_0 } => {
let __code_82 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let _ = "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the resulting value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_82, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnusedOpSuggestion::BlockTailExpr {
before_span: __binding_0, after_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_83 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let _ = "))
});
let __code_84 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
});
suggestions.push((__binding_0, __code_83));
suggestions.push((__binding_1, __code_84));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the resulting value")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2414pub(crate) enum UnusedOpSuggestion {
2415 #[suggestion(
2416 "use `let _ = ...` to ignore the resulting value",
2417 style = "verbose",
2418 code = "let _ = ",
2419 applicability = "maybe-incorrect"
2420 )]
2421 NormalExpr {
2422 #[primary_span]
2423 span: Span,
2424 },
2425 #[multipart_suggestion(
2426 "use `let _ = ...` to ignore the resulting value",
2427 style = "verbose",
2428 applicability = "maybe-incorrect"
2429 )]
2430 BlockTailExpr {
2431 #[suggestion_part(code = "let _ = ")]
2432 before_span: Span,
2433 #[suggestion_part(code = ";")]
2434 after_span: Span,
2435 },
2436}
2437
2438#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedResult<'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 {
UnusedResult { ty: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused result of type `{$ty}`")));
;
diag.arg("ty", __binding_0);
diag
}
}
}
}
};Diagnostic)]
2439#[diag("unused result of type `{$ty}`")]
2440pub(crate) struct UnusedResult<'a> {
2441 pub ty: Ty<'a>,
2442}
2443
2444#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedClosure<'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 {
UnusedClosure {
count: __binding_0, pre: __binding_1, post: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$pre}{$count ->\n [one] closure\n *[other] closures\n }{$post} that must be used")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closures are lazy and do nothing unless called")));
;
diag.arg("count", __binding_0);
diag.arg("pre", __binding_1);
diag.arg("post", __binding_2);
diag
}
}
}
}
};Diagnostic)]
2447#[diag(
2448 "unused {$pre}{$count ->
2449 [one] closure
2450 *[other] closures
2451 }{$post} that must be used"
2452)]
2453#[note("closures are lazy and do nothing unless called")]
2454pub(crate) struct UnusedClosure<'a> {
2455 pub count: usize,
2456 pub pre: &'a str,
2457 pub post: &'a str,
2458}
2459
2460#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedCoroutine<'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 {
UnusedCoroutine {
count: __binding_0, pre: __binding_1, post: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$pre}{$count ->\n [one] coroutine\n *[other] coroutine\n }{$post} that must be used")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("coroutines are lazy and do nothing unless resumed")));
;
diag.arg("count", __binding_0);
diag.arg("pre", __binding_1);
diag.arg("post", __binding_2);
diag
}
}
}
}
};Diagnostic)]
2463#[diag(
2464 "unused {$pre}{$count ->
2465 [one] coroutine
2466 *[other] coroutine
2467 }{$post} that must be used"
2468)]
2469#[note("coroutines are lazy and do nothing unless resumed")]
2470pub(crate) struct UnusedCoroutine<'a> {
2471 pub count: usize,
2472 pub pre: &'a str,
2473 pub post: &'a str,
2474}
2475
2476pub(crate) struct UnusedDef<'a, 'b> {
2479 pub pre: &'a str,
2480 pub post: &'a str,
2481 pub cx: &'a LateContext<'b>,
2482 pub def_id: DefId,
2483 pub note: Option<Symbol>,
2484 pub suggestion: Option<UnusedDefSuggestion>,
2485}
2486
2487#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedDefSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnusedDefSuggestion::NormalExpr { span: __binding_0 } => {
let __code_85 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let _ = "))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the resulting value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_85, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
UnusedDefSuggestion::BlockTailExpr {
before_span: __binding_0, after_span: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_86 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let _ = "))
});
let __code_87 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(";"))
});
suggestions.push((__binding_0, __code_86));
suggestions.push((__binding_1, __code_87));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the resulting value")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2488pub(crate) enum UnusedDefSuggestion {
2489 #[suggestion(
2490 "use `let _ = ...` to ignore the resulting value",
2491 style = "verbose",
2492 code = "let _ = ",
2493 applicability = "maybe-incorrect"
2494 )]
2495 NormalExpr {
2496 #[primary_span]
2497 span: Span,
2498 },
2499 #[multipart_suggestion(
2500 "use `let _ = ...` to ignore the resulting value",
2501 style = "verbose",
2502 applicability = "maybe-incorrect"
2503 )]
2504 BlockTailExpr {
2505 #[suggestion_part(code = "let _ = ")]
2506 before_span: Span,
2507 #[suggestion_part(code = ";")]
2508 after_span: Span,
2509 },
2510}
2511
2512impl<'a> Diagnostic<'a, ()> for UnusedDef<'_, '_> {
2514 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2515 let mut diag =
2516 Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$pre}`{$def}`{$post} that must be used"))msg!("unused {$pre}`{$def}`{$post} that must be used"))
2517 .with_arg("pre", self.pre)
2518 .with_arg("post", self.post)
2519 .with_arg("def", self.cx.tcx.def_path_str(self.def_id));
2520 if let Some(note) = self.note {
2522 diag.note(note.to_string());
2523 }
2524 if let Some(sugg) = self.suggestion {
2525 diag.subdiagnostic(sugg);
2526 }
2527 diag
2528 }
2529}
2530
2531#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathStatementDrop where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathStatementDrop { sub: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path statement drops value")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
2532#[diag("path statement drops value")]
2533pub(crate) struct PathStatementDrop {
2534 #[subdiagnostic]
2535 pub sub: PathStatementDropSub,
2536}
2537
2538#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for PathStatementDropSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
PathStatementDropSub::Suggestion {
span: __binding_0, snippet: __binding_1 } => {
let __code_88 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("drop({0});",
__binding_1))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("snippet".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("use `drop` to clarify the intent")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_88, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
PathStatementDropSub::Help { 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("use `drop` to clarify the intent")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
2539pub(crate) enum PathStatementDropSub {
2540 #[suggestion(
2541 "use `drop` to clarify the intent",
2542 code = "drop({snippet});",
2543 applicability = "machine-applicable"
2544 )]
2545 Suggestion {
2546 #[primary_span]
2547 span: Span,
2548 snippet: String,
2549 },
2550 #[help("use `drop` to clarify the intent")]
2551 Help {
2552 #[primary_span]
2553 span: Span,
2554 },
2555}
2556
2557#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
PathStatementNoEffect where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PathStatementNoEffect => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path statement with no effect")));
;
diag
}
}
}
}
};Diagnostic)]
2558#[diag("path statement with no effect")]
2559pub(crate) struct PathStatementNoEffect;
2560
2561#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedDelim<'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 {
UnusedDelim {
delim: __binding_0,
item: __binding_1,
suggestion: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary {$delim} around {$item}")));
;
diag.arg("delim", __binding_0);
diag.arg("item", __binding_1);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
2562#[diag("unnecessary {$delim} around {$item}")]
2563pub(crate) struct UnusedDelim<'a> {
2564 pub delim: &'static str,
2565 pub item: &'a str,
2566 #[subdiagnostic]
2567 pub suggestion: Option<UnusedDelimSuggestion>,
2568}
2569
2570#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedDelimSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnusedDelimSuggestion {
start_span: __binding_0,
start_replace: __binding_1,
end_span: __binding_2,
end_replace: __binding_3,
delim: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_89 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
});
let __code_90 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
});
suggestions.push((__binding_0, __code_89));
suggestions.push((__binding_2, __code_90));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("start_replace".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("end_replace".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("delim".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove these {$delim}")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2571#[multipart_suggestion("remove these {$delim}", applicability = "machine-applicable")]
2572pub(crate) struct UnusedDelimSuggestion {
2573 #[suggestion_part(code = "{start_replace}")]
2574 pub start_span: Span,
2575 pub start_replace: &'static str,
2576 #[suggestion_part(code = "{end_replace}")]
2577 pub end_span: Span,
2578 pub end_replace: &'static str,
2579 pub delim: &'static str,
2580}
2581
2582#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedImportBracesDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnusedImportBracesDiag { node: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("braces around {$node} is unnecessary")));
;
diag.arg("node", __binding_0);
diag
}
}
}
}
};Diagnostic)]
2583#[diag("braces around {$node} is unnecessary")]
2584pub(crate) struct UnusedImportBracesDiag {
2585 pub node: Symbol,
2586}
2587
2588#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedAllocationDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnusedAllocationDiag => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary allocation, use `&` instead")));
;
diag
}
}
}
}
};Diagnostic)]
2589#[diag("unnecessary allocation, use `&` instead")]
2590pub(crate) struct UnusedAllocationDiag;
2591
2592#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedAllocationMutDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnusedAllocationMutDiag => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary allocation, use `&mut` instead")));
;
diag
}
}
}
}
};Diagnostic)]
2593#[diag("unnecessary allocation, use `&mut` instead")]
2594pub(crate) struct UnusedAllocationMutDiag;
2595
2596pub(crate) struct AsyncFnInTraitDiag {
2597 pub sugg: Option<Vec<(Span, String)>>,
2598}
2599
2600impl<'a> Diagnostic<'a, ()> for AsyncFnInTraitDiag {
2601 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2602 let mut diag = Diag::new(
2603 dcx,
2604 level,
2605 "use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified",
2606 );
2607 diag.note("you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future`");
2608 if let Some(sugg) = self.sugg {
2609 diag.multipart_suggestion("you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change", sugg, Applicability::MaybeIncorrect);
2610 }
2611 diag
2612 }
2613}
2614
2615#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnitBindingsDiag where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnitBindingsDiag { label: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("binding has unit type `()`")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this pattern is inferred to be the unit type `()`")));
diag
}
}
}
}
};Diagnostic)]
2616#[diag("binding has unit type `()`")]
2617pub(crate) struct UnitBindingsDiag {
2618 #[label("this pattern is inferred to be the unit type `()`")]
2619 pub label: Span,
2620}
2621
2622#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidAsmLabel where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidAsmLabel::Named { missing_precise_span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("avoid using named labels in inline assembly")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only local labels of the form `<number>:` should be used in inline asm")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information")));
;
if __binding_0 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label may be declared in the expansion of a macro")));
}
diag
}
InvalidAsmLabel::FormatArg {
missing_precise_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("avoid using named labels in inline assembly")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only local labels of the form `<number>:` should be used in inline asm")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("format arguments may expand to a non-numeric value")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information")));
;
if __binding_0 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label may be declared in the expansion of a macro")));
}
diag
}
InvalidAsmLabel::Binary {
missing_precise_span: __binding_0, span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("avoid using labels containing only the digits `0` and `1` in inline assembly")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("start numbering with `2` instead")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an LLVM bug makes these labels ambiguous with a binary literal number on x86")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://github.com/llvm/llvm-project/issues/99547> for more information")));
;
if __binding_0 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label may be declared in the expansion of a macro")));
}
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a different label that doesn't start with `0` or `1`")));
diag
}
}
}
}
};Diagnostic)]
2623pub(crate) enum InvalidAsmLabel {
2624 #[diag("avoid using named labels in inline assembly")]
2625 #[help("only local labels of the form `<number>:` should be used in inline asm")]
2626 #[note(
2627 "see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information"
2628 )]
2629 Named {
2630 #[note("the label may be declared in the expansion of a macro")]
2631 missing_precise_span: bool,
2632 },
2633 #[diag("avoid using named labels in inline assembly")]
2634 #[help("only local labels of the form `<number>:` should be used in inline asm")]
2635 #[note("format arguments may expand to a non-numeric value")]
2636 #[note(
2637 "see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information"
2638 )]
2639 FormatArg {
2640 #[note("the label may be declared in the expansion of a macro")]
2641 missing_precise_span: bool,
2642 },
2643 #[diag("avoid using labels containing only the digits `0` and `1` in inline assembly")]
2644 #[help("start numbering with `2` instead")]
2645 #[note("an LLVM bug makes these labels ambiguous with a binary literal number on x86")]
2646 #[note("see <https://github.com/llvm/llvm-project/issues/99547> for more information")]
2647 Binary {
2648 #[note("the label may be declared in the expansion of a macro")]
2649 missing_precise_span: bool,
2650 #[label("use a different label that doesn't start with `0` or `1`")]
2652 span: Span,
2653 },
2654}
2655
2656#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedCfgCargoHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedCfgCargoHelp::LintCfg {
cargo_toml_lint_cfg: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("cargo_toml_lint_cfg".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 using a Cargo feature instead")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:{$cargo_toml_lint_cfg}")),
&sub_args);
diag.help(__message);
}
UnexpectedCfgCargoHelp::LintCfgAndBuildRs {
cargo_toml_lint_cfg: __binding_0,
build_rs_println: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("cargo_toml_lint_cfg".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("build_rs_println".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("consider using a Cargo feature instead")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:{$cargo_toml_lint_cfg}")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or consider adding `{$build_rs_println}` to the top of the `build.rs`")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2657pub(crate) enum UnexpectedCfgCargoHelp {
2658 #[help("consider using a Cargo feature instead")]
2659 #[help(
2660 "or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:{$cargo_toml_lint_cfg}"
2661 )]
2662 LintCfg { cargo_toml_lint_cfg: String },
2663 #[help("consider using a Cargo feature instead")]
2664 #[help(
2665 "or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:{$cargo_toml_lint_cfg}"
2666 )]
2667 #[help("or consider adding `{$build_rs_println}` to the top of the `build.rs`")]
2668 LintCfgAndBuildRs { cargo_toml_lint_cfg: String, build_rs_println: String },
2669}
2670
2671impl UnexpectedCfgCargoHelp {
2672 fn cargo_toml_lint_cfg(unescaped: &str) -> String {
2673 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\n [lints.rust]\n unexpected_cfgs = {{ level = \"warn\", check-cfg = [\'{0}\'] }}",
unescaped))
})format!(
2674 "\n [lints.rust]\n unexpected_cfgs = {{ level = \"warn\", check-cfg = ['{unescaped}'] }}"
2675 )
2676 }
2677
2678 pub(crate) fn lint_cfg(unescaped: &str) -> Self {
2679 UnexpectedCfgCargoHelp::LintCfg {
2680 cargo_toml_lint_cfg: Self::cargo_toml_lint_cfg(unescaped),
2681 }
2682 }
2683
2684 pub(crate) fn lint_cfg_and_build_rs(unescaped: &str, escaped: &str) -> Self {
2685 UnexpectedCfgCargoHelp::LintCfgAndBuildRs {
2686 cargo_toml_lint_cfg: Self::cargo_toml_lint_cfg(unescaped),
2687 build_rs_println: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("println!(\"cargo::rustc-check-cfg={0}\");",
escaped))
})format!("println!(\"cargo::rustc-check-cfg={escaped}\");"),
2688 }
2689 }
2690}
2691
2692#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedCfgRustcHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedCfgRustcHelp { cmdline_arg: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("cmdline_arg".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("to expect this configuration use `{$cmdline_arg}`")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2693#[help("to expect this configuration use `{$cmdline_arg}`")]
2694pub(crate) struct UnexpectedCfgRustcHelp {
2695 pub cmdline_arg: String,
2696}
2697
2698impl UnexpectedCfgRustcHelp {
2699 pub(crate) fn new(unescaped: &str) -> Self {
2700 Self { cmdline_arg: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("--check-cfg={0}", unescaped))
})format!("--check-cfg={unescaped}") }
2701 }
2702}
2703
2704#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedCfgRustcMacroHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedCfgRustcMacroHelp {
macro_kind: __binding_0, macro_name: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("macro_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("macro_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("using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2705#[note(
2706 "using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate"
2707)]
2708#[help("try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg")]
2709pub(crate) struct UnexpectedCfgRustcMacroHelp {
2710 pub macro_kind: &'static str,
2711 pub macro_name: Symbol,
2712}
2713
2714#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnexpectedCfgCargoMacroHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnexpectedCfgCargoMacroHelp {
macro_kind: __binding_0,
macro_name: __binding_1,
crate_name: __binding_2 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("macro_kind".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("macro_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("crate_name".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("using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg")),
&sub_args);
diag.help(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}`")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2715#[note(
2716 "using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate"
2717)]
2718#[help("try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg")]
2719#[help(
2720 "the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}`"
2721)]
2722pub(crate) struct UnexpectedCfgCargoMacroHelp {
2723 pub macro_kind: &'static str,
2724 pub macro_name: Symbol,
2725 pub crate_name: Symbol,
2726}
2727
2728#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedCfgName where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedCfgName {
code_sugg: __binding_0,
invocation_help: __binding_1,
name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `cfg` condition name: `{$name}`")));
;
diag.arg("name", __binding_2);
diag.subdiagnostic(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2729#[diag("unexpected `cfg` condition name: `{$name}`")]
2730pub(crate) struct UnexpectedCfgName {
2731 #[subdiagnostic]
2732 pub code_sugg: unexpected_cfg_name::CodeSuggestion,
2733 #[subdiagnostic]
2734 pub invocation_help: unexpected_cfg_name::InvocationHelp,
2735
2736 pub name: Symbol,
2737}
2738
2739pub(crate) mod unexpected_cfg_name {
2740 use rustc_errors::DiagSymbolList;
2741 use rustc_macros::Subdiagnostic;
2742 use rustc_span::{Ident, Span, Symbol};
2743
2744 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CodeSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CodeSuggestion::DefineFeatures => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider defining some features in `Cargo.toml`")),
&sub_args);
diag.help(__message);
}
CodeSuggestion::VersionSyntax {
between_name_and_value: __binding_0,
after_value: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_91 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_92 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_91));
suggestions.push((__binding_1, __code_92));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is a similar config predicate: `version(\"..\")`")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
CodeSuggestion::SimilarNameAndValue {
span: __binding_0, code: __binding_1 } => {
let __code_93 =
[::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("code".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 config with a similar name and value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_93, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
CodeSuggestion::SimilarNameNoValue {
span: __binding_0, code: __binding_1 } => {
let __code_94 =
[::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("code".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 config with a similar name and no value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_94, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
CodeSuggestion::SimilarNameDifferentValues {
span: __binding_0, code: __binding_1, expected: __binding_2
} => {
let __code_95 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
if let Some(__binding_2) = __binding_2 {
__binding_2.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("code".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 config with a similar name and different values")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_95, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
CodeSuggestion::SimilarName {
span: __binding_0, code: __binding_1, expected: __binding_2
} => {
let __code_96 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
if let Some(__binding_2) = __binding_2 {
__binding_2.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("code".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 config with a similar name")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_96, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
CodeSuggestion::SimilarValues {
with_similar_values: __binding_0,
expected_names: __binding_1 } => {
for __binding_0 in __binding_0 {
__binding_0.add_to_diag(diag);
}
if let Some(__binding_1) = __binding_1 {
__binding_1.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
}
CodeSuggestion::BooleanLiteral {
span: __binding_0, literal: __binding_1 } => {
let __code_97 =
[::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("literal".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("you may have meant to use `{$literal}` (notice the capitalization). Doing so makes this predicate evaluate to `{$literal}` unconditionally")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_97, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2745 pub(crate) enum CodeSuggestion {
2746 #[help("consider defining some features in `Cargo.toml`")]
2747 DefineFeatures,
2748 #[multipart_suggestion(
2749 "there is a similar config predicate: `version(\"..\")`",
2750 applicability = "machine-applicable"
2751 )]
2752 VersionSyntax {
2753 #[suggestion_part(code = "(")]
2754 between_name_and_value: Span,
2755 #[suggestion_part(code = ")")]
2756 after_value: Span,
2757 },
2758 #[suggestion(
2759 "there is a config with a similar name and value",
2760 applicability = "maybe-incorrect",
2761 code = "{code}"
2762 )]
2763 SimilarNameAndValue {
2764 #[primary_span]
2765 span: Span,
2766 code: String,
2767 },
2768 #[suggestion(
2769 "there is a config with a similar name and no value",
2770 applicability = "maybe-incorrect",
2771 code = "{code}"
2772 )]
2773 SimilarNameNoValue {
2774 #[primary_span]
2775 span: Span,
2776 code: String,
2777 },
2778 #[suggestion(
2779 "there is a config with a similar name and different values",
2780 applicability = "maybe-incorrect",
2781 code = "{code}"
2782 )]
2783 SimilarNameDifferentValues {
2784 #[primary_span]
2785 span: Span,
2786 code: String,
2787 #[subdiagnostic]
2788 expected: Option<ExpectedValues>,
2789 },
2790 #[suggestion(
2791 "there is a config with a similar name",
2792 applicability = "maybe-incorrect",
2793 code = "{code}"
2794 )]
2795 SimilarName {
2796 #[primary_span]
2797 span: Span,
2798 code: String,
2799 #[subdiagnostic]
2800 expected: Option<ExpectedValues>,
2801 },
2802 SimilarValues {
2803 #[subdiagnostic]
2804 with_similar_values: Vec<FoundWithSimilarValue>,
2805 #[subdiagnostic]
2806 expected_names: Option<ExpectedNames>,
2807 },
2808 #[suggestion(
2809 "you may have meant to use `{$literal}` (notice the capitalization). Doing so makes this predicate evaluate to `{$literal}` unconditionally",
2810 applicability = "machine-applicable",
2811 style = "verbose",
2812 code = "{literal}"
2813 )]
2814 BooleanLiteral {
2815 #[primary_span]
2816 span: Span,
2817 literal: bool,
2818 },
2819 }
2820
2821 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectedValues {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectedValues {
best_match: __binding_0, possibilities: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("best_match".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("possibilities".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("expected values for `{$best_match}` are: {$possibilities}")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
2822 #[help("expected values for `{$best_match}` are: {$possibilities}")]
2823 pub(crate) struct ExpectedValues {
2824 pub best_match: Symbol,
2825 pub possibilities: DiagSymbolList,
2826 }
2827
2828 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FoundWithSimilarValue {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FoundWithSimilarValue { span: __binding_0, code: __binding_1
} => {
let __code_98 =
[::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("code".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("found config with similar value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_98, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2829 #[suggestion(
2830 "found config with similar value",
2831 applicability = "maybe-incorrect",
2832 code = "{code}"
2833 )]
2834 pub(crate) struct FoundWithSimilarValue {
2835 #[primary_span]
2836 pub span: Span,
2837 pub code: String,
2838 }
2839
2840 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectedNames {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectedNames {
possibilities: __binding_0, and_more: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("possibilities".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("and_more".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("expected names are: {$possibilities}{$and_more ->\n [0] {\"\"}\n *[other] {\" \"}and {$and_more} more\n }")),
&sub_args);
diag.help_once(__message);
}
}
}
}
};Subdiagnostic)]
2841 #[help_once(
2842 "expected names are: {$possibilities}{$and_more ->
2843 [0] {\"\"}
2844 *[other] {\" \"}and {$and_more} more
2845 }"
2846 )]
2847 pub(crate) struct ExpectedNames {
2848 pub possibilities: DiagSymbolList<Ident>,
2849 pub and_more: usize,
2850 }
2851
2852 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvocationHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvocationHelp::Cargo {
macro_help: __binding_0, help: __binding_1 } => {
if let Some(__binding_0) = __binding_0 {
__binding_0.add_to_diag(diag);
}
if let Some(__binding_1) = __binding_1 {
__binding_1.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration")),
&sub_args);
diag.note(__message);
}
InvocationHelp::Rustc {
macro_help: __binding_0, help: __binding_1 } => {
if let Some(__binding_0) = __binding_0 {
__binding_0.add_to_diag(diag);
}
__binding_1.add_to_diag(diag);
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
2853 pub(crate) enum InvocationHelp {
2854 #[note(
2855 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration"
2856 )]
2857 Cargo {
2858 #[subdiagnostic]
2859 macro_help: Option<super::UnexpectedCfgCargoMacroHelp>,
2860 #[subdiagnostic]
2861 help: Option<super::UnexpectedCfgCargoHelp>,
2862 },
2863 #[note(
2864 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration"
2865 )]
2866 Rustc {
2867 #[subdiagnostic]
2868 macro_help: Option<super::UnexpectedCfgRustcMacroHelp>,
2869 #[subdiagnostic]
2870 help: super::UnexpectedCfgRustcHelp,
2871 },
2872 }
2873}
2874
2875#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedCfgValue where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnexpectedCfgValue {
code_sugg: __binding_0,
invocation_help: __binding_1,
has_value: __binding_2,
value: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `cfg` condition value: {$has_value ->\n [true] `{$value}`\n *[false] (none)\n }")));
;
diag.arg("has_value", __binding_2);
diag.arg("value", __binding_3);
diag.subdiagnostic(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
2876#[diag(
2877 "unexpected `cfg` condition value: {$has_value ->
2878 [true] `{$value}`
2879 *[false] (none)
2880 }"
2881)]
2882pub(crate) struct UnexpectedCfgValue {
2883 #[subdiagnostic]
2884 pub code_sugg: unexpected_cfg_value::CodeSuggestion,
2885 #[subdiagnostic]
2886 pub invocation_help: unexpected_cfg_value::InvocationHelp,
2887
2888 pub has_value: bool,
2889 pub value: String,
2890}
2891
2892pub(crate) mod unexpected_cfg_value {
2893 use rustc_errors::DiagSymbolList;
2894 use rustc_macros::Subdiagnostic;
2895 use rustc_span::{Span, Symbol};
2896
2897 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CodeSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CodeSuggestion::ChangeValue {
expected_values: __binding_0, suggestion: __binding_1 } => {
__binding_0.add_to_diag(diag);
if let Some(__binding_1) = __binding_1 {
__binding_1.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
}
CodeSuggestion::RemoveValue {
suggestion: __binding_0, name: __binding_1 } => {
if let Some(__binding_0) = __binding_0 {
__binding_0.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("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("no expected value for `{$name}`")),
&sub_args);
diag.note(__message);
}
CodeSuggestion::RemoveCondition {
suggestion: __binding_0, name: __binding_1 } => {
__binding_0.add_to_diag(diag);
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("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("no expected values for `{$name}`")),
&sub_args);
diag.note(__message);
}
CodeSuggestion::ChangeName { suggestions: __binding_0 } => {
for __binding_0 in __binding_0 {
__binding_0.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
}
}
}
}
};Subdiagnostic)]
2898 pub(crate) enum CodeSuggestion {
2899 ChangeValue {
2900 #[subdiagnostic]
2901 expected_values: ExpectedValues,
2902 #[subdiagnostic]
2903 suggestion: Option<ChangeValueSuggestion>,
2904 },
2905 #[note("no expected value for `{$name}`")]
2906 RemoveValue {
2907 #[subdiagnostic]
2908 suggestion: Option<RemoveValueSuggestion>,
2909
2910 name: Symbol,
2911 },
2912 #[note("no expected values for `{$name}`")]
2913 RemoveCondition {
2914 #[subdiagnostic]
2915 suggestion: RemoveConditionSuggestion,
2916
2917 name: Symbol,
2918 },
2919 ChangeName {
2920 #[subdiagnostic]
2921 suggestions: Vec<ChangeNameSuggestion>,
2922 },
2923 }
2924
2925 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeValueSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ChangeValueSuggestion::SimilarName {
span: __binding_0, best_match: __binding_1 } => {
let __code_99 =
[::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("best_match".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 expected value with a similar name")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_99, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
ChangeValueSuggestion::SpecifyValue {
span: __binding_0, first_possibility: __binding_1 } => {
let __code_100 =
[::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("first_possibility".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("specify a config value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_100, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2926 pub(crate) enum ChangeValueSuggestion {
2927 #[suggestion(
2928 "there is a expected value with a similar name",
2929 code = r#""{best_match}""#,
2930 applicability = "maybe-incorrect"
2931 )]
2932 SimilarName {
2933 #[primary_span]
2934 span: Span,
2935 best_match: Symbol,
2936 },
2937 #[suggestion(
2938 "specify a config value",
2939 code = r#" = "{first_possibility}""#,
2940 applicability = "maybe-incorrect"
2941 )]
2942 SpecifyValue {
2943 #[primary_span]
2944 span: Span,
2945 first_possibility: Symbol,
2946 },
2947 }
2948
2949 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RemoveValueSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RemoveValueSuggestion { span: __binding_0 } => {
let __code_101 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the value")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_101, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2950 #[suggestion("remove the value", code = "", applicability = "maybe-incorrect")]
2951 pub(crate) struct RemoveValueSuggestion {
2952 #[primary_span]
2953 pub span: Span,
2954 }
2955
2956 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RemoveConditionSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RemoveConditionSuggestion { span: __binding_0 } => {
let __code_102 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the condition")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_102, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
2957 #[suggestion("remove the condition", code = "", applicability = "maybe-incorrect")]
2958 pub(crate) struct RemoveConditionSuggestion {
2959 #[primary_span]
2960 pub span: Span,
2961 }
2962
2963 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExpectedValues {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExpectedValues {
name: __binding_0,
have_none_possibility: __binding_1,
possibilities: __binding_2,
and_more: __binding_3 } => {
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("have_none_possibility".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("possibilities".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("and_more".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected values for `{$name}` are: {$have_none_possibility ->\n [true] {\"(none), \"}\n *[false] {\"\"}\n }{$possibilities}{$and_more ->\n [0] {\"\"}\n *[other] {\" \"}and {$and_more} more\n }")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
2964 #[note(
2965 "expected values for `{$name}` are: {$have_none_possibility ->
2966 [true] {\"(none), \"}
2967 *[false] {\"\"}
2968 }{$possibilities}{$and_more ->
2969 [0] {\"\"}
2970 *[other] {\" \"}and {$and_more} more
2971 }"
2972 )]
2973 pub(crate) struct ExpectedValues {
2974 pub name: Symbol,
2975 pub have_none_possibility: bool,
2976 pub possibilities: DiagSymbolList,
2977 pub and_more: usize,
2978 }
2979
2980 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ChangeNameSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ChangeNameSuggestion {
span: __binding_0, name: __binding_1, value: __binding_2 }
=> {
let __code_103 =
[::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("name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("value".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("`{$value}` is an expected value for `{$name}`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_103, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
2981 #[suggestion(
2982 "`{$value}` is an expected value for `{$name}`",
2983 code = "{name}",
2984 applicability = "maybe-incorrect",
2985 style = "verbose"
2986 )]
2987 pub(crate) struct ChangeNameSuggestion {
2988 #[primary_span]
2989 pub span: Span,
2990 pub name: Symbol,
2991 pub value: Symbol,
2992 }
2993
2994 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InvocationHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvocationHelp::Cargo {
help: __binding_0, macro_help: __binding_1 } => {
if let Some(__binding_0) = __binding_0 {
__binding_0.add_to_diag(diag);
}
if let Some(__binding_1) = __binding_1 {
__binding_1.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration")),
&sub_args);
diag.note(__message);
}
InvocationHelp::Rustc {
help: __binding_0, macro_help: __binding_1 } => {
if let Some(__binding_0) = __binding_0 {
__binding_0.add_to_diag(diag);
}
if let Some(__binding_1) = __binding_1 {
__binding_1.add_to_diag(diag);
}
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
2995 pub(crate) enum InvocationHelp {
2996 #[note(
2997 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration"
2998 )]
2999 Cargo {
3000 #[subdiagnostic]
3001 help: Option<CargoHelp>,
3002 #[subdiagnostic]
3003 macro_help: Option<super::UnexpectedCfgCargoMacroHelp>,
3004 },
3005 #[note(
3006 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration"
3007 )]
3008 Rustc {
3009 #[subdiagnostic]
3010 help: Option<super::UnexpectedCfgRustcHelp>,
3011 #[subdiagnostic]
3012 macro_help: Option<super::UnexpectedCfgRustcMacroHelp>,
3013 },
3014 }
3015
3016 #[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CargoHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CargoHelp::AddFeature { value: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("value".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 adding `{$value}` as a feature in `Cargo.toml`")),
&sub_args);
diag.help(__message);
}
CargoHelp::DefineFeatures => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider defining some features in `Cargo.toml`")),
&sub_args);
diag.help(__message);
}
CargoHelp::Other(__binding_0) => {
__binding_0.add_to_diag(diag);
let mut sub_args = rustc_errors::DiagArgMap::default();
}
}
}
}
};Subdiagnostic)]
3017 pub(crate) enum CargoHelp {
3018 #[help("consider adding `{$value}` as a feature in `Cargo.toml`")]
3019 AddFeature {
3020 value: Symbol,
3021 },
3022 #[help("consider defining some features in `Cargo.toml`")]
3023 DefineFeatures,
3024 Other(#[subdiagnostic] super::UnexpectedCfgCargoHelp),
3025 }
3026}
3027
3028#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IllFormedAttributeInput where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IllFormedAttributeInput {
num_suggestions: __binding_0,
suggestions: __binding_1,
has_docs: __binding_2,
docs: __binding_3,
help: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$num_suggestions ->\n [1] attribute must be of the form {$suggestions}\n *[other] valid forms for the attribute are {$suggestions}\n }")));
;
diag.arg("num_suggestions", __binding_0);
diag.arg("suggestions", __binding_1);
diag.arg("docs", __binding_3);
if __binding_2 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <{$docs}>")));
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
diag
}
}
}
}
};Diagnostic)]
3030#[diag(
3031 "{$num_suggestions ->
3032 [1] attribute must be of the form {$suggestions}
3033 *[other] valid forms for the attribute are {$suggestions}
3034 }"
3035)]
3036pub(crate) struct IllFormedAttributeInput {
3037 pub num_suggestions: usize,
3038 pub suggestions: DiagArgValue,
3039 #[note("for more information, visit <{$docs}>")]
3040 pub has_docs: bool,
3041 pub docs: &'static str,
3042 #[subdiagnostic]
3043 pub help: Option<IllFormedAttributeInputHelp>,
3044}
3045
3046#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for IllFormedAttributeInputHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
IllFormedAttributeInputHelp { lint: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("lint".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("if you meant to silence a warning, consider using #![allow({$lint})] or #![expect({$lint})]")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
3047#[help(
3048 "if you meant to silence a warning, consider using #![allow({$lint})] or #![expect({$lint})]"
3049)]
3050pub(crate) struct IllFormedAttributeInputHelp {
3051 pub lint: String,
3052}
3053
3054#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
RefOfMutStatic<'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 {
RefOfMutStatic {
span: __binding_0,
sugg: __binding_1,
shared_label: __binding_2,
shared_note: __binding_3,
mut_note: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("creating a {$shared_label}reference to mutable static")));
;
diag.arg("shared_label", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$shared_label}reference to mutable static")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
if __binding_3 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives")));
}
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives")));
}
diag
}
}
}
}
};Diagnostic)]
3055#[diag("creating a {$shared_label}reference to mutable static")]
3056pub(crate) struct RefOfMutStatic<'a> {
3057 #[label("{$shared_label}reference to mutable static")]
3058 pub span: Span,
3059 #[subdiagnostic]
3060 pub sugg: Option<MutRefSugg>,
3061 pub shared_label: &'a str,
3062 #[note(
3063 "shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives"
3064 )]
3065 pub shared_note: bool,
3066 #[note(
3067 "mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives"
3068 )]
3069 pub mut_note: bool,
3070}
3071
3072#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MutRefSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MutRefSugg::Shared { span: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_104 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&raw const "))
});
suggestions.push((__binding_0, __code_104));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `&raw const` instead to create a raw pointer")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
MutRefSugg::Mut { span: __binding_0 } => {
let mut suggestions = Vec::new();
let __code_105 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("&raw mut "))
});
suggestions.push((__binding_0, __code_105));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `&raw mut` instead to create a raw pointer")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
3073pub(crate) enum MutRefSugg {
3074 #[multipart_suggestion(
3075 "use `&raw const` instead to create a raw pointer",
3076 style = "verbose",
3077 applicability = "maybe-incorrect"
3078 )]
3079 Shared {
3080 #[suggestion_part(code = "&raw const ")]
3081 span: Span,
3082 },
3083 #[multipart_suggestion(
3084 "use `&raw mut` instead to create a raw pointer",
3085 style = "verbose",
3086 applicability = "maybe-incorrect"
3087 )]
3088 Mut {
3089 #[suggestion_part(code = "&raw mut ")]
3090 span: Span,
3091 },
3092}
3093
3094#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnqualifiedLocalImportsDiag where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnqualifiedLocalImportsDiag => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`use` of a local item without leading `self::`, `super::`, or `crate::`")));
;
diag
}
}
}
}
};Diagnostic)]
3095#[diag("`use` of a local item without leading `self::`, `super::`, or `crate::`")]
3096pub(crate) struct UnqualifiedLocalImportsDiag;
3097
3098#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionCastsAsIntegerDiag<'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 {
FunctionCastsAsIntegerDiag { sugg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("direct cast of function item into an integer")));
;
diag.subdiagnostic(__binding_0);
diag
}
}
}
}
};Diagnostic)]
3099#[diag("direct cast of function item into an integer")]
3100pub(crate) struct FunctionCastsAsIntegerDiag<'tcx> {
3101 #[subdiagnostic]
3102 pub(crate) sugg: FunctionCastsAsIntegerSugg<'tcx>,
3103}
3104
3105#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for
FunctionCastsAsIntegerSugg<'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FunctionCastsAsIntegerSugg {
suggestion: __binding_0, cast_to_ty: __binding_1 } => {
let __code_106 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" as *const ()"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("cast_to_ty".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("first cast to a pointer `as *const ()`")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_106, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
3106#[suggestion(
3107 "first cast to a pointer `as *const ()`",
3108 code = " as *const ()",
3109 applicability = "machine-applicable",
3110 style = "verbose"
3111)]
3112pub(crate) struct FunctionCastsAsIntegerSugg<'tcx> {
3113 #[primary_span]
3114 pub suggestion: Span,
3115 pub cast_to_ty: Ty<'tcx>,
3116}
3117
3118#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MismatchedLifetimeSyntaxes {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"MismatchedLifetimeSyntaxes", "inputs", &self.inputs, "outputs",
&self.outputs, "suggestions", &&self.suggestions)
}
}Debug)]
3119pub(crate) struct MismatchedLifetimeSyntaxes {
3120 pub inputs: LifetimeSyntaxCategories<Vec<Span>>,
3121 pub outputs: LifetimeSyntaxCategories<Vec<Span>>,
3122
3123 pub suggestions: Vec<MismatchedLifetimeSyntaxesSuggestion>,
3124}
3125
3126impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MismatchedLifetimeSyntaxes {
3127 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
3128 let counts = self.inputs.len() + self.outputs.len();
3129 let message = match counts {
3130 LifetimeSyntaxCategories { hidden: 0, elided: 0, named: 0 } => {
3131 {
::core::panicking::panic_fmt(format_args!("No lifetime mismatch detected"));
}panic!("No lifetime mismatch detected")
3132 }
3133
3134 LifetimeSyntaxCategories { hidden: _, elided: _, named: 0 } => {
3135 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hiding a lifetime that's elided elsewhere is confusing"))msg!("hiding a lifetime that's elided elsewhere is confusing")
3136 }
3137
3138 LifetimeSyntaxCategories { hidden: _, elided: 0, named: _ } => {
3139 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hiding a lifetime that's named elsewhere is confusing"))msg!("hiding a lifetime that's named elsewhere is confusing")
3140 }
3141
3142 LifetimeSyntaxCategories { hidden: 0, elided: _, named: _ } => {
3143 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("eliding a lifetime that's named elsewhere is confusing"))msg!("eliding a lifetime that's named elsewhere is confusing")
3144 }
3145
3146 LifetimeSyntaxCategories { hidden: _, elided: _, named: _ } => {
3147 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hiding or eliding a lifetime that's named elsewhere is confusing"))msg!("hiding or eliding a lifetime that's named elsewhere is confusing")
3148 }
3149 };
3150 let mut diag = Diag::new(dcx, level, message);
3151
3152 for s in self.inputs.hidden {
3153 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is hidden here"))msg!("the lifetime is hidden here"));
3154 }
3155 for s in self.inputs.elided {
3156 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is elided here"))msg!("the lifetime is elided here"));
3157 }
3158 for s in self.inputs.named {
3159 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is named here"))msg!("the lifetime is named here"));
3160 }
3161
3162 let mut hidden_output_counts: FxIndexMap<Span, usize> = FxIndexMap::default();
3163 for s in self.outputs.hidden {
3164 *hidden_output_counts.entry(s).or_insert(0) += 1;
3165 }
3166 for (span, count) in hidden_output_counts {
3167 let label = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same {$count ->\n [one] lifetime\n *[other] lifetimes\n } {$count ->\n [one] is\n *[other] are\n } hidden here"))msg!(
3168 "the same {$count ->
3169 [one] lifetime
3170 *[other] lifetimes
3171 } {$count ->
3172 [one] is
3173 *[other] are
3174 } hidden here"
3175 )
3176 .arg("count", count)
3177 .format();
3178 diag.span_label(span, label);
3179 }
3180 for s in self.outputs.elided {
3181 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same lifetime is elided here"))msg!("the same lifetime is elided here"));
3182 }
3183 for s in self.outputs.named {
3184 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same lifetime is named here"))msg!("the same lifetime is named here"));
3185 }
3186
3187 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same lifetime is referred to in inconsistent ways, making the signature confusing"))msg!(
3188 "the same lifetime is referred to in inconsistent ways, making the signature confusing"
3189 ));
3190
3191 let mut suggestions = self.suggestions.into_iter();
3192 if let Some(s) = suggestions.next() {
3193 diag.subdiagnostic(s);
3194
3195 for mut s in suggestions {
3196 s.make_optional_alternative();
3197 diag.subdiagnostic(s);
3198 }
3199 }
3200 diag
3201 }
3202}
3203
3204#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MismatchedLifetimeSyntaxesSuggestion {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
MismatchedLifetimeSyntaxesSuggestion::Implicit {
suggestions: __self_0, optional_alternative: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Implicit", "suggestions", __self_0, "optional_alternative",
&__self_1),
MismatchedLifetimeSyntaxesSuggestion::Mixed {
implicit_suggestions: __self_0,
explicit_anonymous_suggestions: __self_1,
optional_alternative: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f, "Mixed",
"implicit_suggestions", __self_0,
"explicit_anonymous_suggestions", __self_1,
"optional_alternative", &__self_2),
MismatchedLifetimeSyntaxesSuggestion::Explicit {
lifetime_name: __self_0,
suggestions: __self_1,
optional_alternative: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f,
"Explicit", "lifetime_name", __self_0, "suggestions",
__self_1, "optional_alternative", &__self_2),
}
}
}Debug)]
3205pub(crate) enum MismatchedLifetimeSyntaxesSuggestion {
3206 Implicit {
3207 suggestions: Vec<Span>,
3208 optional_alternative: bool,
3209 },
3210
3211 Mixed {
3212 implicit_suggestions: Vec<Span>,
3213 explicit_anonymous_suggestions: Vec<(Span, String)>,
3214 optional_alternative: bool,
3215 },
3216
3217 Explicit {
3218 lifetime_name: String,
3219 suggestions: Vec<(Span, String)>,
3220 optional_alternative: bool,
3221 },
3222}
3223
3224impl MismatchedLifetimeSyntaxesSuggestion {
3225 fn make_optional_alternative(&mut self) {
3226 use MismatchedLifetimeSyntaxesSuggestion::*;
3227
3228 let optional_alternative = match self {
3229 Implicit { optional_alternative, .. }
3230 | Mixed { optional_alternative, .. }
3231 | Explicit { optional_alternative, .. } => optional_alternative,
3232 };
3233
3234 *optional_alternative = true;
3235 }
3236}
3237
3238impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
3239 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
3240 use MismatchedLifetimeSyntaxesSuggestion::*;
3241
3242 let style = |optional_alternative| {
3243 if optional_alternative {
3244 SuggestionStyle::CompletelyHidden
3245 } else {
3246 SuggestionStyle::ShowAlways
3247 }
3248 };
3249
3250 let applicability = |optional_alternative| {
3251 if optional_alternative {
3254 Applicability::MaybeIncorrect
3255 } else {
3256 Applicability::MachineApplicable
3257 }
3258 };
3259
3260 match self {
3261 Implicit { suggestions, optional_alternative } => {
3262 let suggestions = suggestions.into_iter().map(|s| (s, String::new())).collect();
3263 diag.multipart_suggestion_with_style(
3264 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the lifetime name from references"))msg!("remove the lifetime name from references"),
3265 suggestions,
3266 applicability(optional_alternative),
3267 style(optional_alternative),
3268 );
3269 }
3270
3271 Mixed {
3272 implicit_suggestions,
3273 explicit_anonymous_suggestions,
3274 optional_alternative,
3275 } => {
3276 let message = if implicit_suggestions.is_empty() {
3277 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `'_` for type paths"))msg!("use `'_` for type paths")
3278 } else {
3279 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the lifetime name from references and use `'_` for type paths"))msg!("remove the lifetime name from references and use `'_` for type paths")
3280 };
3281
3282 let implicit_suggestions =
3283 implicit_suggestions.into_iter().map(|s| (s, String::new()));
3284
3285 let suggestions =
3286 implicit_suggestions.chain(explicit_anonymous_suggestions).collect();
3287
3288 diag.multipart_suggestion_with_style(
3289 message,
3290 suggestions,
3291 applicability(optional_alternative),
3292 style(optional_alternative),
3293 );
3294 }
3295
3296 Explicit { lifetime_name, suggestions, optional_alternative } => {
3297 let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consistently use `{$lifetime_name}`"))msg!("consistently use `{$lifetime_name}`")
3298 .arg("lifetime_name", lifetime_name)
3299 .format();
3300 diag.multipart_suggestion_with_style(
3301 msg,
3302 suggestions,
3303 applicability(optional_alternative),
3304 style(optional_alternative),
3305 );
3306 }
3307 }
3308 }
3309}
3310
3311#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EmptyAttributeList where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EmptyAttributeList {
attr_span: __binding_0,
attr_path: __binding_1,
valid_without_list: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused attribute")));
let __code_107 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$valid_without_list ->\n [true] using `{$attr_path}` with an empty list is equivalent to not using a list at all\n *[other] using `{$attr_path}` with an empty list has no effect\n }")));
;
diag.arg("attr_path", __binding_1);
diag.arg("valid_without_list", __binding_2);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$valid_without_list ->\n [true] remove these parentheses\n *[other] remove this attribute\n }")),
__code_107, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
3312#[diag("unused attribute")]
3313#[note(
3314 "{$valid_without_list ->
3315 [true] using `{$attr_path}` with an empty list is equivalent to not using a list at all
3316 *[other] using `{$attr_path}` with an empty list has no effect
3317 }"
3318)]
3319pub(crate) struct EmptyAttributeList {
3320 #[suggestion(
3321 "{$valid_without_list ->
3322 [true] remove these parentheses
3323 *[other] remove this attribute
3324 }",
3325 code = "",
3326 applicability = "machine-applicable"
3327 )]
3328 pub attr_span: Span,
3329 pub attr_path: String,
3330 pub valid_without_list: bool,
3331}
3332
3333#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidTargetLint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidTargetLint {
name: __binding_0,
target: __binding_1,
applied: __binding_2,
only: __binding_3,
attr_span: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}]` attribute cannot be used on {$target}")));
let __code_108 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
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.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[{$name}]` can {$only}be applied to {$applied}")));
;
diag.arg("name", __binding_0);
diag.arg("target", __binding_1);
diag.arg("applied", __binding_2);
diag.arg("only", __binding_3);
diag.span_suggestions_with_style(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the attribute")),
__code_108, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::CompletelyHidden);
diag
}
}
}
}
};Diagnostic)]
3334#[diag("`#[{$name}]` attribute cannot be used on {$target}")]
3335#[warning(
3336 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3337)]
3338#[help("`#[{$name}]` can {$only}be applied to {$applied}")]
3339pub(crate) struct InvalidTargetLint {
3340 pub name: String,
3341 pub target: &'static str,
3342 pub applied: DiagArgValue,
3343 pub only: &'static str,
3344 #[suggestion(
3345 "remove the attribute",
3346 code = "",
3347 applicability = "machine-applicable",
3348 style = "tool-only"
3349 )]
3350 pub attr_span: Span,
3351}
3352
3353#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidAttrStyle where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidAttrStyle {
name: __binding_0,
is_used_as_inner: __binding_1,
target_span: __binding_2,
target: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_used_as_inner ->\n [false] crate-level attribute should be an inner attribute: add an exclamation mark: `#![{$name}]`\n *[other] the `#![{$name}]` attribute can only be used at the crate root\n }")));
;
diag.arg("name", __binding_0);
diag.arg("is_used_as_inner", __binding_1);
diag.arg("target", __binding_3);
if let Some(__binding_2) = __binding_2 {
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this attribute does not have an `!`, which means it is applied to this {$target}")));
}
diag
}
}
}
}
};Diagnostic)]
3354#[diag(
3355 "{$is_used_as_inner ->
3356 [false] crate-level attribute should be an inner attribute: add an exclamation mark: `#![{$name}]`
3357 *[other] the `#![{$name}]` attribute can only be used at the crate root
3358 }"
3359)]
3360pub(crate) struct InvalidAttrStyle {
3361 pub name: String,
3362 pub is_used_as_inner: bool,
3363 #[note("this attribute does not have an `!`, which means it is applied to this {$target}")]
3364 pub target_span: Option<Span>,
3365 pub target: &'static str,
3366}
3367
3368#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnusedDuplicate where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnusedDuplicate {
this: __binding_0, other: __binding_1, warning: __binding_2
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused attribute")));
let __code_109 =
[::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_109, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.span_note(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("attribute also specified here")));
if __binding_2 {
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)]
3369#[diag("unused attribute")]
3370pub(crate) struct UnusedDuplicate {
3371 #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
3372 pub this: Span,
3373 #[note("attribute also specified here")]
3374 pub other: Span,
3375 #[warning(
3376 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3377 )]
3378 pub warning: bool,
3379}
3380
3381#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MalformedDoc
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalformedDoc => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("malformed `doc` attribute input")));
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)]
3382#[diag("malformed `doc` attribute input")]
3383#[warning(
3384 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3385)]
3386pub(crate) struct MalformedDoc;
3387
3388#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for ExpectedNoArgs
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedNoArgs => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("didn't expect any arguments here")));
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)]
3389#[diag("didn't expect any arguments here")]
3390#[warning(
3391 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3392)]
3393pub(crate) struct ExpectedNoArgs;
3394
3395#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ExpectedNameValue where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ExpectedNameValue => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected this to be of the form `... = \"...\"`")));
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)]
3396#[diag("expected this to be of the form `... = \"...\"`")]
3397#[warning(
3398 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3399)]
3400pub(crate) struct ExpectedNameValue;
3401
3402#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeAttrOutsideUnsafeLint where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeAttrOutsideUnsafeLint {
span: __binding_0, suggestion: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe attribute used without unsafe")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of unsafe attribute")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
3403#[diag("unsafe attribute used without unsafe")]
3404pub(crate) struct UnsafeAttrOutsideUnsafeLint {
3405 #[label("usage of unsafe attribute")]
3406 pub span: Span,
3407 #[subdiagnostic]
3408 pub suggestion: Option<UnsafeAttrOutsideUnsafeSuggestion>,
3409}
3410
3411#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnsafeAttrOutsideUnsafeSuggestion
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnsafeAttrOutsideUnsafeSuggestion {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_110 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe("))
});
let __code_111 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_110));
suggestions.push((__binding_1, __code_111));
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)]
3412#[multipart_suggestion("wrap the attribute in `unsafe(...)`", applicability = "machine-applicable")]
3413pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
3414 #[suggestion_part(code = "unsafe(")]
3415 pub left: Span,
3416 #[suggestion_part(code = ")")]
3417 pub right: Span,
3418}
3419
3420#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocAliasDuplicated where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocAliasDuplicated { first_defn: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("doc alias is duplicated")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first defined here")));
diag
}
}
}
}
};Diagnostic)]
3421#[diag("doc alias is duplicated")]
3422pub(crate) struct DocAliasDuplicated {
3423 #[label("first defined here")]
3424 pub first_defn: Span,
3425}
3426
3427#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocAutoCfgExpectsHideOrShow where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocAutoCfgExpectsHideOrShow => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]`")));
;
diag
}
}
}
}
};Diagnostic)]
3428#[diag("only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]`")]
3429pub(crate) struct DocAutoCfgExpectsHideOrShow;
3430
3431#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AmbiguousDeriveHelpers where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AmbiguousDeriveHelpers => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there exists a built-in attribute with the same name")));
;
diag
}
}
}
}
};Diagnostic)]
3432#[diag("there exists a built-in attribute with the same name")]
3433pub(crate) struct AmbiguousDeriveHelpers;
3434
3435#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocAutoCfgHideShowUnexpectedItem where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocAutoCfgHideShowUnexpectedItem { attr_name: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#![doc(auto_cfg({$attr_name}(...)))]` only accepts identifiers or key/value items")));
;
diag.arg("attr_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
3436#[diag("`#![doc(auto_cfg({$attr_name}(...)))]` only accepts identifiers or key/value items")]
3437pub(crate) struct DocAutoCfgHideShowUnexpectedItem {
3438 pub attr_name: Symbol,
3439}
3440
3441#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocAutoCfgHideShowExpectsList where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocAutoCfgHideShowExpectsList { attr_name: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#![doc(auto_cfg({$attr_name}(...)))]` expects a list of items")));
;
diag.arg("attr_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
3442#[diag("`#![doc(auto_cfg({$attr_name}(...)))]` expects a list of items")]
3443pub(crate) struct DocAutoCfgHideShowExpectsList {
3444 pub attr_name: Symbol,
3445}
3446
3447#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DocInvalid
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocInvalid => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `doc` attribute")));
;
diag
}
}
}
}
};Diagnostic)]
3448#[diag("invalid `doc` attribute")]
3449pub(crate) struct DocInvalid;
3450
3451#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocUnknownInclude where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocUnknownInclude {
inner: __binding_0, value: __binding_1, sugg: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `doc` attribute `include`")));
let __code_112 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#{0}[doc = include_str!(\"{1}\")]",
__binding_0, __binding_1))
})].into_iter();
;
diag.arg("inner", __binding_0);
diag.arg("value", __binding_1);
diag.span_suggestions_with_style(__binding_2.0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `doc = include_str!` instead")),
__code_112, __binding_2.1,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
3452#[diag("unknown `doc` attribute `include`")]
3453pub(crate) struct DocUnknownInclude {
3454 pub inner: &'static str,
3455 pub value: Symbol,
3456 #[suggestion(
3457 "use `doc = include_str!` instead",
3458 code = "#{inner}[doc = include_str!(\"{value}\")]"
3459 )]
3460 pub sugg: (Span, Applicability),
3461}
3462
3463#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocUnknownSpotlight where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocUnknownSpotlight { sugg_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `doc` attribute `spotlight`")));
let __code_113 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("notable_trait"))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`doc(spotlight)` was renamed to `doc(notable_trait)`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`doc(spotlight)` is now a no-op")));
;
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `notable_trait` instead")),
__code_113, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
3464#[diag("unknown `doc` attribute `spotlight`")]
3465#[note("`doc(spotlight)` was renamed to `doc(notable_trait)`")]
3466#[note("`doc(spotlight)` is now a no-op")]
3467pub(crate) struct DocUnknownSpotlight {
3468 #[suggestion(
3469 "use `notable_trait` instead",
3470 style = "short",
3471 applicability = "machine-applicable",
3472 code = "notable_trait"
3473 )]
3474 pub sugg_span: Span,
3475}
3476
3477#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocUnknownPasses where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocUnknownPasses { name: __binding_0, note_span: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `doc` attribute `{$name}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`doc` attribute `{$name}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`doc({$name})` is now a no-op")));
;
diag.arg("name", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no longer functions")));
diag
}
}
}
}
};Diagnostic)]
3478#[diag("unknown `doc` attribute `{$name}`")]
3479#[note(
3480 "`doc` attribute `{$name}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>"
3481)]
3482#[note("`doc({$name})` is now a no-op")]
3483pub(crate) struct DocUnknownPasses {
3484 pub name: Symbol,
3485 #[label("no longer functions")]
3486 pub note_span: Span,
3487}
3488
3489#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocUnknownPlugins where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocUnknownPlugins { label_span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `doc` attribute `plugins`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`doc` attribute `plugins` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136> and CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`doc(plugins)` is now a no-op")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no longer functions")));
diag
}
}
}
}
};Diagnostic)]
3490#[diag("unknown `doc` attribute `plugins`")]
3491#[note(
3492 "`doc` attribute `plugins` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136> and CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>"
3493)]
3494#[note("`doc(plugins)` is now a no-op")]
3495pub(crate) struct DocUnknownPlugins {
3496 #[label("no longer functions")]
3497 pub label_span: Span,
3498}
3499
3500#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DocUnknownAny
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocUnknownAny { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `doc` attribute `{$name}`")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
3501#[diag("unknown `doc` attribute `{$name}`")]
3502pub(crate) struct DocUnknownAny {
3503 pub name: Symbol,
3504}
3505
3506#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocAutoCfgWrongLiteral where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocAutoCfgWrongLiteral => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected boolean for `#[doc(auto_cfg = ...)]`")));
;
diag
}
}
}
}
};Diagnostic)]
3507#[diag("expected boolean for `#[doc(auto_cfg = ...)]`")]
3508pub(crate) struct DocAutoCfgWrongLiteral;
3509
3510#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DocTestTakesList where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocTestTakesList => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[doc(test(...)]` takes a list of attributes")));
;
diag
}
}
}
}
};Diagnostic)]
3511#[diag("`#[doc(test(...)]` takes a list of attributes")]
3512pub(crate) struct DocTestTakesList;
3513
3514#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DocTestUnknown
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocTestUnknown { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown `doc(test)` attribute `{$name}`")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
3515#[diag("unknown `doc(test)` attribute `{$name}`")]
3516pub(crate) struct DocTestUnknown {
3517 pub name: Symbol,
3518}
3519
3520#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for DocTestLiteral
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DocTestLiteral => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#![doc(test(...)]` does not take a literal")));
;
diag
}
}
}
}
};Diagnostic)]
3521#[diag("`#![doc(test(...)]` does not take a literal")]
3522pub(crate) struct DocTestLiteral;
3523
3524#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AttrCrateLevelOnly where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AttrCrateLevelOnly => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this attribute can only be applied at the crate level")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information")));
;
diag
}
}
}
}
};Diagnostic)]
3525#[diag("this attribute can only be applied at the crate level")]
3526#[note(
3527 "read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information"
3528)]
3529pub(crate) struct AttrCrateLevelOnly;
3530
3531#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DoNotRecommendDoesNotExpectArgs where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DoNotRecommendDoesNotExpectArgs => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[diagnostic::do_not_recommend]` does not expect any arguments")));
;
diag
}
}
}
}
};Diagnostic)]
3532#[diag("`#[diagnostic::do_not_recommend]` does not expect any arguments")]
3533pub(crate) struct DoNotRecommendDoesNotExpectArgs;
3534
3535#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownCrateTypes where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownCrateTypes { sugg: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid `crate_type` value")));
;
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
3536#[diag("invalid `crate_type` value")]
3537pub(crate) struct UnknownCrateTypes {
3538 #[subdiagnostic]
3539 pub sugg: Option<UnknownCrateTypesSuggestion>,
3540}
3541
3542#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnknownCrateTypesSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnknownCrateTypesSuggestion {
span: __binding_0, snippet: __binding_1 } => {
let __code_114 =
[::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("snippet".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("did you mean")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_114, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
3543#[suggestion("did you mean", code = r#""{snippet}""#, applicability = "maybe-incorrect")]
3544pub(crate) struct UnknownCrateTypesSuggestion {
3545 #[primary_span]
3546 pub span: Span,
3547 pub snippet: Symbol,
3548}
3549
3550#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DisallowedPositionalArgument where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DisallowedPositionalArgument => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("positional format arguments are not allowed here")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only named format arguments with the name of one of the generic types are allowed in this context")));
;
diag
}
}
}
}
};Diagnostic)]
3551#[diag("positional format arguments are not allowed here")]
3552#[help(
3553 "only named format arguments with the name of one of the generic types are allowed in this context"
3554)]
3555pub(crate) struct DisallowedPositionalArgument;
3556
3557#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DisallowedPlaceholder where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DisallowedPlaceholder => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("format arguments are not allowed here")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing this format argument")));
;
diag
}
}
}
}
};Diagnostic)]
3558#[diag("format arguments are not allowed here")]
3559#[help("consider removing this format argument")]
3560pub(crate) struct DisallowedPlaceholder;
3561
3562#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidFormatSpecifier where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidFormatSpecifier => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid format specifier")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no format specifier are supported in this position")));
;
diag
}
}
}
}
};Diagnostic)]
3563#[diag("invalid format specifier")]
3564#[help("no format specifier are supported in this position")]
3565pub(crate) struct InvalidFormatSpecifier;
3566
3567#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
WrappedParserError<'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 {
WrappedParserError {
description: __binding_0,
span: __binding_1,
label: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$description}")));
;
diag.arg("description", __binding_0);
diag.arg("label", __binding_2);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$label}")));
diag
}
}
}
}
};Diagnostic)]
3568#[diag("{$description}")]
3569pub(crate) struct WrappedParserError<'a> {
3570 pub description: &'a str,
3571 #[label("{$label}")]
3572 pub span: Span,
3573 pub label: &'a str,
3574}
3575
3576#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IgnoredDiagnosticOption where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IgnoredDiagnosticOption {
option_name: __binding_0,
first_span: __binding_1,
later_span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$option_name}` is ignored due to previous definition of `{$option_name}`")));
;
diag.arg("option_name", __binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$option_name}` is first declared here")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$option_name}` is later redundantly declared here")));
diag
}
}
}
}
};Diagnostic)]
3577#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")]
3578pub(crate) struct IgnoredDiagnosticOption {
3579 pub option_name: Symbol,
3580 #[label("`{$option_name}` is first declared here")]
3581 pub first_span: Span,
3582 #[label("`{$option_name}` is later redundantly declared here")]
3583 pub later_span: Span,
3584}
3585
3586#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingOptionsForDiagnosticAttribute where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingOptionsForDiagnosticAttribute {
attribute: __binding_0, options: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing options for `{$attribute}` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$options}")));
;
diag.arg("attribute", __binding_0);
diag.arg("options", __binding_1);
diag
}
}
}
}
};Diagnostic)]
3587#[diag("missing options for `{$attribute}` attribute")]
3588#[help("{$options}")]
3589pub(crate) struct MissingOptionsForDiagnosticAttribute {
3590 pub attribute: &'static str,
3591 pub options: &'static str,
3592}
3593
3594#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EqInternalMethodImplemented where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
EqInternalMethodImplemented => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this method was used to add checks to the `Eq` derive macro")));
;
diag
}
}
}
}
};Diagnostic)]
3595#[diag("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")]
3596#[note("this method was used to add checks to the `Eq` derive macro")]
3597pub(crate) struct EqInternalMethodImplemented;
3598
3599#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NonMetaItemDiagnosticAttribute where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonMetaItemDiagnosticAttribute => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a literal or missing delimiter")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma")));
;
diag
}
}
}
}
};Diagnostic)]
3600#[diag("expected a literal or missing delimiter")]
3601#[help(
3602 "only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
3603)]
3604pub(crate) struct NonMetaItemDiagnosticAttribute;
3605
3606#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MalFormedDiagnosticAttributeLint where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalFormedDiagnosticAttributeLint {
attribute: __binding_0,
options: __binding_1,
span: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("malformed `{$attribute}` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$options}")));
;
diag.arg("attribute", __binding_0);
diag.arg("options", __binding_1);
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid option found here")));
diag
}
}
}
}
};Diagnostic)]
3607#[diag("malformed `{$attribute}` attribute")]
3608#[help("{$options}")]
3609pub(crate) struct MalFormedDiagnosticAttributeLint {
3610 pub attribute: &'static str,
3611 pub options: &'static str,
3612 #[label("invalid option found here")]
3613 pub span: Span,
3614}