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