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