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