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 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)]
1167pub(crate) enum NonBindingLet {
1168 #[diag("non-binding let on a synchronization lock")]
1169 SyncLock {
1170 #[label("this lock is not assigned to a binding and is immediately dropped")]
1171 pat: Span,
1172 #[subdiagnostic]
1173 sub: NonBindingLetSub,
1174 },
1175 #[diag("non-binding let on a type that has a destructor")]
1176 DropType {
1177 #[subdiagnostic]
1178 sub: NonBindingLetSub,
1179 },
1180}
1181
1182pub(crate) struct NonBindingLetSub {
1183 pub suggestion: Span,
1184 pub drop_fn_start_end: Option<(Span, Span)>,
1185 pub is_assign_desugar: bool,
1186}
1187
1188impl Subdiagnostic for NonBindingLetSub {
1189 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1190 let can_suggest_binding = self.drop_fn_start_end.is_some() || !self.is_assign_desugar;
1191
1192 if can_suggest_binding {
1193 let prefix = if self.is_assign_desugar { "let " } else { "" };
1194 diag.span_suggestion_verbose(
1195 self.suggestion,
1196 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider binding to an unused variable to avoid immediately dropping the value"))msg!(
1197 "consider binding to an unused variable to avoid immediately dropping the value"
1198 ),
1199 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}_unused", prefix))
})format!("{prefix}_unused"),
1200 Applicability::MachineApplicable,
1201 );
1202 } else {
1203 diag.span_help(
1204 self.suggestion,
1205 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider binding to an unused variable to avoid immediately dropping the value"))msg!(
1206 "consider binding to an unused variable to avoid immediately dropping the value"
1207 ),
1208 );
1209 }
1210 if let Some(drop_fn_start_end) = self.drop_fn_start_end {
1211 diag.multipart_suggestion(
1212 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider immediately dropping the value"))msg!("consider immediately dropping the value"),
1213 ::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![
1214 (drop_fn_start_end.0, "drop(".to_string()),
1215 (drop_fn_start_end.1, ")".to_string()),
1216 ],
1217 Applicability::MachineApplicable,
1218 );
1219 } else {
1220 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider immediately dropping the value using `drop(..)` after the `let` statement"))msg!(
1221 "consider immediately dropping the value using `drop(..)` after the `let` statement"
1222 ));
1223 }
1224 }
1225}
1226
1227#[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)]
1229#[diag("{$lint_level}({$lint_source}) incompatible with previous forbid")]
1230pub(crate) struct OverruledAttributeLint<'a> {
1231 #[label("overruled by previous forbid")]
1232 pub overruled: Span,
1233 pub lint_level: &'a str,
1234 pub lint_source: Symbol,
1235 #[subdiagnostic]
1236 pub sub: OverruledAttributeSub,
1237}
1238
1239#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DeprecatedLintName where G: rustc_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)]
1240#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
1241pub(crate) struct DeprecatedLintName {
1242 pub name: Symbol,
1243 #[suggestion("change it to", code = "{replace}", applicability = "machine-applicable")]
1244 pub suggestion: Span,
1245 pub replace: Symbol,
1246}
1247
1248#[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)]
1249#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
1250#[help("change it to {$replace}")]
1251pub(crate) struct DeprecatedLintNameFromCommandLine<'a> {
1252 pub name: String,
1253 pub replace: &'a str,
1254 #[subdiagnostic]
1255 pub requested_level: RequestedLevel<'a>,
1256}
1257
1258#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for RenamedLint
where G: rustc_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)]
1259#[diag("lint `{$name}` has been renamed to `{$replace}`")]
1260pub(crate) struct RenamedLint {
1261 pub name: Symbol,
1262 pub replace: Symbol,
1263 #[subdiagnostic]
1264 pub suggestion: RenamedLintSuggestion,
1265}
1266
1267#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for RenamedLintSuggestion {
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)]
1268pub(crate) enum RenamedLintSuggestion {
1269 #[suggestion("use the new name", code = "{replace}", applicability = "machine-applicable")]
1270 WithSpan {
1271 #[primary_span]
1272 suggestion: Span,
1273 replace: Symbol,
1274 },
1275 #[help("use the new name `{$replace}`")]
1276 WithoutSpan { replace: Symbol },
1277}
1278
1279#[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)]
1280#[diag("lint `{$name}` has been renamed to `{$replace}`")]
1281pub(crate) struct RenamedLintFromCommandLine<'a> {
1282 pub name: &'a str,
1283 pub replace: Symbol,
1284 #[subdiagnostic]
1285 pub suggestion: RenamedLintSuggestion,
1286 #[subdiagnostic]
1287 pub requested_level: RequestedLevel<'a>,
1288}
1289
1290#[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)]
1291#[diag("lint `{$name}` has been removed: {$reason}")]
1292pub(crate) struct RemovedLint<'a> {
1293 pub name: Symbol,
1294 pub reason: &'a str,
1295}
1296
1297#[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)]
1298#[diag("lint `{$name}` has been removed: {$reason}")]
1299pub(crate) struct RemovedLintFromCommandLine<'a> {
1300 pub name: &'a str,
1301 pub reason: &'a str,
1302 #[subdiagnostic]
1303 pub requested_level: RequestedLevel<'a>,
1304}
1305
1306#[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)]
1307#[diag("unknown lint: `{$name}`")]
1308pub(crate) struct UnknownLint {
1309 pub name: Symbol,
1310 #[subdiagnostic]
1311 pub suggestion: Option<UnknownLintSuggestion>,
1312}
1313
1314#[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)]
1315pub(crate) enum UnknownLintSuggestion {
1316 #[suggestion(
1317 "{$from_rustc ->
1318 [true] a lint with a similar name exists in `rustc` lints
1319 *[false] did you mean
1320 }",
1321 code = "{replace}",
1322 applicability = "maybe-incorrect"
1323 )]
1324 WithSpan {
1325 #[primary_span]
1326 suggestion: Span,
1327 replace: Symbol,
1328 from_rustc: bool,
1329 },
1330 #[help(
1331 "{$from_rustc ->
1332 [true] a lint with a similar name exists in `rustc` lints: `{$replace}`
1333 *[false] did you mean: `{$replace}`
1334 }"
1335 )]
1336 WithoutSpan { replace: Symbol, from_rustc: bool },
1337}
1338
1339#[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)]
1340#[diag("unknown lint: `{$name}`", code = E0602)]
1341pub(crate) struct UnknownLintFromCommandLine<'a> {
1342 pub name: String,
1343 #[subdiagnostic]
1344 pub suggestion: Option<UnknownLintSuggestion>,
1345 #[subdiagnostic]
1346 pub requested_level: RequestedLevel<'a>,
1347}
1348
1349#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IgnoredUnlessCrateSpecified where
G: rustc_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)]
1350#[diag("{$level}({$name}) is ignored unless specified at crate level")]
1351pub(crate) struct IgnoredUnlessCrateSpecified {
1352 pub level: Symbol,
1353 pub name: Symbol,
1354}
1355
1356#[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)]
1358#[diag("this creates a dangling pointer because temporary `{$ty}` is dropped at end of statement")]
1359#[help("bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`")]
1360#[note("a dangling pointer is safe, but dereferencing one is undefined behavior")]
1361#[note("returning a pointer to a local variable will always result in a dangling pointer")]
1362#[note("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")]
1363pub(crate) struct DanglingPointersFromTemporaries<'tcx> {
1365 pub callee: Ident,
1366 pub ty: Ty<'tcx>,
1367 #[label("pointer created here")]
1368 pub ptr_span: Span,
1369 #[label("this `{$ty}` is dropped at end of statement")]
1370 pub temporary_span: Span,
1371}
1372
1373#[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)]
1374#[diag("{$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`")]
1375#[note("a dangling pointer is safe, but dereferencing one is undefined behavior")]
1376#[note("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")]
1377pub(crate) struct DanglingPointersFromLocals<'tcx> {
1378 pub ret_ty: Ty<'tcx>,
1379 #[label("return type is `{$ret_ty}`")]
1380 pub ret_ty_span: Span,
1381 pub fn_kind: &'static str,
1382 #[label("local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}")]
1383 pub local_var: Span,
1384 pub local_var_name: Ident,
1385 pub local_var_ty: Ty<'tcx>,
1386 #[label("dangling pointer created here")]
1387 pub created_at: Option<Span>,
1388}
1389
1390#[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)]
1392#[diag("`{$ident}` is dyn-compatible and has multiple supertraits")]
1393pub(crate) struct MultipleSupertraitUpcastable {
1394 pub ident: Ident,
1395}
1396
1397#[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)]
1399#[diag("identifier contains non-ASCII characters")]
1400pub(crate) struct IdentifierNonAsciiChar;
1401
1402#[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)]
1403#[diag(
1404 "identifier contains {$codepoints_len ->
1405 [one] { $identifier_type ->
1406 [Exclusion] a character from an archaic script
1407 [Technical] a character that is for non-linguistic, specialized usage
1408 [Limited_Use] a character from a script in limited use
1409 [Not_NFKC] a non normalized (NFKC) character
1410 *[other] an uncommon character
1411 }
1412 *[other] { $identifier_type ->
1413 [Exclusion] {$codepoints_len} characters from archaic scripts
1414 [Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage
1415 [Limited_Use] {$codepoints_len} characters from scripts in limited use
1416 [Not_NFKC] {$codepoints_len} non normalized (NFKC) characters
1417 *[other] uncommon characters
1418 }
1419 }: {$codepoints}"
1420)]
1421#[note(
1422 r#"{$codepoints_len ->
1423 [one] this character is
1424 *[other] these characters are
1425 } included in the{$identifier_type ->
1426 [Restricted] {""}
1427 *[other] {" "}{$identifier_type}
1428 } Unicode general security profile"#
1429)]
1430pub(crate) struct IdentifierUncommonCodepoints {
1431 pub codepoints: Vec<char>,
1432 pub codepoints_len: usize,
1433 pub identifier_type: &'static str,
1434}
1435
1436#[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)]
1437#[diag("found both `{$existing_sym}` and `{$sym}` as identifiers, which look alike")]
1438pub(crate) struct ConfusableIdentifierPair {
1439 pub existing_sym: Symbol,
1440 pub sym: Symbol,
1441 #[label("other identifier used here")]
1442 pub label: Span,
1443 #[label("this identifier can be confused with `{$existing_sym}`")]
1444 pub main_label: Span,
1445}
1446
1447#[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)]
1448#[diag(
1449 "the usage of Script Group `{$set}` in this crate consists solely of mixed script confusables"
1450)]
1451#[note("the usage includes {$includes}")]
1452#[note("please recheck to make sure their usages are indeed what you want")]
1453pub(crate) struct MixedScriptConfusables {
1454 pub set: String,
1455 pub includes: String,
1456}
1457
1458pub(crate) struct NonFmtPanicUnused {
1460 pub count: usize,
1461 pub suggestion: Option<Span>,
1462}
1463
1464impl<'a> Diagnostic<'a, ()> for NonFmtPanicUnused {
1466 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1467 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!(
1468 "panic message contains {$count ->
1469 [one] an unused
1470 *[other] unused
1471 } formatting {$count ->
1472 [one] placeholder
1473 *[other] placeholders
1474 }"
1475 ))
1476 .with_arg("count", self.count)
1477 .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"));
1478 if let Some(span) = self.suggestion {
1479 diag.span_suggestion(
1480 span.shrink_to_hi(),
1481 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add the missing {$count ->\n [one] argument\n *[other] arguments\n }"))msg!(
1482 "add the missing {$count ->
1483 [one] argument
1484 *[other] arguments
1485 }"
1486 ),
1487 ", ...",
1488 Applicability::HasPlaceholders,
1489 );
1490 diag.span_suggestion(
1491 span.shrink_to_lo(),
1492 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"#),
1493 "\"{}\", ",
1494 Applicability::MachineApplicable,
1495 );
1496 }
1497 diag
1498 }
1499}
1500
1501#[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)]
1502#[diag(
1503 "panic message contains {$count ->
1504 [one] a brace
1505 *[other] braces
1506 }"
1507)]
1508#[note("this message is not used as a format string, but will be in Rust 2021")]
1509pub(crate) struct NonFmtPanicBraces {
1510 pub count: usize,
1511 #[suggestion(
1512 "add a \"{\"{\"}{\"}\"}\" format string to use the message literally",
1513 code = "\"{{}}\", ",
1514 applicability = "machine-applicable"
1515 )]
1516 pub suggestion: Option<Span>,
1517}
1518
1519#[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)]
1521#[diag("{$sort} `{$name}` should have an upper camel case name")]
1522pub(crate) struct NonCamelCaseType<'a> {
1523 pub sort: &'a str,
1524 pub name: &'a str,
1525 #[subdiagnostic]
1526 pub sub: NonCamelCaseTypeSub,
1527}
1528
1529#[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)]
1530pub(crate) enum NonCamelCaseTypeSub {
1531 #[label("should have an UpperCamelCase name")]
1532 Label {
1533 #[primary_span]
1534 span: Span,
1535 },
1536 #[suggestion(
1537 "convert the identifier to upper camel case",
1538 code = "{replace}",
1539 applicability = "maybe-incorrect"
1540 )]
1541 Suggestion {
1542 #[primary_span]
1543 span: Span,
1544 replace: String,
1545 },
1546}
1547
1548#[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)]
1549#[diag("{$sort} `{$name}` should have a snake case name")]
1550pub(crate) struct NonSnakeCaseDiag<'a> {
1551 pub sort: &'a str,
1552 pub name: &'a str,
1553 pub sc: String,
1554 #[subdiagnostic]
1555 pub sub: NonSnakeCaseDiagSub,
1556}
1557
1558pub(crate) enum NonSnakeCaseDiagSub {
1559 Label { span: Span },
1560 Help,
1561 RenameOrConvertSuggestion { span: Span, suggestion: Ident },
1562 ConvertSuggestion { span: Span, suggestion: String },
1563 SuggestionAndNote { span: Span },
1564}
1565
1566impl Subdiagnostic for NonSnakeCaseDiagSub {
1567 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1568 match self {
1569 NonSnakeCaseDiagSub::Label { span } => {
1570 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"));
1571 }
1572 NonSnakeCaseDiagSub::Help => {
1573 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}`"));
1574 }
1575 NonSnakeCaseDiagSub::ConvertSuggestion { span, suggestion } => {
1576 diag.span_suggestion(
1577 span,
1578 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert the identifier to snake case"))msg!("convert the identifier to snake case"),
1579 suggestion,
1580 Applicability::MaybeIncorrect,
1581 );
1582 }
1583 NonSnakeCaseDiagSub::RenameOrConvertSuggestion { span, suggestion } => {
1584 diag.span_suggestion(
1585 span,
1586 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"),
1587 suggestion,
1588 Applicability::MaybeIncorrect,
1589 );
1590 }
1591 NonSnakeCaseDiagSub::SuggestionAndNote { span } => {
1592 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"));
1593 diag.span_suggestion(
1594 span,
1595 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rename the identifier"))msg!("rename the identifier"),
1596 "",
1597 Applicability::MaybeIncorrect,
1598 );
1599 }
1600 }
1601 }
1602}
1603
1604#[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)]
1605#[diag("{$sort} `{$name}` should have an upper case name")]
1606pub(crate) struct NonUpperCaseGlobal<'a> {
1607 pub sort: &'a str,
1608 pub name: &'a str,
1609 #[subdiagnostic]
1610 pub sub: NonUpperCaseGlobalSub,
1611 #[subdiagnostic]
1612 pub usages: Vec<NonUpperCaseGlobalSubTool>,
1613}
1614
1615#[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)]
1616pub(crate) enum NonUpperCaseGlobalSub {
1617 #[label("should have an UPPER_CASE name")]
1618 Label {
1619 #[primary_span]
1620 span: Span,
1621 },
1622 #[suggestion("convert the identifier to upper case", code = "{replace}")]
1623 Suggestion {
1624 #[primary_span]
1625 span: Span,
1626 #[applicability]
1627 applicability: Applicability,
1628 replace: String,
1629 },
1630}
1631
1632#[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)]
1633#[suggestion(
1634 "convert the identifier to upper case",
1635 code = "{replace}",
1636 applicability = "machine-applicable",
1637 style = "tool-only"
1638)]
1639pub(crate) struct NonUpperCaseGlobalSubTool {
1640 #[primary_span]
1641 pub(crate) span: Span,
1642 pub(crate) replace: String,
1643}
1644
1645#[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)]
1647#[diag("call to `.{$method}()` on a reference in this situation does nothing")]
1648#[note(
1649 "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"
1650)]
1651pub(crate) struct NoopMethodCallDiag<'a> {
1652 pub method: Ident,
1653 pub orig_ty: Ty<'a>,
1654 pub trait_: Symbol,
1655 #[suggestion("remove this redundant call", code = "", applicability = "machine-applicable")]
1656 pub label: Span,
1657 #[suggestion(
1658 "if you meant to clone `{$orig_ty}`, implement `Clone` for it",
1659 code = "#[derive(Clone)]\n",
1660 applicability = "maybe-incorrect"
1661 )]
1662 pub suggest_derive: Option<Span>,
1663}
1664
1665#[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)]
1666#[diag(
1667 "using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type"
1668)]
1669pub(crate) struct SuspiciousDoubleRefDerefDiag<'a> {
1670 pub ty: Ty<'a>,
1671}
1672
1673#[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)]
1674#[diag(
1675 "using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type"
1676)]
1677pub(crate) struct SuspiciousDoubleRefCloneDiag<'a> {
1678 pub ty: Ty<'a>,
1679}
1680
1681pub(crate) enum NonLocalDefinitionsDiag {
1683 Impl {
1684 depth: u32,
1685 body_kind_descr: &'static str,
1686 body_name: String,
1687 cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
1688 const_anon: Option<Option<Span>>,
1689 doctest: bool,
1690 macro_to_change: Option<(String, &'static str)>,
1691 },
1692 MacroRules {
1693 depth: u32,
1694 body_kind_descr: &'static str,
1695 body_name: String,
1696 doctest: bool,
1697 cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
1698 },
1699}
1700
1701impl<'a> Diagnostic<'a, ()> for NonLocalDefinitionsDiag {
1702 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1703 let mut diag = Diag::new(dcx, level, "");
1704 match self {
1705 NonLocalDefinitionsDiag::Impl {
1706 depth,
1707 body_kind_descr,
1708 body_name,
1709 cargo_update,
1710 const_anon,
1711 doctest,
1712 macro_to_change,
1713 } => {
1714 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"));
1715 diag.arg("depth", depth);
1716 diag.arg("body_kind_descr", body_kind_descr);
1717 diag.arg("body_name", body_name);
1718
1719 if let Some((macro_to_change, macro_kind)) = macro_to_change {
1720 diag.arg("macro_to_change", macro_to_change);
1721 diag.arg("macro_kind", macro_kind);
1722 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"));
1723 }
1724 if let Some(cargo_update) = cargo_update {
1725 diag.subdiagnostic(cargo_update);
1726 }
1727
1728 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`"));
1729
1730 if doctest {
1731 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() {\"{\"} ... {\"}\"}`"));
1732 }
1733
1734 if let Some(const_anon) = const_anon {
1735 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"));
1736 if let Some(const_anon) = const_anon {
1737 diag.span_suggestion(
1738 const_anon,
1739 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"),
1740 "_",
1741 Applicability::MachineApplicable,
1742 );
1743 }
1744 }
1745 }
1746 NonLocalDefinitionsDiag::MacroRules {
1747 depth,
1748 body_kind_descr,
1749 body_name,
1750 doctest,
1751 cargo_update,
1752 } => {
1753 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"));
1754 diag.arg("depth", depth);
1755 diag.arg("body_kind_descr", body_kind_descr);
1756 diag.arg("body_name", body_name);
1757
1758 if doctest {
1759 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() {"{"} ... {"}"}`"#));
1760 } else {
1761 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!(
1762 "remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth ->
1763 [one] `{$body_name}`
1764 *[other] `{$body_name}` and up {$depth} bodies
1765 }"
1766 ));
1767 }
1768
1769 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"));
1770
1771 if let Some(cargo_update) = cargo_update {
1772 diag.subdiagnostic(cargo_update);
1773 }
1774 }
1775 }
1776 diag
1777 }
1778}
1779
1780#[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)]
1781#[note(
1782 "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}`"
1783)]
1784pub(crate) struct NonLocalDefinitionsCargoUpdateNote {
1785 pub macro_kind: &'static str,
1786 pub macro_name: Symbol,
1787 pub crate_name: Symbol,
1788}
1789
1790#[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)]
1792#[diag("`-` has lower precedence than method calls, which might be unexpected")]
1793#[note("e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`")]
1794pub(crate) struct AmbiguousNegativeLiteralsDiag {
1795 #[subdiagnostic]
1796 pub negative_literal: AmbiguousNegativeLiteralsNegativeLiteralSuggestion,
1797 #[subdiagnostic]
1798 pub current_behavior: AmbiguousNegativeLiteralsCurrentBehaviorSuggestion,
1799}
1800
1801#[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)]
1802#[multipart_suggestion(
1803 "add parentheses around the `-` and the literal to call the method on a negative literal",
1804 applicability = "maybe-incorrect"
1805)]
1806pub(crate) struct AmbiguousNegativeLiteralsNegativeLiteralSuggestion {
1807 #[suggestion_part(code = "(")]
1808 pub start_span: Span,
1809 #[suggestion_part(code = ")")]
1810 pub end_span: Span,
1811}
1812
1813#[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)]
1814#[multipart_suggestion(
1815 "add parentheses around the literal and the method call to keep the current behavior",
1816 applicability = "maybe-incorrect"
1817)]
1818pub(crate) struct AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
1819 #[suggestion_part(code = "(")]
1820 pub start_span: Span,
1821 #[suggestion_part(code = ")")]
1822 pub end_span: Span,
1823}
1824
1825#[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)]
1827#[diag("passing `{$ty}` by reference")]
1828pub(crate) struct DisallowedPassByRefDiag {
1829 pub ty: String,
1830 #[suggestion("try passing by value", code = "{ty}", applicability = "maybe-incorrect")]
1831 pub suggestion: Span,
1832}
1833
1834#[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)]
1836#[diag(
1837 "unnecessary trailing {$multiple ->
1838 [true] semicolons
1839 *[false] semicolon
1840 }"
1841)]
1842pub(crate) struct RedundantSemicolonsDiag {
1843 pub multiple: bool,
1844 #[subdiagnostic]
1845 pub suggestion: Option<RedundantSemicolonsSuggestion>,
1846}
1847
1848#[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)]
1849#[suggestion(
1850 "remove {$multiple_semicolons ->
1851 [true] these semicolons
1852 *[false] this semicolon
1853 }",
1854 code = "",
1855 applicability = "maybe-incorrect"
1856)]
1857pub(crate) struct RedundantSemicolonsSuggestion {
1858 pub multiple_semicolons: bool,
1859 #[primary_span]
1860 pub span: Span,
1861}
1862
1863pub(crate) struct DropTraitConstraintsDiag<'a> {
1865 pub predicate: Clause<'a>,
1866 pub tcx: TyCtxt<'a>,
1867 pub def_id: DefId,
1868}
1869
1870impl<'a> Diagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
1872 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1873 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"))
1874 .with_arg("predicate", self.predicate)
1875 .with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
1876 }
1877}
1878
1879pub(crate) struct DropGlue<'a> {
1880 pub tcx: TyCtxt<'a>,
1881 pub def_id: DefId,
1882}
1883
1884impl<'a> Diagnostic<'a, ()> for DropGlue<'_> {
1886 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1887 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"))
1888 .with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
1889 }
1890}
1891
1892#[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)]
1894#[diag("transmuting an integer to a pointer creates a pointer without provenance")]
1895#[note("this is dangerous because dereferencing the resulting pointer is undefined behavior")]
1896#[note(
1897 "exposed provenance semantics can be used to create a pointer based on some previously exposed provenance"
1898)]
1899#[help(
1900 "if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`"
1901)]
1902#[help(
1903 "for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>"
1904)]
1905#[help(
1906 "for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>"
1907)]
1908pub(crate) struct IntegerToPtrTransmutes<'tcx> {
1909 #[subdiagnostic]
1910 pub suggestion: Option<IntegerToPtrTransmutesSuggestion<'tcx>>,
1911}
1912
1913#[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)]
1914pub(crate) enum IntegerToPtrTransmutesSuggestion<'tcx> {
1915 #[multipart_suggestion(
1916 "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance",
1917 applicability = "machine-applicable",
1918 style = "verbose"
1919 )]
1920 ToPtr {
1921 dst: Ty<'tcx>,
1922 suffix: &'static str,
1923 #[suggestion_part(code = "std::ptr::with_exposed_provenance{suffix}::<{dst}>(")]
1924 start_call: Span,
1925 },
1926 #[multipart_suggestion(
1927 "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance",
1928 applicability = "machine-applicable",
1929 style = "verbose"
1930 )]
1931 ToRef {
1932 dst: Ty<'tcx>,
1933 suffix: &'static str,
1934 ref_mutbl: &'static str,
1935 #[suggestion_part(
1936 code = "&{ref_mutbl}*std::ptr::with_exposed_provenance{suffix}::<{dst}>("
1937 )]
1938 start_call: Span,
1939 },
1940}
1941
1942#[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)]
1944#[diag("range endpoint is out of range for `{$ty}`")]
1945pub(crate) struct RangeEndpointOutOfRange<'a> {
1946 pub ty: &'a str,
1947 #[subdiagnostic]
1948 pub sub: UseInclusiveRange<'a>,
1949}
1950
1951#[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)]
1952pub(crate) enum UseInclusiveRange<'a> {
1953 #[suggestion(
1954 "use an inclusive range instead",
1955 code = "{start}..={literal}{suffix}",
1956 applicability = "machine-applicable"
1957 )]
1958 WithoutParen {
1959 #[primary_span]
1960 sugg: Span,
1961 start: String,
1962 literal: u128,
1963 suffix: &'a str,
1964 },
1965 #[multipart_suggestion("use an inclusive range instead", applicability = "machine-applicable")]
1966 WithParen {
1967 #[suggestion_part(code = "=")]
1968 eq_sugg: Span,
1969 #[suggestion_part(code = "{literal}{suffix}")]
1970 lit_sugg: Span,
1971 literal: u128,
1972 suffix: &'a str,
1973 },
1974}
1975
1976#[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)]
1977#[diag("literal out of range for `{$ty}`")]
1978pub(crate) struct OverflowingBinHex<'a> {
1979 pub ty: &'a str,
1980 #[subdiagnostic]
1981 pub sign: OverflowingBinHexSign<'a>,
1982 #[subdiagnostic]
1983 pub sub: Option<OverflowingBinHexSub<'a>>,
1984 #[subdiagnostic]
1985 pub sign_bit_sub: Option<OverflowingBinHexSignBitSub<'a>>,
1986}
1987
1988#[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)]
1989pub(crate) enum OverflowingBinHexSign<'a> {
1990 #[note(
1991 "the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`"
1992 )]
1993 Positive { lit: String, ty: &'a str, actually: String, dec: u128 },
1994 #[note("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`")]
1995 #[note("and the value `-{$lit}` will become `{$actually}{$ty}`")]
1996 Negative { lit: String, ty: &'a str, actually: String, dec: u128 },
1997}
1998
1999#[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)]
2000pub(crate) enum OverflowingBinHexSub<'a> {
2001 #[suggestion(
2002 "consider using the type `{$suggestion_ty}` instead",
2003 code = "{sans_suffix}{suggestion_ty}",
2004 applicability = "machine-applicable"
2005 )]
2006 Suggestion {
2007 #[primary_span]
2008 span: Span,
2009 suggestion_ty: &'a str,
2010 sans_suffix: &'a str,
2011 },
2012 #[help("consider using the type `{$suggestion_ty}` instead")]
2013 Help { suggestion_ty: &'a str },
2014}
2015
2016#[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)]
2017#[suggestion(
2018 "to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`",
2019 code = "{lit_no_suffix}{uint_ty} as {int_ty}",
2020 applicability = "maybe-incorrect"
2021)]
2022pub(crate) struct OverflowingBinHexSignBitSub<'a> {
2023 #[primary_span]
2024 pub span: Span,
2025 pub lit_no_suffix: &'a str,
2026 pub negative_val: String,
2027 pub uint_ty: &'a str,
2028 pub int_ty: &'a str,
2029}
2030
2031#[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)]
2032#[diag("literal out of range for `{$ty}`")]
2033#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
2034pub(crate) struct OverflowingInt<'a> {
2035 pub ty: &'a str,
2036 pub lit: String,
2037 pub min: i128,
2038 pub max: u128,
2039 #[subdiagnostic]
2040 pub help: Option<OverflowingIntHelp<'a>>,
2041}
2042
2043#[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)]
2044#[help("consider using the type `{$suggestion_ty}` instead")]
2045pub(crate) struct OverflowingIntHelp<'a> {
2046 pub suggestion_ty: &'a str,
2047}
2048
2049#[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)]
2050#[diag("only `u8` can be cast into `char`")]
2051pub(crate) struct OnlyCastu8ToChar {
2052 #[suggestion(
2053 "use a `char` literal instead",
2054 code = "'\\u{{{literal:X}}}'",
2055 applicability = "machine-applicable"
2056 )]
2057 pub span: Span,
2058 pub literal: u128,
2059}
2060
2061#[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)]
2062#[diag("literal out of range for `{$ty}`")]
2063#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
2064pub(crate) struct OverflowingUInt<'a> {
2065 pub ty: &'a str,
2066 pub lit: String,
2067 pub min: u128,
2068 pub max: u128,
2069}
2070
2071#[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)]
2072#[diag("literal out of range for `{$ty}`")]
2073#[note(
2074 "the literal `{$lit}` does not fit into the type `{$ty}` and will be converted to `{$ty}::INFINITY`"
2075)]
2076pub(crate) struct OverflowingLiteral<'a> {
2077 pub ty: &'a str,
2078 pub lit: String,
2079}
2080
2081#[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)]
2082#[diag("surrogate values are not valid for `char`")]
2083#[note("`0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values")]
2084pub(crate) struct SurrogateCharCast {
2085 pub literal: u128,
2086}
2087
2088#[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)]
2089#[diag("value exceeds maximum `char` value")]
2090#[note("maximum valid `char` value is `0x10FFFF`")]
2091pub(crate) struct TooLargeCharCast {
2092 pub literal: u128,
2093}
2094
2095#[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)]
2096#[diag(
2097 "repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type"
2098)]
2099pub(crate) struct UsesPowerAlignment;
2100
2101#[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)]
2102#[diag("comparison is useless due to type limits")]
2103pub(crate) struct UnusedComparisons;
2104
2105#[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)]
2106pub(crate) enum InvalidNanComparisons {
2107 #[diag("incorrect NaN comparison, NaN cannot be directly compared to itself")]
2108 EqNe {
2109 #[subdiagnostic]
2110 suggestion: InvalidNanComparisonsSuggestion,
2111 },
2112 #[diag("incorrect NaN comparison, NaN is not orderable")]
2113 LtLeGtGe,
2114}
2115
2116#[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)]
2117pub(crate) enum InvalidNanComparisonsSuggestion {
2118 #[multipart_suggestion(
2119 "use `f32::is_nan()` or `f64::is_nan()` instead",
2120 style = "verbose",
2121 applicability = "machine-applicable"
2122 )]
2123 Spanful {
2124 #[suggestion_part(code = "!")]
2125 neg: Option<Span>,
2126 #[suggestion_part(code = ".is_nan()")]
2127 float: Span,
2128 #[suggestion_part(code = "")]
2129 nan_plus_binop: Span,
2130 },
2131 #[help("use `f32::is_nan()` or `f64::is_nan()` instead")]
2132 Spanless,
2133}
2134
2135#[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)]
2136pub(crate) enum AmbiguousWidePointerComparisons<'a> {
2137 #[diag(
2138 "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2139 )]
2140 SpanfulEq {
2141 #[subdiagnostic]
2142 addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion<'a>,
2143 #[subdiagnostic]
2144 addr_metadata_suggestion: Option<AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a>>,
2145 },
2146 #[diag(
2147 "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2148 )]
2149 SpanfulCmp {
2150 #[subdiagnostic]
2151 cast_suggestion: AmbiguousWidePointerComparisonsCastSuggestion<'a>,
2152 #[subdiagnostic]
2153 expect_suggestion: AmbiguousWidePointerComparisonsExpectSuggestion<'a>,
2154 },
2155 #[diag(
2156 "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2157 )]
2158 #[help("use explicit `std::ptr::eq` method to compare metadata and addresses")]
2159 #[help("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")]
2160 Spanless,
2161}
2162
2163#[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)]
2164#[multipart_suggestion(
2165 "use explicit `std::ptr::eq` method to compare metadata and addresses",
2166 style = "verbose",
2167 applicability = "maybe-incorrect"
2169)]
2170pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
2171 pub ne: &'a str,
2172 pub deref_left: &'a str,
2173 pub deref_right: &'a str,
2174 pub l_modifiers: &'a str,
2175 pub r_modifiers: &'a str,
2176 #[suggestion_part(code = "{ne}std::ptr::eq({deref_left}")]
2177 pub left: Span,
2178 #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
2179 pub middle: Span,
2180 #[suggestion_part(code = "{r_modifiers})")]
2181 pub right: Span,
2182}
2183
2184#[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)]
2185#[multipart_suggestion(
2186 "use `std::ptr::addr_eq` or untyped pointers to only compare their addresses",
2187 style = "verbose",
2188 applicability = "maybe-incorrect"
2190)]
2191pub(crate) struct AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
2192 pub(crate) ne: &'a str,
2193 pub(crate) deref_left: &'a str,
2194 pub(crate) deref_right: &'a str,
2195 pub(crate) l_modifiers: &'a str,
2196 pub(crate) r_modifiers: &'a str,
2197 #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")]
2198 pub(crate) left: Span,
2199 #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
2200 pub(crate) middle: Span,
2201 #[suggestion_part(code = "{r_modifiers})")]
2202 pub(crate) right: Span,
2203}
2204
2205#[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)]
2206#[multipart_suggestion(
2207 "use untyped pointers to only compare their addresses",
2208 style = "verbose",
2209 applicability = "maybe-incorrect"
2211)]
2212pub(crate) struct AmbiguousWidePointerComparisonsCastSuggestion<'a> {
2213 pub(crate) deref_left: &'a str,
2214 pub(crate) deref_right: &'a str,
2215 pub(crate) paren_left: &'a str,
2216 pub(crate) paren_right: &'a str,
2217 pub(crate) l_modifiers: &'a str,
2218 pub(crate) r_modifiers: &'a str,
2219 #[suggestion_part(code = "({deref_left}")]
2220 pub(crate) left_before: Option<Span>,
2221 #[suggestion_part(code = "{l_modifiers}{paren_left}.cast::<()>()")]
2222 pub(crate) left_after: Span,
2223 #[suggestion_part(code = "({deref_right}")]
2224 pub(crate) right_before: Option<Span>,
2225 #[suggestion_part(code = "{r_modifiers}{paren_right}.cast::<()>()")]
2226 pub(crate) right_after: Span,
2227}
2228
2229#[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)]
2230#[multipart_suggestion(
2231 "or expect the lint to compare the pointers metadata and addresses",
2232 style = "verbose",
2233 applicability = "maybe-incorrect"
2235)]
2236pub(crate) struct AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
2237 pub(crate) paren_left: &'a str,
2238 pub(crate) paren_right: &'a str,
2239 #[suggestion_part(
2241 code = r#"{{ #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] {paren_left}"#
2242 )]
2243 pub(crate) before: Span,
2244 #[suggestion_part(code = "{paren_right} }}")]
2245 pub(crate) after: Span,
2246}
2247
2248#[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)]
2249pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> {
2250 #[diag(
2251 "function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique"
2252 )]
2253 #[note("the address of the same function can vary between different codegen units")]
2254 #[note(
2255 "furthermore, different functions could have the same address after being merged together"
2256 )]
2257 #[note(
2258 "for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>"
2259 )]
2260 Suggestion {
2261 #[subdiagnostic]
2262 sugg: UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx>,
2263 },
2264 #[diag(
2265 "function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique"
2266 )]
2267 #[note("the address of the same function can vary between different codegen units")]
2268 #[note(
2269 "furthermore, different functions could have the same address after being merged together"
2270 )]
2271 #[note(
2272 "for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>"
2273 )]
2274 Warn,
2275}
2276
2277#[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)]
2278pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> {
2279 #[multipart_suggestion(
2280 "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint",
2281 style = "verbose",
2282 applicability = "maybe-incorrect"
2283 )]
2284 FnAddrEq {
2285 ne: &'a str,
2286 deref_left: &'a str,
2287 deref_right: &'a str,
2288 #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
2289 left: Span,
2290 #[suggestion_part(code = ", {deref_right}")]
2291 middle: Span,
2292 #[suggestion_part(code = ")")]
2293 right: Span,
2294 },
2295 #[multipart_suggestion(
2296 "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint",
2297 style = "verbose",
2298 applicability = "maybe-incorrect"
2299 )]
2300 FnAddrEqWithCast {
2301 ne: &'a str,
2302 deref_left: &'a str,
2303 deref_right: &'a str,
2304 fn_sig: rustc_middle::ty::PolyFnSig<'tcx>,
2305 #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
2306 left: Span,
2307 #[suggestion_part(code = ", {deref_right}")]
2308 middle: Span,
2309 #[suggestion_part(code = " as {fn_sig})")]
2310 right: Span,
2311 },
2312}
2313
2314pub(crate) struct ImproperCTypes<'a> {
2315 pub ty: Ty<'a>,
2316 pub desc: &'a str,
2317 pub label: Span,
2318 pub help: Option<DiagMessage>,
2319 pub note: DiagMessage,
2320 pub span_note: Option<Span>,
2321}
2322
2323impl<'a> Diagnostic<'a, ()> for ImproperCTypes<'_> {
2325 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2326 let mut diag = Diag::new(
2327 dcx,
2328 level,
2329 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"),
2330 )
2331 .with_arg("ty", self.ty)
2332 .with_arg("desc", self.desc)
2333 .with_span_label(self.label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not FFI-safe"))msg!("not FFI-safe"));
2334 if let Some(help) = self.help {
2335 diag.help(help);
2336 }
2337 diag.note(self.note);
2338 if let Some(note) = self.span_note {
2339 diag.span_note(note, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type is defined here"))msg!("the type is defined here"));
2340 }
2341 diag
2342 }
2343}
2344
2345#[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)]
2346#[diag("passing type `{$ty}` to a function with \"gpu-kernel\" ABI may have unexpected behavior")]
2347#[help("use primitive types and raw pointers to get reliable behavior")]
2348pub(crate) struct ImproperGpuKernelArg<'a> {
2349 pub ty: Ty<'a>,
2350}
2351
2352#[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)]
2353#[diag("function with the \"gpu-kernel\" ABI has a mangled name")]
2354#[help("use `unsafe(no_mangle)` or `unsafe(export_name = \"<name>\")`")]
2355#[note("mangled names make it hard to find the kernel, this is usually not intended")]
2356pub(crate) struct MissingGpuKernelExportName;
2357
2358#[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)]
2359#[diag("enum variant is more than three times larger ({$largest} bytes) than the next largest")]
2360pub(crate) struct VariantSizeDifferencesDiag {
2361 pub largest: u64,
2362}
2363
2364#[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)]
2365#[diag("atomic loads cannot have `Release` or `AcqRel` ordering")]
2366#[help("consider using ordering modes `Acquire`, `SeqCst` or `Relaxed`")]
2367pub(crate) struct AtomicOrderingLoad;
2368
2369#[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)]
2370#[diag("atomic stores cannot have `Acquire` or `AcqRel` ordering")]
2371#[help("consider using ordering modes `Release`, `SeqCst` or `Relaxed`")]
2372pub(crate) struct AtomicOrderingStore;
2373
2374#[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)]
2375#[diag("memory fences cannot have `Relaxed` ordering")]
2376#[help("consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`")]
2377pub(crate) struct AtomicOrderingFence;
2378
2379#[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)]
2380#[diag(
2381 "`{$method}`'s failure ordering may not be `Release` or `AcqRel`, since a failed `{$method}` does not result in a write"
2382)]
2383#[help("consider using `Acquire` or `Relaxed` failure ordering instead")]
2384pub(crate) struct InvalidAtomicOrderingDiag {
2385 pub method: Symbol,
2386 #[label("invalid failure ordering")]
2387 pub fail_order_arg_span: Span,
2388}
2389
2390#[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)]
2392#[diag("unused {$op} that must be used")]
2393pub(crate) struct UnusedOp<'a> {
2394 pub op: &'a str,
2395 #[label("the {$op} produces a value")]
2396 pub label: Span,
2397 #[subdiagnostic]
2398 pub suggestion: UnusedOpSuggestion,
2399}
2400
2401#[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)]
2402pub(crate) enum UnusedOpSuggestion {
2403 #[suggestion(
2404 "use `let _ = ...` to ignore the resulting value",
2405 style = "verbose",
2406 code = "let _ = ",
2407 applicability = "maybe-incorrect"
2408 )]
2409 NormalExpr {
2410 #[primary_span]
2411 span: Span,
2412 },
2413 #[multipart_suggestion(
2414 "use `let _ = ...` to ignore the resulting value",
2415 style = "verbose",
2416 applicability = "maybe-incorrect"
2417 )]
2418 BlockTailExpr {
2419 #[suggestion_part(code = "let _ = ")]
2420 before_span: Span,
2421 #[suggestion_part(code = ";")]
2422 after_span: Span,
2423 },
2424}
2425
2426#[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)]
2427#[diag("unused result of type `{$ty}`")]
2428pub(crate) struct UnusedResult<'a> {
2429 pub ty: Ty<'a>,
2430}
2431
2432#[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)]
2435#[diag(
2436 "unused {$pre}{$count ->
2437 [one] closure
2438 *[other] closures
2439 }{$post} that must be used"
2440)]
2441#[note("closures are lazy and do nothing unless called")]
2442pub(crate) struct UnusedClosure<'a> {
2443 pub count: usize,
2444 pub pre: &'a str,
2445 pub post: &'a str,
2446}
2447
2448#[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)]
2451#[diag(
2452 "unused {$pre}{$count ->
2453 [one] coroutine
2454 *[other] coroutine
2455 }{$post} that must be used"
2456)]
2457#[note("coroutines are lazy and do nothing unless resumed")]
2458pub(crate) struct UnusedCoroutine<'a> {
2459 pub count: usize,
2460 pub pre: &'a str,
2461 pub post: &'a str,
2462}
2463
2464pub(crate) struct UnusedDef<'a, 'b> {
2467 pub pre: &'a str,
2468 pub post: &'a str,
2469 pub cx: &'a LateContext<'b>,
2470 pub def_id: DefId,
2471 pub note: Option<Symbol>,
2472 pub suggestion: Option<UnusedDefSuggestion>,
2473}
2474
2475#[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)]
2476pub(crate) enum UnusedDefSuggestion {
2477 #[suggestion(
2478 "use `let _ = ...` to ignore the resulting value",
2479 style = "verbose",
2480 code = "let _ = ",
2481 applicability = "maybe-incorrect"
2482 )]
2483 NormalExpr {
2484 #[primary_span]
2485 span: Span,
2486 },
2487 #[multipart_suggestion(
2488 "use `let _ = ...` to ignore the resulting value",
2489 style = "verbose",
2490 applicability = "maybe-incorrect"
2491 )]
2492 BlockTailExpr {
2493 #[suggestion_part(code = "let _ = ")]
2494 before_span: Span,
2495 #[suggestion_part(code = ";")]
2496 after_span: Span,
2497 },
2498}
2499
2500impl<'a> Diagnostic<'a, ()> for UnusedDef<'_, '_> {
2502 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2503 let mut diag =
2504 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"))
2505 .with_arg("pre", self.pre)
2506 .with_arg("post", self.post)
2507 .with_arg("def", self.cx.tcx.def_path_str(self.def_id));
2508 if let Some(note) = self.note {
2510 diag.note(note.to_string());
2511 }
2512 if let Some(sugg) = self.suggestion {
2513 diag.subdiagnostic(sugg);
2514 }
2515 diag
2516 }
2517}
2518
2519#[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)]
2520#[diag("path statement drops value")]
2521pub(crate) struct PathStatementDrop {
2522 #[subdiagnostic]
2523 pub sub: PathStatementDropSub,
2524}
2525
2526#[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)]
2527pub(crate) enum PathStatementDropSub {
2528 #[suggestion(
2529 "use `drop` to clarify the intent",
2530 code = "drop({snippet});",
2531 applicability = "machine-applicable"
2532 )]
2533 Suggestion {
2534 #[primary_span]
2535 span: Span,
2536 snippet: String,
2537 },
2538 #[help("use `drop` to clarify the intent")]
2539 Help {
2540 #[primary_span]
2541 span: Span,
2542 },
2543}
2544
2545#[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)]
2546#[diag("path statement with no effect")]
2547pub(crate) struct PathStatementNoEffect;
2548
2549#[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)]
2550#[diag("unnecessary {$delim} around {$item}")]
2551pub(crate) struct UnusedDelim<'a> {
2552 pub delim: &'static str,
2553 pub item: &'a str,
2554 #[subdiagnostic]
2555 pub suggestion: Option<UnusedDelimSuggestion>,
2556}
2557
2558#[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)]
2559#[multipart_suggestion("remove these {$delim}", applicability = "machine-applicable")]
2560pub(crate) struct UnusedDelimSuggestion {
2561 #[suggestion_part(code = "{start_replace}")]
2562 pub start_span: Span,
2563 pub start_replace: &'static str,
2564 #[suggestion_part(code = "{end_replace}")]
2565 pub end_span: Span,
2566 pub end_replace: &'static str,
2567 pub delim: &'static str,
2568}
2569
2570#[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)]
2571#[diag("braces around {$node} is unnecessary")]
2572pub(crate) struct UnusedImportBracesDiag {
2573 pub node: Symbol,
2574}
2575
2576#[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)]
2577#[diag("unnecessary allocation, use `&` instead")]
2578pub(crate) struct UnusedAllocationDiag;
2579
2580#[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)]
2581#[diag("unnecessary allocation, use `&mut` instead")]
2582pub(crate) struct UnusedAllocationMutDiag;
2583
2584pub(crate) struct AsyncFnInTraitDiag {
2585 pub sugg: Option<Vec<(Span, String)>>,
2586}
2587
2588impl<'a> Diagnostic<'a, ()> for AsyncFnInTraitDiag {
2589 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2590 let mut diag = Diag::new(
2591 dcx,
2592 level,
2593 "use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified",
2594 );
2595 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`");
2596 if let Some(sugg) = self.sugg {
2597 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);
2598 }
2599 diag
2600 }
2601}
2602
2603#[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)]
2604#[diag("binding has unit type `()`")]
2605pub(crate) struct UnitBindingsDiag {
2606 #[label("this pattern is inferred to be the unit type `()`")]
2607 pub label: Span,
2608}
2609
2610#[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)]
2611pub(crate) enum InvalidAsmLabel {
2612 #[diag("avoid using named labels in inline assembly")]
2613 #[help("only local labels of the form `<number>:` should be used in inline asm")]
2614 #[note(
2615 "see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information"
2616 )]
2617 Named {
2618 #[note("the label may be declared in the expansion of a macro")]
2619 missing_precise_span: bool,
2620 },
2621 #[diag("avoid using named labels in inline assembly")]
2622 #[help("only local labels of the form `<number>:` should be used in inline asm")]
2623 #[note("format arguments may expand to a non-numeric value")]
2624 #[note(
2625 "see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information"
2626 )]
2627 FormatArg {
2628 #[note("the label may be declared in the expansion of a macro")]
2629 missing_precise_span: bool,
2630 },
2631 #[diag("avoid using labels containing only the digits `0` and `1` in inline assembly")]
2632 #[help("start numbering with `2` instead")]
2633 #[note("an LLVM bug makes these labels ambiguous with a binary literal number on x86")]
2634 #[note("see <https://github.com/llvm/llvm-project/issues/99547> for more information")]
2635 Binary {
2636 #[note("the label may be declared in the expansion of a macro")]
2637 missing_precise_span: bool,
2638 #[label("use a different label that doesn't start with `0` or `1`")]
2640 span: Span,
2641 },
2642}
2643
2644#[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)]
2645pub(crate) enum UnexpectedCfgCargoHelp {
2646 #[help("consider using a Cargo feature instead")]
2647 #[help(
2648 "or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:{$cargo_toml_lint_cfg}"
2649 )]
2650 LintCfg { cargo_toml_lint_cfg: String },
2651 #[help("consider using a Cargo feature instead")]
2652 #[help(
2653 "or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:{$cargo_toml_lint_cfg}"
2654 )]
2655 #[help("or consider adding `{$build_rs_println}` to the top of the `build.rs`")]
2656 LintCfgAndBuildRs { cargo_toml_lint_cfg: String, build_rs_println: String },
2657}
2658
2659impl UnexpectedCfgCargoHelp {
2660 fn cargo_toml_lint_cfg(unescaped: &str) -> String {
2661 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\n [lints.rust]\n unexpected_cfgs = {{ level = \"warn\", check-cfg = [\'{0}\'] }}",
unescaped))
})format!(
2662 "\n [lints.rust]\n unexpected_cfgs = {{ level = \"warn\", check-cfg = ['{unescaped}'] }}"
2663 )
2664 }
2665
2666 pub(crate) fn lint_cfg(unescaped: &str) -> Self {
2667 UnexpectedCfgCargoHelp::LintCfg {
2668 cargo_toml_lint_cfg: Self::cargo_toml_lint_cfg(unescaped),
2669 }
2670 }
2671
2672 pub(crate) fn lint_cfg_and_build_rs(unescaped: &str, escaped: &str) -> Self {
2673 UnexpectedCfgCargoHelp::LintCfgAndBuildRs {
2674 cargo_toml_lint_cfg: Self::cargo_toml_lint_cfg(unescaped),
2675 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}\");"),
2676 }
2677 }
2678}
2679
2680#[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)]
2681#[help("to expect this configuration use `{$cmdline_arg}`")]
2682pub(crate) struct UnexpectedCfgRustcHelp {
2683 pub cmdline_arg: String,
2684}
2685
2686impl UnexpectedCfgRustcHelp {
2687 pub(crate) fn new(unescaped: &str) -> Self {
2688 Self { cmdline_arg: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("--check-cfg={0}", unescaped))
})format!("--check-cfg={unescaped}") }
2689 }
2690}
2691
2692#[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)]
2693#[note(
2694 "using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate"
2695)]
2696#[help("try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg")]
2697pub(crate) struct UnexpectedCfgRustcMacroHelp {
2698 pub macro_kind: &'static str,
2699 pub macro_name: Symbol,
2700}
2701
2702#[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)]
2703#[note(
2704 "using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate"
2705)]
2706#[help("try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg")]
2707#[help(
2708 "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}`"
2709)]
2710pub(crate) struct UnexpectedCfgCargoMacroHelp {
2711 pub macro_kind: &'static str,
2712 pub macro_name: Symbol,
2713 pub crate_name: Symbol,
2714}
2715
2716#[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)]
2717#[diag("unexpected `cfg` condition name: `{$name}`")]
2718pub(crate) struct UnexpectedCfgName {
2719 #[subdiagnostic]
2720 pub code_sugg: unexpected_cfg_name::CodeSuggestion,
2721 #[subdiagnostic]
2722 pub invocation_help: unexpected_cfg_name::InvocationHelp,
2723
2724 pub name: Symbol,
2725}
2726
2727pub(crate) mod unexpected_cfg_name {
2728 use rustc_errors::DiagSymbolList;
2729 use rustc_macros::Subdiagnostic;
2730 use rustc_span::{Ident, Span, Symbol};
2731
2732 #[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)]
2733 pub(crate) enum CodeSuggestion {
2734 #[help("consider defining some features in `Cargo.toml`")]
2735 DefineFeatures,
2736 #[multipart_suggestion(
2737 "there is a similar config predicate: `version(\"..\")`",
2738 applicability = "machine-applicable"
2739 )]
2740 VersionSyntax {
2741 #[suggestion_part(code = "(")]
2742 between_name_and_value: Span,
2743 #[suggestion_part(code = ")")]
2744 after_value: Span,
2745 },
2746 #[suggestion(
2747 "there is a config with a similar name and value",
2748 applicability = "maybe-incorrect",
2749 code = "{code}"
2750 )]
2751 SimilarNameAndValue {
2752 #[primary_span]
2753 span: Span,
2754 code: String,
2755 },
2756 #[suggestion(
2757 "there is a config with a similar name and no value",
2758 applicability = "maybe-incorrect",
2759 code = "{code}"
2760 )]
2761 SimilarNameNoValue {
2762 #[primary_span]
2763 span: Span,
2764 code: String,
2765 },
2766 #[suggestion(
2767 "there is a config with a similar name and different values",
2768 applicability = "maybe-incorrect",
2769 code = "{code}"
2770 )]
2771 SimilarNameDifferentValues {
2772 #[primary_span]
2773 span: Span,
2774 code: String,
2775 #[subdiagnostic]
2776 expected: Option<ExpectedValues>,
2777 },
2778 #[suggestion(
2779 "there is a config with a similar name",
2780 applicability = "maybe-incorrect",
2781 code = "{code}"
2782 )]
2783 SimilarName {
2784 #[primary_span]
2785 span: Span,
2786 code: String,
2787 #[subdiagnostic]
2788 expected: Option<ExpectedValues>,
2789 },
2790 SimilarValues {
2791 #[subdiagnostic]
2792 with_similar_values: Vec<FoundWithSimilarValue>,
2793 #[subdiagnostic]
2794 expected_names: Option<ExpectedNames>,
2795 },
2796 #[suggestion(
2797 "you may have meant to use `{$literal}` (notice the capitalization). Doing so makes this predicate evaluate to `{$literal}` unconditionally",
2798 applicability = "machine-applicable",
2799 style = "verbose",
2800 code = "{literal}"
2801 )]
2802 BooleanLiteral {
2803 #[primary_span]
2804 span: Span,
2805 literal: bool,
2806 },
2807 }
2808
2809 #[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)]
2810 #[help("expected values for `{$best_match}` are: {$possibilities}")]
2811 pub(crate) struct ExpectedValues {
2812 pub best_match: Symbol,
2813 pub possibilities: DiagSymbolList,
2814 }
2815
2816 #[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)]
2817 #[suggestion(
2818 "found config with similar value",
2819 applicability = "maybe-incorrect",
2820 code = "{code}"
2821 )]
2822 pub(crate) struct FoundWithSimilarValue {
2823 #[primary_span]
2824 pub span: Span,
2825 pub code: String,
2826 }
2827
2828 #[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)]
2829 #[help_once(
2830 "expected names are: {$possibilities}{$and_more ->
2831 [0] {\"\"}
2832 *[other] {\" \"}and {$and_more} more
2833 }"
2834 )]
2835 pub(crate) struct ExpectedNames {
2836 pub possibilities: DiagSymbolList<Ident>,
2837 pub and_more: usize,
2838 }
2839
2840 #[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)]
2841 pub(crate) enum InvocationHelp {
2842 #[note(
2843 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration"
2844 )]
2845 Cargo {
2846 #[subdiagnostic]
2847 macro_help: Option<super::UnexpectedCfgCargoMacroHelp>,
2848 #[subdiagnostic]
2849 help: Option<super::UnexpectedCfgCargoHelp>,
2850 },
2851 #[note(
2852 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration"
2853 )]
2854 Rustc {
2855 #[subdiagnostic]
2856 macro_help: Option<super::UnexpectedCfgRustcMacroHelp>,
2857 #[subdiagnostic]
2858 help: super::UnexpectedCfgRustcHelp,
2859 },
2860 }
2861}
2862
2863#[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)]
2864#[diag(
2865 "unexpected `cfg` condition value: {$has_value ->
2866 [true] `{$value}`
2867 *[false] (none)
2868 }"
2869)]
2870pub(crate) struct UnexpectedCfgValue {
2871 #[subdiagnostic]
2872 pub code_sugg: unexpected_cfg_value::CodeSuggestion,
2873 #[subdiagnostic]
2874 pub invocation_help: unexpected_cfg_value::InvocationHelp,
2875
2876 pub has_value: bool,
2877 pub value: String,
2878}
2879
2880pub(crate) mod unexpected_cfg_value {
2881 use rustc_errors::DiagSymbolList;
2882 use rustc_macros::Subdiagnostic;
2883 use rustc_span::{Span, Symbol};
2884
2885 #[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)]
2886 pub(crate) enum CodeSuggestion {
2887 ChangeValue {
2888 #[subdiagnostic]
2889 expected_values: ExpectedValues,
2890 #[subdiagnostic]
2891 suggestion: Option<ChangeValueSuggestion>,
2892 },
2893 #[note("no expected value for `{$name}`")]
2894 RemoveValue {
2895 #[subdiagnostic]
2896 suggestion: Option<RemoveValueSuggestion>,
2897
2898 name: Symbol,
2899 },
2900 #[note("no expected values for `{$name}`")]
2901 RemoveCondition {
2902 #[subdiagnostic]
2903 suggestion: RemoveConditionSuggestion,
2904
2905 name: Symbol,
2906 },
2907 ChangeName {
2908 #[subdiagnostic]
2909 suggestions: Vec<ChangeNameSuggestion>,
2910 },
2911 }
2912
2913 #[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)]
2914 pub(crate) enum ChangeValueSuggestion {
2915 #[suggestion(
2916 "there is a expected value with a similar name",
2917 code = r#""{best_match}""#,
2918 applicability = "maybe-incorrect"
2919 )]
2920 SimilarName {
2921 #[primary_span]
2922 span: Span,
2923 best_match: Symbol,
2924 },
2925 #[suggestion(
2926 "specify a config value",
2927 code = r#" = "{first_possibility}""#,
2928 applicability = "maybe-incorrect"
2929 )]
2930 SpecifyValue {
2931 #[primary_span]
2932 span: Span,
2933 first_possibility: Symbol,
2934 },
2935 }
2936
2937 #[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)]
2938 #[suggestion("remove the value", code = "", applicability = "maybe-incorrect")]
2939 pub(crate) struct RemoveValueSuggestion {
2940 #[primary_span]
2941 pub span: Span,
2942 }
2943
2944 #[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)]
2945 #[suggestion("remove the condition", code = "", applicability = "maybe-incorrect")]
2946 pub(crate) struct RemoveConditionSuggestion {
2947 #[primary_span]
2948 pub span: Span,
2949 }
2950
2951 #[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)]
2952 #[note(
2953 "expected values for `{$name}` are: {$have_none_possibility ->
2954 [true] {\"(none), \"}
2955 *[false] {\"\"}
2956 }{$possibilities}{$and_more ->
2957 [0] {\"\"}
2958 *[other] {\" \"}and {$and_more} more
2959 }"
2960 )]
2961 pub(crate) struct ExpectedValues {
2962 pub name: Symbol,
2963 pub have_none_possibility: bool,
2964 pub possibilities: DiagSymbolList,
2965 pub and_more: usize,
2966 }
2967
2968 #[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)]
2969 #[suggestion(
2970 "`{$value}` is an expected value for `{$name}`",
2971 code = "{name}",
2972 applicability = "maybe-incorrect",
2973 style = "verbose"
2974 )]
2975 pub(crate) struct ChangeNameSuggestion {
2976 #[primary_span]
2977 pub span: Span,
2978 pub name: Symbol,
2979 pub value: Symbol,
2980 }
2981
2982 #[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)]
2983 pub(crate) enum InvocationHelp {
2984 #[note(
2985 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration"
2986 )]
2987 Cargo {
2988 #[subdiagnostic]
2989 help: Option<CargoHelp>,
2990 #[subdiagnostic]
2991 macro_help: Option<super::UnexpectedCfgCargoMacroHelp>,
2992 },
2993 #[note(
2994 "see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration"
2995 )]
2996 Rustc {
2997 #[subdiagnostic]
2998 help: Option<super::UnexpectedCfgRustcHelp>,
2999 #[subdiagnostic]
3000 macro_help: Option<super::UnexpectedCfgRustcMacroHelp>,
3001 },
3002 }
3003
3004 #[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)]
3005 pub(crate) enum CargoHelp {
3006 #[help("consider adding `{$value}` as a feature in `Cargo.toml`")]
3007 AddFeature {
3008 value: Symbol,
3009 },
3010 #[help("consider defining some features in `Cargo.toml`")]
3011 DefineFeatures,
3012 Other(#[subdiagnostic] super::UnexpectedCfgCargoHelp),
3013 }
3014}
3015
3016#[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)]
3018#[diag(
3019 "{$num_suggestions ->
3020 [1] attribute must be of the form {$suggestions}
3021 *[other] valid forms for the attribute are {$suggestions}
3022 }"
3023)]
3024pub(crate) struct IllFormedAttributeInput {
3025 pub num_suggestions: usize,
3026 pub suggestions: DiagArgValue,
3027 #[note("for more information, visit <{$docs}>")]
3028 pub has_docs: bool,
3029 pub docs: &'static str,
3030 #[subdiagnostic]
3031 pub help: Option<IllFormedAttributeInputHelp>,
3032}
3033
3034#[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)]
3035#[help(
3036 "if you meant to silence a warning, consider using #![allow({$lint})] or #![expect({$lint})]"
3037)]
3038pub(crate) struct IllFormedAttributeInputHelp {
3039 pub lint: String,
3040}
3041
3042#[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)]
3043#[diag("creating a {$shared_label}reference to mutable static")]
3044pub(crate) struct RefOfMutStatic<'a> {
3045 #[label("{$shared_label}reference to mutable static")]
3046 pub span: Span,
3047 #[subdiagnostic]
3048 pub sugg: Option<MutRefSugg>,
3049 pub shared_label: &'a str,
3050 #[note(
3051 "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"
3052 )]
3053 pub shared_note: bool,
3054 #[note(
3055 "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"
3056 )]
3057 pub mut_note: bool,
3058}
3059
3060#[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)]
3061pub(crate) enum MutRefSugg {
3062 #[multipart_suggestion(
3063 "use `&raw const` instead to create a raw pointer",
3064 style = "verbose",
3065 applicability = "maybe-incorrect"
3066 )]
3067 Shared {
3068 #[suggestion_part(code = "&raw const ")]
3069 span: Span,
3070 },
3071 #[multipart_suggestion(
3072 "use `&raw mut` instead to create a raw pointer",
3073 style = "verbose",
3074 applicability = "maybe-incorrect"
3075 )]
3076 Mut {
3077 #[suggestion_part(code = "&raw mut ")]
3078 span: Span,
3079 },
3080}
3081
3082#[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)]
3083#[diag("`use` of a local item without leading `self::`, `super::`, or `crate::`")]
3084pub(crate) struct UnqualifiedLocalImportsDiag;
3085
3086#[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)]
3087#[diag("direct cast of function item into an integer")]
3088pub(crate) struct FunctionCastsAsIntegerDiag<'tcx> {
3089 #[subdiagnostic]
3090 pub(crate) sugg: FunctionCastsAsIntegerSugg<'tcx>,
3091}
3092
3093#[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)]
3094#[suggestion(
3095 "first cast to a pointer `as *const ()`",
3096 code = " as *const ()",
3097 applicability = "machine-applicable",
3098 style = "verbose"
3099)]
3100pub(crate) struct FunctionCastsAsIntegerSugg<'tcx> {
3101 #[primary_span]
3102 pub suggestion: Span,
3103 pub cast_to_ty: Ty<'tcx>,
3104}
3105
3106#[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)]
3107pub(crate) struct MismatchedLifetimeSyntaxes {
3108 pub inputs: LifetimeSyntaxCategories<Vec<Span>>,
3109 pub outputs: LifetimeSyntaxCategories<Vec<Span>>,
3110
3111 pub suggestions: Vec<MismatchedLifetimeSyntaxesSuggestion>,
3112}
3113
3114impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MismatchedLifetimeSyntaxes {
3115 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
3116 let counts = self.inputs.len() + self.outputs.len();
3117 let message = match counts {
3118 LifetimeSyntaxCategories { hidden: 0, elided: 0, named: 0 } => {
3119 {
::core::panicking::panic_fmt(format_args!("No lifetime mismatch detected"));
}panic!("No lifetime mismatch detected")
3120 }
3121
3122 LifetimeSyntaxCategories { hidden: _, elided: _, named: 0 } => {
3123 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")
3124 }
3125
3126 LifetimeSyntaxCategories { hidden: _, elided: 0, named: _ } => {
3127 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")
3128 }
3129
3130 LifetimeSyntaxCategories { hidden: 0, elided: _, named: _ } => {
3131 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")
3132 }
3133
3134 LifetimeSyntaxCategories { hidden: _, elided: _, named: _ } => {
3135 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")
3136 }
3137 };
3138 let mut diag = Diag::new(dcx, level, message);
3139
3140 for s in self.inputs.hidden {
3141 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is hidden here"))msg!("the lifetime is hidden here"));
3142 }
3143 for s in self.inputs.elided {
3144 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is elided here"))msg!("the lifetime is elided here"));
3145 }
3146 for s in self.inputs.named {
3147 diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is named here"))msg!("the lifetime is named here"));
3148 }
3149
3150 let mut hidden_output_counts: FxIndexMap<Span, usize> = FxIndexMap::default();
3151 for s in self.outputs.hidden {
3152 *hidden_output_counts.entry(s).or_insert(0) += 1;
3153 }
3154 for (span, count) in hidden_output_counts {
3155 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!(
3156 "the same {$count ->
3157 [one] lifetime
3158 *[other] lifetimes
3159 } {$count ->
3160 [one] is
3161 *[other] are
3162 } hidden here"
3163 )
3164 .arg("count", count)
3165 .format();
3166 diag.span_label(span, label);
3167 }
3168 for s in self.outputs.elided {
3169 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"));
3170 }
3171 for s in self.outputs.named {
3172 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"));
3173 }
3174
3175 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same lifetime is referred to in inconsistent ways, making the signature confusing"))msg!(
3176 "the same lifetime is referred to in inconsistent ways, making the signature confusing"
3177 ));
3178
3179 let mut suggestions = self.suggestions.into_iter();
3180 if let Some(s) = suggestions.next() {
3181 diag.subdiagnostic(s);
3182
3183 for mut s in suggestions {
3184 s.make_optional_alternative();
3185 diag.subdiagnostic(s);
3186 }
3187 }
3188 diag
3189 }
3190}
3191
3192#[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)]
3193pub(crate) enum MismatchedLifetimeSyntaxesSuggestion {
3194 Implicit {
3195 suggestions: Vec<Span>,
3196 optional_alternative: bool,
3197 },
3198
3199 Mixed {
3200 implicit_suggestions: Vec<Span>,
3201 explicit_anonymous_suggestions: Vec<(Span, String)>,
3202 optional_alternative: bool,
3203 },
3204
3205 Explicit {
3206 lifetime_name: String,
3207 suggestions: Vec<(Span, String)>,
3208 optional_alternative: bool,
3209 },
3210}
3211
3212impl MismatchedLifetimeSyntaxesSuggestion {
3213 fn make_optional_alternative(&mut self) {
3214 use MismatchedLifetimeSyntaxesSuggestion::*;
3215
3216 let optional_alternative = match self {
3217 Implicit { optional_alternative, .. }
3218 | Mixed { optional_alternative, .. }
3219 | Explicit { optional_alternative, .. } => optional_alternative,
3220 };
3221
3222 *optional_alternative = true;
3223 }
3224}
3225
3226impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
3227 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
3228 use MismatchedLifetimeSyntaxesSuggestion::*;
3229
3230 let style = |optional_alternative| {
3231 if optional_alternative {
3232 SuggestionStyle::CompletelyHidden
3233 } else {
3234 SuggestionStyle::ShowAlways
3235 }
3236 };
3237
3238 let applicability = |optional_alternative| {
3239 if optional_alternative {
3242 Applicability::MaybeIncorrect
3243 } else {
3244 Applicability::MachineApplicable
3245 }
3246 };
3247
3248 match self {
3249 Implicit { suggestions, optional_alternative } => {
3250 let suggestions = suggestions.into_iter().map(|s| (s, String::new())).collect();
3251 diag.multipart_suggestion_with_style(
3252 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the lifetime name from references"))msg!("remove the lifetime name from references"),
3253 suggestions,
3254 applicability(optional_alternative),
3255 style(optional_alternative),
3256 );
3257 }
3258
3259 Mixed {
3260 implicit_suggestions,
3261 explicit_anonymous_suggestions,
3262 optional_alternative,
3263 } => {
3264 let message = if implicit_suggestions.is_empty() {
3265 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `'_` for type paths"))msg!("use `'_` for type paths")
3266 } else {
3267 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")
3268 };
3269
3270 let implicit_suggestions =
3271 implicit_suggestions.into_iter().map(|s| (s, String::new()));
3272
3273 let suggestions =
3274 implicit_suggestions.chain(explicit_anonymous_suggestions).collect();
3275
3276 diag.multipart_suggestion_with_style(
3277 message,
3278 suggestions,
3279 applicability(optional_alternative),
3280 style(optional_alternative),
3281 );
3282 }
3283
3284 Explicit { lifetime_name, suggestions, optional_alternative } => {
3285 let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consistently use `{$lifetime_name}`"))msg!("consistently use `{$lifetime_name}`")
3286 .arg("lifetime_name", lifetime_name)
3287 .format();
3288 diag.multipart_suggestion_with_style(
3289 msg,
3290 suggestions,
3291 applicability(optional_alternative),
3292 style(optional_alternative),
3293 );
3294 }
3295 }
3296 }
3297}
3298
3299#[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)]
3300#[diag("unused attribute")]
3301#[note(
3302 "{$valid_without_list ->
3303 [true] using `{$attr_path}` with an empty list is equivalent to not using a list at all
3304 *[other] using `{$attr_path}` with an empty list has no effect
3305 }"
3306)]
3307pub(crate) struct EmptyAttributeList {
3308 #[suggestion(
3309 "{$valid_without_list ->
3310 [true] remove these parentheses
3311 *[other] remove this attribute
3312 }",
3313 code = "",
3314 applicability = "machine-applicable"
3315 )]
3316 pub attr_span: Span,
3317 pub attr_path: String,
3318 pub valid_without_list: bool,
3319}
3320
3321#[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)]
3322#[diag("`#[{$name}]` attribute cannot be used on {$target}")]
3323#[warning(
3324 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3325)]
3326#[help("`#[{$name}]` can {$only}be applied to {$applied}")]
3327pub(crate) struct InvalidTargetLint {
3328 pub name: String,
3329 pub target: &'static str,
3330 pub applied: DiagArgValue,
3331 pub only: &'static str,
3332 #[suggestion(
3333 "remove the attribute",
3334 code = "",
3335 applicability = "machine-applicable",
3336 style = "tool-only"
3337 )]
3338 pub attr_span: Span,
3339}
3340
3341#[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)]
3342#[diag(
3343 "{$is_used_as_inner ->
3344 [false] crate-level attribute should be an inner attribute: add an exclamation mark: `#![{$name}]`
3345 *[other] the `#![{$name}]` attribute can only be used at the crate root
3346 }"
3347)]
3348pub(crate) struct InvalidAttrStyle {
3349 pub name: String,
3350 pub is_used_as_inner: bool,
3351 #[note("this attribute does not have an `!`, which means it is applied to this {$target}")]
3352 pub target_span: Option<Span>,
3353 pub target: &'static str,
3354}
3355
3356#[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)]
3357#[diag("unused attribute")]
3358pub(crate) struct UnusedDuplicate {
3359 #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
3360 pub this: Span,
3361 #[note("attribute also specified here")]
3362 pub other: Span,
3363 #[warning(
3364 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3365 )]
3366 pub warning: bool,
3367}
3368
3369#[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)]
3370#[diag("malformed `doc` attribute input")]
3371#[warning(
3372 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3373)]
3374pub(crate) struct MalformedDoc;
3375
3376#[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)]
3377#[diag("didn't expect any arguments here")]
3378#[warning(
3379 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3380)]
3381pub(crate) struct ExpectedNoArgs;
3382
3383#[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)]
3384#[diag("expected this to be of the form `... = \"...\"`")]
3385#[warning(
3386 "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
3387)]
3388pub(crate) struct ExpectedNameValue;
3389
3390#[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)]
3391#[diag("unsafe attribute used without unsafe")]
3392pub(crate) struct UnsafeAttrOutsideUnsafeLint {
3393 #[label("usage of unsafe attribute")]
3394 pub span: Span,
3395 #[subdiagnostic]
3396 pub suggestion: Option<UnsafeAttrOutsideUnsafeSuggestion>,
3397}
3398
3399#[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)]
3400#[multipart_suggestion("wrap the attribute in `unsafe(...)`", applicability = "machine-applicable")]
3401pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
3402 #[suggestion_part(code = "unsafe(")]
3403 pub left: Span,
3404 #[suggestion_part(code = ")")]
3405 pub right: Span,
3406}
3407
3408#[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)]
3409#[diag("doc alias is duplicated")]
3410pub(crate) struct DocAliasDuplicated {
3411 #[label("first defined here")]
3412 pub first_defn: Span,
3413}
3414
3415#[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)]
3416#[diag("only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]`")]
3417pub(crate) struct DocAutoCfgExpectsHideOrShow;
3418
3419#[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)]
3420#[diag("there exists a built-in attribute with the same name")]
3421pub(crate) struct AmbiguousDeriveHelpers;
3422
3423#[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)]
3424#[diag("`#![doc(auto_cfg({$attr_name}(...)))]` only accepts identifiers or key/value items")]
3425pub(crate) struct DocAutoCfgHideShowUnexpectedItem {
3426 pub attr_name: Symbol,
3427}
3428
3429#[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)]
3430#[diag("`#![doc(auto_cfg({$attr_name}(...)))]` expects a list of items")]
3431pub(crate) struct DocAutoCfgHideShowExpectsList {
3432 pub attr_name: Symbol,
3433}
3434
3435#[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)]
3436#[diag("invalid `doc` attribute")]
3437pub(crate) struct DocInvalid;
3438
3439#[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)]
3440#[diag("unknown `doc` attribute `include`")]
3441pub(crate) struct DocUnknownInclude {
3442 pub inner: &'static str,
3443 pub value: Symbol,
3444 #[suggestion(
3445 "use `doc = include_str!` instead",
3446 code = "#{inner}[doc = include_str!(\"{value}\")]"
3447 )]
3448 pub sugg: (Span, Applicability),
3449}
3450
3451#[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)]
3452#[diag("unknown `doc` attribute `spotlight`")]
3453#[note("`doc(spotlight)` was renamed to `doc(notable_trait)`")]
3454#[note("`doc(spotlight)` is now a no-op")]
3455pub(crate) struct DocUnknownSpotlight {
3456 #[suggestion(
3457 "use `notable_trait` instead",
3458 style = "short",
3459 applicability = "machine-applicable",
3460 code = "notable_trait"
3461 )]
3462 pub sugg_span: Span,
3463}
3464
3465#[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)]
3466#[diag("unknown `doc` attribute `{$name}`")]
3467#[note(
3468 "`doc` attribute `{$name}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>"
3469)]
3470#[note("`doc({$name})` is now a no-op")]
3471pub(crate) struct DocUnknownPasses {
3472 pub name: Symbol,
3473 #[label("no longer functions")]
3474 pub note_span: Span,
3475}
3476
3477#[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)]
3478#[diag("unknown `doc` attribute `plugins`")]
3479#[note(
3480 "`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>"
3481)]
3482#[note("`doc(plugins)` is now a no-op")]
3483pub(crate) struct DocUnknownPlugins {
3484 #[label("no longer functions")]
3485 pub label_span: Span,
3486}
3487
3488#[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)]
3489#[diag("unknown `doc` attribute `{$name}`")]
3490pub(crate) struct DocUnknownAny {
3491 pub name: Symbol,
3492}
3493
3494#[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)]
3495#[diag("expected boolean for `#[doc(auto_cfg = ...)]`")]
3496pub(crate) struct DocAutoCfgWrongLiteral;
3497
3498#[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)]
3499#[diag("`#[doc(test(...)]` takes a list of attributes")]
3500pub(crate) struct DocTestTakesList;
3501
3502#[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)]
3503#[diag("unknown `doc(test)` attribute `{$name}`")]
3504pub(crate) struct DocTestUnknown {
3505 pub name: Symbol,
3506}
3507
3508#[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)]
3509#[diag("`#![doc(test(...)]` does not take a literal")]
3510pub(crate) struct DocTestLiteral;
3511
3512#[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)]
3513#[diag("this attribute can only be applied at the crate level")]
3514#[note(
3515 "read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information"
3516)]
3517pub(crate) struct AttrCrateLevelOnly;
3518
3519#[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)]
3520#[diag("`#[diagnostic::do_not_recommend]` does not expect any arguments")]
3521pub(crate) struct DoNotRecommendDoesNotExpectArgs;
3522
3523#[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)]
3524#[diag("invalid `crate_type` value")]
3525pub(crate) struct UnknownCrateTypes {
3526 #[subdiagnostic]
3527 pub sugg: Option<UnknownCrateTypesSuggestion>,
3528}
3529
3530#[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)]
3531#[suggestion("did you mean", code = r#""{snippet}""#, applicability = "maybe-incorrect")]
3532pub(crate) struct UnknownCrateTypesSuggestion {
3533 #[primary_span]
3534 pub span: Span,
3535 pub snippet: Symbol,
3536}
3537
3538#[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)]
3539#[diag("positional format arguments are not allowed here")]
3540#[help(
3541 "only named format arguments with the name of one of the generic types are allowed in this context"
3542)]
3543pub(crate) struct DisallowedPositionalArgument;
3544
3545#[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)]
3546#[diag("invalid format specifier")]
3547#[help("no format specifier are supported in this position")]
3548pub(crate) struct InvalidFormatSpecifier;
3549
3550#[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)]
3551#[diag("{$description}")]
3552pub(crate) struct WrappedParserError<'a> {
3553 pub description: &'a str,
3554 #[label("{$label}")]
3555 pub span: Span,
3556 pub label: &'a str,
3557}
3558
3559#[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)]
3560#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")]
3561pub(crate) struct IgnoredDiagnosticOption {
3562 pub option_name: Symbol,
3563 #[label("`{$option_name}` is first declared here")]
3564 pub first_span: Span,
3565 #[label("`{$option_name}` is later redundantly declared here")]
3566 pub later_span: Span,
3567}
3568
3569#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingOptionsForOnUnimplementedAttr where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingOptionsForOnUnimplementedAttr => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing options for `on_unimplemented` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("at least one of the `message`, `note` and `label` options are expected")));
;
diag
}
}
}
}
};Diagnostic)]
3570#[diag("missing options for `on_unimplemented` attribute")]
3571#[help("at least one of the `message`, `note` and `label` options are expected")]
3572pub(crate) struct MissingOptionsForOnUnimplementedAttr;
3573
3574#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingOptionsForOnConstAttr where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingOptionsForOnConstAttr => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing options for `on_const` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("at least one of the `message`, `note` and `label` options are expected")));
;
diag
}
}
}
}
};Diagnostic)]
3575#[diag("missing options for `on_const` attribute")]
3576#[help("at least one of the `message`, `note` and `label` options are expected")]
3577pub(crate) struct MissingOptionsForOnConstAttr;
3578
3579#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MissingOptionsForOnMoveAttr where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MissingOptionsForOnMoveAttr => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing options for `on_move` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("at least one of the `message`, `note` and `label` options are expected")));
;
diag
}
}
}
}
};Diagnostic)]
3580#[diag("missing options for `on_move` attribute")]
3581#[help("at least one of the `message`, `note` and `label` options are expected")]
3582pub(crate) struct MissingOptionsForOnMoveAttr;
3583
3584#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MalformedOnUnimplementedAttrLint where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalformedOnUnimplementedAttrLint { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("malformed `on_unimplemented` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `message`, `note` and `label` are allowed as options")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid option found here")));
diag
}
}
}
}
};Diagnostic)]
3585#[diag("malformed `on_unimplemented` attribute")]
3586#[help("only `message`, `note` and `label` are allowed as options")]
3587pub(crate) struct MalformedOnUnimplementedAttrLint {
3588 #[label("invalid option found here")]
3589 pub span: Span,
3590}
3591
3592#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MalformedOnConstAttrLint where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalformedOnConstAttrLint { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("malformed `on_const` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `message`, `note` and `label` are allowed as options")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid option found here")));
diag
}
}
}
}
};Diagnostic)]
3593#[diag("malformed `on_const` attribute")]
3594#[help("only `message`, `note` and `label` are allowed as options")]
3595pub(crate) struct MalformedOnConstAttrLint {
3596 #[label("invalid option found here")]
3597 pub span: Span,
3598}
3599
3600#[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)]
3601#[diag("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")]
3602#[note("this method was used to add checks to the `Eq` derive macro")]
3603pub(crate) struct EqInternalMethodImplemented;
3604
3605#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MalformedOnMoveAttrLint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalformedOnMoveAttrLint { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown or malformed `on_move` attribute")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `message`, `note` and `label` are allowed as options. Their values must be string literals")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid option found here")));
diag
}
}
}
}
};Diagnostic)]
3606#[diag("unknown or malformed `on_move` attribute")]
3607#[help(
3608 "only `message`, `note` and `label` are allowed as options. Their values must be string literals"
3609)]
3610pub(crate) struct MalformedOnMoveAttrLint {
3611 #[label("invalid option found here")]
3612 pub span: Span,
3613}
3614
3615#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OnMoveMalformedFormatLiterals where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OnMoveMalformedFormatLiterals { name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown parameter `{$name}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expect `Self` as format argument")));
;
diag.arg("name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
3616#[diag("unknown parameter `{$name}`")]
3617#[help("expect `Self` as format argument")]
3618pub(crate) struct OnMoveMalformedFormatLiterals {
3619 pub name: Symbol,
3620}
3621
3622#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OnMoveMalformedAttrExpectedLiteralOrDelimiter where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OnMoveMalformedAttrExpectedLiteralOrDelimiter => {
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)]
3623#[diag("expected a literal or missing delimiter")]
3624#[help(
3625 "only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
3626)]
3627pub(crate) struct OnMoveMalformedAttrExpectedLiteralOrDelimiter;