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