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