1use rustc_errors::codes::*;
2use rustc_errors::{
3Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
4MultiSpan, Subdiagnostic, msg,
5};
6use rustc_macros::{Diagnostic, Subdiagnostic};
7use rustc_middle::ty::{self, Ty};
8use rustc_pattern_analysis::errors::Uncovered;
9use rustc_pattern_analysis::rustc::RustcPatCtxt;
10use rustc_span::{Ident, Span, Symbol};
1112#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallToDeprecatedSafeFnRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallToDeprecatedSafeFnRequiresUnsafe {
span: __binding_0, function: __binding_1, sub: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to deprecated safe function `{$function}` is unsafe and requires unsafe block")));
;
diag.arg("function", __binding_1);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
diag.subdiagnostic(__binding_2);
diag
}
}
}
}
};Diagnostic)]
13#[diag("call to deprecated safe function `{$function}` is unsafe and requires unsafe block")]
14pub(crate) struct CallToDeprecatedSafeFnRequiresUnsafe {
15#[label("call to unsafe function")]
16pub(crate) span: Span,
17pub(crate) function: String,
18#[subdiagnostic]
19pub(crate) sub: CallToDeprecatedSafeFnRequiresUnsafeSub,
20}
2122#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
CallToDeprecatedSafeFnRequiresUnsafeSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CallToDeprecatedSafeFnRequiresUnsafeSub {
start_of_line_suggestion: __binding_0,
start_of_line: __binding_1,
left: __binding_2,
right: __binding_3,
guarantee: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_0 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_0))
});
let __code_1 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unsafe {{ "))
});
let __code_2 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" }}"))
});
suggestions.push((__binding_1, __code_0));
suggestions.push((__binding_2, __code_1));
suggestions.push((__binding_3, __code_2));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("guarantee".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("you can wrap the call in an `unsafe` block if you can guarantee {$guarantee}")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
23#[multipart_suggestion(
24"you can wrap the call in an `unsafe` block if you can guarantee {$guarantee}",
25 applicability = "machine-applicable"
26)]
27pub(crate) struct CallToDeprecatedSafeFnRequiresUnsafeSub {
28pub(crate) start_of_line_suggestion: String,
29#[suggestion_part(code = "{start_of_line_suggestion}")]
30pub(crate) start_of_line: Span,
31#[suggestion_part(code = "unsafe {{ ")]
32pub(crate) left: Span,
33#[suggestion_part(code = " }}")]
34pub(crate) right: Span,
35pub(crate) guarantee: String,
36}
3738#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
span: __binding_0,
function: __binding_1,
unsafe_not_inherited_note: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function `{$function}` is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consult the function's documentation for information on how to avoid undefined behavior")));
;
diag.arg("function", __binding_1);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
39#[diag("call to unsafe function `{$function}` is unsafe and requires unsafe block", code = E0133)]
40#[note("consult the function's documentation for information on how to avoid undefined behavior")]
41pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
42#[label("call to unsafe function")]
43pub(crate) span: Span,
44pub(crate) function: String,
45#[subdiagnostic]
46pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
47}
4849#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consult the function's documentation for information on how to avoid undefined behavior")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
50#[diag("call to unsafe function is unsafe and requires unsafe block", code = E0133)]
51#[note("consult the function's documentation for information on how to avoid undefined behavior")]
52pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
53#[label("call to unsafe function")]
54pub(crate) span: Span,
55#[subdiagnostic]
56pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
57}
5859#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of inline assembly is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inline assembly is entirely unchecked and can cause undefined behavior")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of inline assembly")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
60#[diag("use of inline assembly is unsafe and requires unsafe block", code = E0133)]
61#[note("inline assembly is entirely unchecked and can cause undefined behavior")]
62pub(crate) struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
63#[label("use of inline assembly")]
64pub(crate) span: Span,
65#[subdiagnostic]
66pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
67}
6869#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsafe
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing type with an unsafe field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe fields may carry library invariants")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initialization of struct with unsafe field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
70#[diag("initializing type with an unsafe field is unsafe and requires unsafe block", code = E0133)]
71#[note("unsafe fields may carry library invariants")]
72pub(crate) struct UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsafe {
73#[label("initialization of struct with unsafe field")]
74pub(crate) span: Span,
75#[subdiagnostic]
76pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
77}
7879#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of mutable static is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of mutable static")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
80#[diag("use of mutable static is unsafe and requires unsafe block", code = E0133)]
81#[note(
82"mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior"
83)]
84pub(crate) struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
85#[label("use of mutable static")]
86pub(crate) span: Span,
87#[subdiagnostic]
88pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
89}
9091#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of extern static is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of extern static")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
92#[diag("use of extern static is unsafe and requires unsafe block", code = E0133)]
93#[note(
94"extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior"
95)]
96pub(crate) struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
97#[label("use of extern static")]
98pub(crate) span: Span,
99#[subdiagnostic]
100pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
101}
102103#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unsafe field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe fields may carry library invariants")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unsafe field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
104#[diag("use of unsafe field is unsafe and requires unsafe block", code = E0133)]
105#[note("unsafe fields may carry library invariants")]
106pub(crate) struct UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe {
107#[label("use of unsafe field")]
108pub(crate) span: Span,
109#[subdiagnostic]
110pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
111}
112113#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereference of raw pointer is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereference of raw pointer")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
114#[diag("dereference of raw pointer is unsafe and requires unsafe block", code = E0133)]
115#[note(
116"raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior"
117)]
118pub(crate) struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
119#[label("dereference of raw pointer")]
120pub(crate) span: Span,
121#[subdiagnostic]
122pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
123}
124125#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("access to union field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the field may not be properly initialized: using uninitialized data will cause undefined behavior")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("access to union field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
126#[diag("access to union field is unsafe and requires unsafe block", code = E0133)]
127#[note(
128"the field may not be properly initialized: using uninitialized data will cause undefined behavior"
129)]
130pub(crate) struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
131#[label("access to union field")]
132pub(crate) span: Span,
133#[subdiagnostic]
134pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
135}
136137#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of layout constrained field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutating layout constrained fields cannot statically be checked for valid values")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of layout constrained field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
138#[diag(
139"mutation of layout constrained field is unsafe and requires unsafe block",
140 code = E0133
141)]
142#[note("mutating layout constrained fields cannot statically be checked for valid values")]
143pub(crate) struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
144#[label("mutation of layout constrained field")]
145pub(crate) span: Span,
146#[subdiagnostic]
147pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
148}
149150#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of layout constrained field with interior mutability is unsafe and requires unsafe block")));
diag.code(E0133);
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of layout constrained field with interior mutability")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
151#[diag(
152"borrow of layout constrained field with interior mutability is unsafe and requires unsafe block",
153 code = E0133,
154)]
155pub(crate) struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
156#[label("borrow of layout constrained field with interior mutability")]
157pub(crate) span: Span,
158#[subdiagnostic]
159pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
160}
161162#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe binder cast is unsafe and requires unsafe block information that may be required to uphold safety guarantees of a type")));
diag.code(E0133);
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe binder cast")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
163#[diag(
164"unsafe binder cast is unsafe and requires unsafe block information that may be required to uphold safety guarantees of a type",
165 code = E0133,
166)]
167pub(crate) struct UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe {
168#[label("unsafe binder cast")]
169pub(crate) span: Span,
170#[subdiagnostic]
171pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
172}
173174#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
span: __binding_0,
function: __binding_1,
missing_target_features: __binding_2,
missing_target_features_count: __binding_3,
note: __binding_4,
build_target_features: __binding_5,
build_target_features_count: __binding_6,
unsafe_not_inherited_note: __binding_7 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block")));
diag.code(E0133);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->\n [1] feature\n *[count] features\n }: {$missing_target_features}")));
;
diag.arg("function", __binding_1);
diag.arg("missing_target_features", __binding_2);
diag.arg("missing_target_features_count", __binding_3);
diag.arg("build_target_features", __binding_5);
diag.arg("build_target_features_count", __binding_6);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to function with `#[target_feature]`")));
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$build_target_features} target {$build_target_features_count ->\n [1] feature\n *[count] features\n } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->\n [1] it\n *[count] them\n } in `#[target_feature]`")));
}
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
diag
}
}
}
}
};Diagnostic)]
175#[diag("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block", code = E0133)]
176#[help(
177"in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
178 [1] feature
179 *[count] features
180 }: {$missing_target_features}"
181)]
182pub(crate) struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
183#[label("call to function with `#[target_feature]`")]
184pub(crate) span: Span,
185pub(crate) function: String,
186pub(crate) missing_target_features: DiagArgValue,
187pub(crate) missing_target_features_count: usize,
188#[note("the {$build_target_features} target {$build_target_features_count ->
189 [1] feature
190 *[count] features
191 } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->
192 [1] it
193 *[count] them
194 } in `#[target_feature]`")]
195pub(crate) note: bool,
196pub(crate) build_target_features: DiagArgValue,
197pub(crate) build_target_features_count: usize,
198#[subdiagnostic]
199pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
200}
201202#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallToUnsafeFunctionRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallToUnsafeFunctionRequiresUnsafe {
span: __binding_0,
function: __binding_1,
unsafe_not_inherited_note: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function `{$function}` is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consult the function's documentation for information on how to avoid undefined behavior")));
;
diag.arg("function", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
203#[diag("call to unsafe function `{$function}` is unsafe and requires unsafe block", code = E0133)]
204#[note("consult the function's documentation for information on how to avoid undefined behavior")]
205pub(crate) struct CallToUnsafeFunctionRequiresUnsafe {
206#[primary_span]
207 #[label("call to unsafe function")]
208pub(crate) span: Span,
209pub(crate) function: String,
210#[subdiagnostic]
211pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
212}
213214#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallToUnsafeFunctionRequiresUnsafeNameless where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallToUnsafeFunctionRequiresUnsafeNameless {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consult the function's documentation for information on how to avoid undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
215#[diag("call to unsafe function is unsafe and requires unsafe block", code = E0133)]
216#[note("consult the function's documentation for information on how to avoid undefined behavior")]
217pub(crate) struct CallToUnsafeFunctionRequiresUnsafeNameless {
218#[primary_span]
219 #[label("call to unsafe function")]
220pub(crate) span: Span,
221#[subdiagnostic]
222pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
223}
224225#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0,
function: __binding_1,
unsafe_not_inherited_note: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function `{$function}` is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consult the function's documentation for information on how to avoid undefined behavior")));
;
diag.arg("function", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
226#[diag("call to unsafe function `{$function}` is unsafe and requires unsafe function or block", code = E0133)]
227#[note("consult the function's documentation for information on how to avoid undefined behavior")]
228pub(crate) struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
229#[primary_span]
230 #[label("call to unsafe function")]
231pub(crate) span: Span,
232pub(crate) function: String,
233#[subdiagnostic]
234pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
235}
236237#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consult the function's documentation for information on how to avoid undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
238#[diag(
239"call to unsafe function is unsafe and requires unsafe function or block",
240 code = E0133
241)]
242#[note("consult the function's documentation for information on how to avoid undefined behavior")]
243pub(crate) struct CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
244#[primary_span]
245 #[label("call to unsafe function")]
246pub(crate) span: Span,
247#[subdiagnostic]
248pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
249}
250251#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfInlineAssemblyRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfInlineAssemblyRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of inline assembly is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inline assembly is entirely unchecked and can cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of inline assembly")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
252#[diag("use of inline assembly is unsafe and requires unsafe block", code = E0133)]
253#[note("inline assembly is entirely unchecked and can cause undefined behavior")]
254pub(crate) struct UseOfInlineAssemblyRequiresUnsafe {
255#[primary_span]
256 #[label("use of inline assembly")]
257pub(crate) span: Span,
258#[subdiagnostic]
259pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
260}
261262#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of inline assembly is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("inline assembly is entirely unchecked and can cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of inline assembly")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
263#[diag("use of inline assembly is unsafe and requires unsafe function or block", code = E0133)]
264#[note("inline assembly is entirely unchecked and can cause undefined behavior")]
265pub(crate) struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
266#[primary_span]
267 #[label("use of inline assembly")]
268pub(crate) span: Span,
269#[subdiagnostic]
270pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
271}
272273#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InitializingTypeWithUnsafeFieldRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InitializingTypeWithUnsafeFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing type with an unsafe field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe fields may carry library invariants")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initialization of struct with unsafe field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
274#[diag("initializing type with an unsafe field is unsafe and requires unsafe block", code = E0133)]
275#[note("unsafe fields may carry library invariants")]
276pub(crate) struct InitializingTypeWithUnsafeFieldRequiresUnsafe {
277#[primary_span]
278 #[label("initialization of struct with unsafe field")]
279pub(crate) span: Span,
280#[subdiagnostic]
281pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
282}
283284#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InitializingTypeWithUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InitializingTypeWithUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing type with an unsafe field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe fields may carry library invariants")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initialization of struct with unsafe field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
285#[diag(
286"initializing type with an unsafe field is unsafe and requires unsafe block",
287 code = E0133
288)]
289#[note("unsafe fields may carry library invariants")]
290pub(crate) struct InitializingTypeWithUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
291#[primary_span]
292 #[label("initialization of struct with unsafe field")]
293pub(crate) span: Span,
294#[subdiagnostic]
295pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
296}
297298#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfMutableStaticRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfMutableStaticRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of mutable static is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of mutable static")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
299#[diag("use of mutable static is unsafe and requires unsafe block", code = E0133)]
300#[note(
301"mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior"
302)]
303pub(crate) struct UseOfMutableStaticRequiresUnsafe {
304#[primary_span]
305 #[label("use of mutable static")]
306pub(crate) span: Span,
307#[subdiagnostic]
308pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
309}
310311#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of mutable static is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of mutable static")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
312#[diag("use of mutable static is unsafe and requires unsafe function or block", code = E0133)]
313#[note(
314"mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior"
315)]
316pub(crate) struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
317#[primary_span]
318 #[label("use of mutable static")]
319pub(crate) span: Span,
320#[subdiagnostic]
321pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
322}
323324#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfExternStaticRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfExternStaticRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of extern static is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of extern static")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
325#[diag("use of extern static is unsafe and requires unsafe block", code = E0133)]
326#[note(
327"extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior"
328)]
329pub(crate) struct UseOfExternStaticRequiresUnsafe {
330#[primary_span]
331 #[label("use of extern static")]
332pub(crate) span: Span,
333#[subdiagnostic]
334pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
335}
336337#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of extern static is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of extern static")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
338#[diag("use of extern static is unsafe and requires unsafe function or block", code = E0133)]
339#[note(
340"extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior"
341)]
342pub(crate) struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
343#[primary_span]
344 #[label("use of extern static")]
345pub(crate) span: Span,
346#[subdiagnostic]
347pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
348}
349350#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfUnsafeFieldRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfUnsafeFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unsafe field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe fields may carry library invariants")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unsafe field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
351#[diag("use of unsafe field is unsafe and requires unsafe block", code = E0133)]
352#[note("unsafe fields may carry library invariants")]
353pub(crate) struct UseOfUnsafeFieldRequiresUnsafe {
354#[primary_span]
355 #[label("use of unsafe field")]
356pub(crate) span: Span,
357#[subdiagnostic]
358pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
359}
360361#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UseOfUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UseOfUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unsafe field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe fields may carry library invariants")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of unsafe field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
362#[diag("use of unsafe field is unsafe and requires unsafe block", code = E0133)]
363#[note("unsafe fields may carry library invariants")]
364pub(crate) struct UseOfUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
365#[primary_span]
366 #[label("use of unsafe field")]
367pub(crate) span: Span,
368#[subdiagnostic]
369pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
370}
371372#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DerefOfRawPointerRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DerefOfRawPointerRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereference of raw pointer is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereference of raw pointer")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
373#[diag("dereference of raw pointer is unsafe and requires unsafe block", code = E0133)]
374#[note(
375"raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior"
376)]
377pub(crate) struct DerefOfRawPointerRequiresUnsafe {
378#[primary_span]
379 #[label("dereference of raw pointer")]
380pub(crate) span: Span,
381#[subdiagnostic]
382pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
383}
384385#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereference of raw pointer is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereference of raw pointer")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
386#[diag("dereference of raw pointer is unsafe and requires unsafe function or block", code = E0133)]
387#[note(
388"raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior"
389)]
390pub(crate) struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
391#[primary_span]
392 #[label("dereference of raw pointer")]
393pub(crate) span: Span,
394#[subdiagnostic]
395pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
396}
397398#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AccessToUnionFieldRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AccessToUnionFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("access to union field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the field may not be properly initialized: using uninitialized data will cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("access to union field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
399#[diag("access to union field is unsafe and requires unsafe block", code = E0133)]
400#[note(
401"the field may not be properly initialized: using uninitialized data will cause undefined behavior"
402)]
403pub(crate) struct AccessToUnionFieldRequiresUnsafe {
404#[primary_span]
405 #[label("access to union field")]
406pub(crate) span: Span,
407#[subdiagnostic]
408pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
409}
410411#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("access to union field is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the field may not be properly initialized: using uninitialized data will cause undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("access to union field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
412#[diag("access to union field is unsafe and requires unsafe function or block", code = E0133)]
413#[note(
414"the field may not be properly initialized: using uninitialized data will cause undefined behavior"
415)]
416pub(crate) struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
417#[primary_span]
418 #[label("access to union field")]
419pub(crate) span: Span,
420#[subdiagnostic]
421pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
422}
423424#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MutationOfLayoutConstrainedFieldRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MutationOfLayoutConstrainedFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of layout constrained field is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutating layout constrained fields cannot statically be checked for valid values")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of layout constrained field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
425#[diag("mutation of layout constrained field is unsafe and requires unsafe block", code = E0133)]
426#[note("mutating layout constrained fields cannot statically be checked for valid values")]
427pub(crate) struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
428#[primary_span]
429 #[label("mutation of layout constrained field")]
430pub(crate) span: Span,
431#[subdiagnostic]
432pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
433}
434435#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of layout constrained field is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutating layout constrained fields cannot statically be checked for valid values")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of layout constrained field")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
436#[diag(
437"mutation of layout constrained field is unsafe and requires unsafe function or block",
438 code = E0133
439)]
440#[note("mutating layout constrained fields cannot statically be checked for valid values")]
441pub(crate) struct MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
442#[primary_span]
443 #[label("mutation of layout constrained field")]
444pub(crate) span: Span,
445#[subdiagnostic]
446pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
447}
448449#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BorrowOfLayoutConstrainedFieldRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BorrowOfLayoutConstrainedFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of layout constrained field with interior mutability is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of layout constrained field with interior mutability")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
450#[diag("borrow of layout constrained field with interior mutability is unsafe and requires unsafe block", code = E0133)]
451#[note(
452"references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values"
453)]
454pub(crate) struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
455#[primary_span]
456 #[label("borrow of layout constrained field with interior mutability")]
457pub(crate) span: Span,
458#[subdiagnostic]
459pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
460}
461462#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of layout constrained field with interior mutability is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of layout constrained field with interior mutability")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
463#[diag(
464"borrow of layout constrained field with interior mutability is unsafe and requires unsafe function or block",
465 code = E0133
466)]
467#[note(
468"references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values"
469)]
470pub(crate) struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
471#[primary_span]
472 #[label("borrow of layout constrained field with interior mutability")]
473pub(crate) span: Span,
474#[subdiagnostic]
475pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
476}
477478#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallToFunctionWithRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallToFunctionWithRequiresUnsafe {
span: __binding_0,
function: __binding_1,
missing_target_features: __binding_2,
missing_target_features_count: __binding_3,
note: __binding_4,
build_target_features: __binding_5,
build_target_features_count: __binding_6,
unsafe_not_inherited_note: __binding_7 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block")));
diag.code(E0133);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->\n [1] feature\n *[count] features\n}: {$missing_target_features}")));
;
diag.arg("function", __binding_1);
diag.arg("missing_target_features", __binding_2);
diag.arg("missing_target_features_count", __binding_3);
diag.arg("build_target_features", __binding_5);
diag.arg("build_target_features_count", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to function with `#[target_feature]`")));
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$build_target_features} target {$build_target_features_count ->\n [1] feature\n *[count] features\n } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->\n [1] it\n *[count] them\n } in `#[target_feature]`")));
}
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
diag
}
}
}
}
};Diagnostic)]
479#[diag("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block", code = E0133)]
480#[help(
481"in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
482 [1] feature
483 *[count] features
484}: {$missing_target_features}"
485)]
486pub(crate) struct CallToFunctionWithRequiresUnsafe {
487#[primary_span]
488 #[label("call to function with `#[target_feature]`")]
489pub(crate) span: Span,
490pub(crate) function: String,
491pub(crate) missing_target_features: DiagArgValue,
492pub(crate) missing_target_features_count: usize,
493#[note("the {$build_target_features} target {$build_target_features_count ->
494 [1] feature
495 *[count] features
496 } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->
497 [1] it
498 *[count] them
499 } in `#[target_feature]`")]
500pub(crate) note: bool,
501pub(crate) build_target_features: DiagArgValue,
502pub(crate) build_target_features_count: usize,
503#[subdiagnostic]
504pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
505}
506507#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0,
function: __binding_1,
missing_target_features: __binding_2,
missing_target_features_count: __binding_3,
note: __binding_4,
build_target_features: __binding_5,
build_target_features_count: __binding_6,
unsafe_not_inherited_note: __binding_7 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->\n [1] feature\n *[count] features\n}: {$missing_target_features}")));
;
diag.arg("function", __binding_1);
diag.arg("missing_target_features", __binding_2);
diag.arg("missing_target_features_count", __binding_3);
diag.arg("build_target_features", __binding_5);
diag.arg("build_target_features_count", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to function with `#[target_feature]`")));
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$build_target_features} target {$build_target_features_count ->\n [1] feature\n *[count] features\n } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->\n [1] it\n *[count] them\n } in `#[target_feature]`")));
}
if let Some(__binding_7) = __binding_7 {
diag.subdiagnostic(__binding_7);
}
diag
}
}
}
}
};Diagnostic)]
508#[diag(
509"call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe function or block",
510 code = E0133,
511)]
512#[help(
513"in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
514 [1] feature
515 *[count] features
516}: {$missing_target_features}"
517)]
518pub(crate) struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
519#[primary_span]
520 #[label("call to function with `#[target_feature]`")]
521pub(crate) span: Span,
522pub(crate) function: String,
523pub(crate) missing_target_features: DiagArgValue,
524pub(crate) missing_target_features_count: usize,
525#[note("the {$build_target_features} target {$build_target_features_count ->
526 [1] feature
527 *[count] features
528 } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->
529 [1] it
530 *[count] them
531 } in `#[target_feature]`")]
532pub(crate) note: bool,
533pub(crate) build_target_features: DiagArgValue,
534pub(crate) build_target_features_count: usize,
535#[subdiagnostic]
536pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
537}
538539#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeBinderCastRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeBinderCastRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe binder cast is unsafe and requires unsafe block information that may be required to uphold safety guarantees of a type")));
diag.code(E0133);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe binder cast")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
540#[diag(
541"unsafe binder cast is unsafe and requires unsafe block information that may be required to uphold safety guarantees of a type",
542 code = E0133,
543)]
544pub(crate) struct UnsafeBinderCastRequiresUnsafe {
545#[primary_span]
546 #[label("unsafe binder cast")]
547pub(crate) span: Span,
548#[subdiagnostic]
549pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
550}
551552#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsafeBinderCastRequiresUnsafeUnsafeOpInUnsafeFnAllowed where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsafeBinderCastRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe binder cast is unsafe and requires unsafe block or unsafe fn information that may be required to uphold safety guarantees of a type")));
diag.code(E0133);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsafe binder cast")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
553#[diag(
554"unsafe binder cast is unsafe and requires unsafe block or unsafe fn information that may be required to uphold safety guarantees of a type",
555 code = E0133,
556)]
557pub(crate) struct UnsafeBinderCastRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
558#[primary_span]
559 #[label("unsafe binder cast")]
560pub(crate) span: Span,
561#[subdiagnostic]
562pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
563}
564565#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CallDropExplicitlyRequiresUnsafe where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CallDropExplicitlyRequiresUnsafe {
span: __binding_0,
function: __binding_1,
unsafe_not_inherited_note: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call `{$function}` explicitly is unsafe and requires unsafe block")));
diag.code(E0133);
;
diag.arg("function", __binding_1);
diag.span(__binding_0);
if let Some(__binding_2) = __binding_2 {
diag.subdiagnostic(__binding_2);
}
diag
}
}
}
}
};Diagnostic)]
566#[diag("call `{$function}` explicitly is unsafe and requires unsafe block", code = E0133)]
567pub(crate) struct CallDropExplicitlyRequiresUnsafe {
568#[primary_span]
569pub(crate) span: Span,
570pub(crate) function: String,
571#[subdiagnostic]
572pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
573}
574575#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnsafeNotInheritedNote {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnsafeNotInheritedNote { 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("items do not inherit unsafety from separate enclosing items")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
576#[label("items do not inherit unsafety from separate enclosing items")]
577pub(crate) struct UnsafeNotInheritedNote {
578#[primary_span]
579pub(crate) span: Span,
580}
581582pub(crate) struct UnsafeNotInheritedLintNote {
583pub(crate) signature_span: Span,
584pub(crate) body_span: Span,
585}
586587impl Subdiagnosticfor UnsafeNotInheritedLintNote {
588fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
589diag.span_note(
590self.signature_span,
591rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an unsafe function restricts its caller, but its body is safe by default"))msg!("an unsafe function restricts its caller, but its body is safe by default"),
592 );
593let body_start = self.body_span.shrink_to_lo();
594let body_end = self.body_span.shrink_to_hi();
595diag.tool_only_multipart_suggestion(
596rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider wrapping the function body in an unsafe block"))msg!("consider wrapping the function body in an unsafe block"),
597::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[(body_start, "{ unsafe ".into()), (body_end, "}".into())]))vec![(body_start, "{ unsafe ".into()), (body_end, "}".into())],
598 Applicability::MachineApplicable,
599 );
600 }
601}
602603#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnusedUnsafe
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnusedUnsafe { span: __binding_0, enclosing: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary `unsafe` block")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary `unsafe` block")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
604#[diag("unnecessary `unsafe` block")]
605pub(crate) struct UnusedUnsafe {
606#[label("unnecessary `unsafe` block")]
607pub(crate) span: Span,
608#[subdiagnostic]
609pub(crate) enclosing: Option<UnusedUnsafeEnclosing>,
610}
611612#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnusedUnsafeEnclosing {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnusedUnsafeEnclosing::Block { 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("because it's nested under this `unsafe` block")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
613pub(crate) enum UnusedUnsafeEnclosing {
614#[label("because it's nested under this `unsafe` block")]
615Block {
616#[primary_span]
617span: Span,
618 },
619}
620621pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'a, 'tcx> {
622pub(crate) cx: &'a RustcPatCtxt<'a, 'tcx>,
623pub(crate) scrut_span: Span,
624pub(crate) braces_span: Option<Span>,
625pub(crate) ty: Ty<'tcx>,
626}
627628impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_> {
629fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
630let mut diag =
631Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-exhaustive patterns: type `{$ty}` is non-empty"))msg!("non-exhaustive patterns: type `{$ty}` is non-empty"));
632diag.span(self.scrut_span);
633diag.code(E0004);
634let peeled_ty = self.ty.peel_refs();
635diag.arg("ty", self.ty);
636diag.arg("peeled_ty", peeled_ty);
637638if let ty::Adt(def, _) = peeled_ty.kind() {
639let def_span = self640 .cx
641 .tcx
642 .hir_get_if_local(def.did())
643 .and_then(|node| node.ident())
644 .map(|ident| ident.span)
645 .unwrap_or_else(|| self.cx.tcx.def_span(def.did()));
646647// workaround to make test pass
648let mut span: MultiSpan = def_span.into();
649span.push_span_label(def_span, "");
650651diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$peeled_ty}` defined here"))msg!("`{$peeled_ty}` defined here"));
652 }
653654let is_non_exhaustive = #[allow(non_exhaustive_omitted_patterns)] match self.ty.kind() {
ty::Adt(def, _) if def.variant_list_has_applicable_non_exhaustive() =>
true,
_ => false,
}matches!(self.ty.kind(),
655 ty::Adt(def, _) if def.variant_list_has_applicable_non_exhaustive());
656if is_non_exhaustive {
657diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`, which is marked as non-exhaustive"))msg!(
658"the matched value is of type `{$ty}`, which is marked as non-exhaustive"
659));
660 } else {
661diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`"))msg!("the matched value is of type `{$ty}`"));
662 }
663664if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
665if !sub_ty.is_inhabited_from(self.cx.tcx, self.cx.module, self.cx.typing_env) {
666diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are always considered inhabited"))msg!("references are always considered inhabited"));
667 }
668 }
669670let sm = self.cx.tcx.sess.source_map();
671if let Some(braces_span) = self.braces_span {
672// Get the span for the empty match body `{}`.
673let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.scrut_span)
674 {
675 (::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\n{0}", snippet))
})format!("\n{snippet}"), " ")
676 } else {
677 (" ".to_string(), "")
678 };
679diag.span_suggestion_verbose(
680braces_span,
681rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown"))msg!("ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown"),
682::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{{0}{1}_ => todo!(),{0}}}",
indentation, more))
})format!(" {{{indentation}{more}_ => todo!(),{indentation}}}"),
683 Applicability::HasPlaceholders,
684 );
685 } else {
686diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ensure that all possible cases are being handled by adding a match arm with a wildcard pattern"))msg!(
687"ensure that all possible cases are being handled by adding a match arm with a wildcard pattern"
688));
689 }
690691diag692 }
693}
694695#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NonExhaustiveMatchAllArmsGuarded
{
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
NonExhaustiveMatchAllArmsGuarded => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("match arms with guards don't count towards exhaustivity")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
696#[note("match arms with guards don't count towards exhaustivity")]
697pub(crate) struct NonExhaustiveMatchAllArmsGuarded;
698699#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
StaticInPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
StaticInPattern {
span: __binding_0, static_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("statics cannot be referenced in patterns")));
diag.code(E0158);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't be used in patterns")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`static` defined here")));
diag
}
}
}
}
};Diagnostic)]
700#[diag("statics cannot be referenced in patterns", code = E0158)]
701pub(crate) struct StaticInPattern {
702#[primary_span]
703 #[label("can't be used in patterns")]
704pub(crate) span: Span,
705#[label("`static` defined here")]
706pub(crate) static_span: Span,
707}
708709#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstParamInPattern where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstParamInPattern {
span: __binding_0, const_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant parameters cannot be referenced in patterns")));
diag.code(E0158);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't be used in patterns")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant defined here")));
diag
}
}
}
}
};Diagnostic)]
710#[diag("constant parameters cannot be referenced in patterns", code = E0158)]
711pub(crate) struct ConstParamInPattern {
712#[primary_span]
713 #[label("can't be used in patterns")]
714pub(crate) span: Span,
715#[label("constant defined here")]
716pub(crate) const_span: Span,
717}
718719#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NonConstPath
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonConstPath { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("runtime values cannot be referenced in patterns")));
diag.code(E0080);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references a runtime value")));
diag
}
}
}
}
};Diagnostic)]
720#[diag("runtime values cannot be referenced in patterns", code = E0080)]
721pub(crate) struct NonConstPath {
722#[primary_span]
723 #[label("references a runtime value")]
724pub(crate) span: Span,
725}
726727pub(crate) struct UnreachablePattern<'tcx> {
728pub(crate) covered_by_many_n_more_count: Option<usize>,
729pub(crate) inner: UnreachablePatternInner<'tcx>,
730}
731732impl<'a, 'tcx, G: EmissionGuarantee> Diagnostic<'a, G> for UnreachablePattern<'tcx> {
733#[track_caller]
734fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
735let mut diag = self.inner.into_diag(dcx, level);
736if let Some(covered_by_many_n_more_count) = self.covered_by_many_n_more_count {
737diag.arg("covered_by_many_n_more_count", covered_by_many_n_more_count);
738 }
739diag740 }
741}
742743#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
UnreachablePatternInner<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnreachablePatternInner {
span: __binding_0,
matches_no_values: __binding_1,
matches_no_values_ty: __binding_2,
uninhabited_note: __binding_3,
covered_by_catchall: __binding_4,
wanted_constant: __binding_5,
accessible_constant: __binding_6,
inaccessible_constant: __binding_7,
pattern_let_binding: __binding_8,
covered_by_one: __binding_9,
covered_by_many: __binding_10,
suggest_remove: __binding_11 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable pattern")));
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
})].into_iter();
;
diag.arg("matches_no_values_ty", __binding_2);
if let Some(__binding_0) = __binding_0 {
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no value can reach this")));
}
if let Some(__binding_1) = __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("matches no values because `{$matches_no_values_ty}` is uninhabited")));
}
if let Some(__binding_3) = __binding_3 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types")));
}
if let Some(__binding_4) = __binding_4 {
diag.span_label(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("matches any value")));
}
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
if let Some(__binding_6) = __binding_6 {
diag.span_note(__binding_6,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is a constant of the same name imported in another scope, which could have been used to pattern match against its value instead of introducing a new catch-all binding, but it needs to be imported in the pattern's scope")));
}
if let Some(__binding_7) = __binding_7 {
diag.span_note(__binding_7,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is a constant of the same name, which could have been used to pattern match against its value instead of introducing a new catch-all binding, but it is not accessible from this scope")));
}
if let Some(__binding_8) = __binding_8 {
diag.span_note(__binding_8,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("there is a binding of the same name; if you meant to pattern match against the value of that binding, that is a feature of constants that is not available for `let` bindings")));
}
if let Some(__binding_9) = __binding_9 {
diag.span_label(__binding_9,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("matches all the relevant values")));
}
if let Some(__binding_10) = __binding_10 {
diag.span_note(__binding_10,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple earlier patterns match some of the same values")));
}
if let Some(__binding_11) = __binding_11 {
diag.span_suggestions_with_style(__binding_11,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the match arm")),
__code_3, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
744#[diag("unreachable pattern")]
745pub(crate) struct UnreachablePatternInner<'tcx> {
746#[label("no value can reach this")]
747pub(crate) span: Option<Span>,
748#[label("matches no values because `{$matches_no_values_ty}` is uninhabited")]
749pub(crate) matches_no_values: Option<Span>,
750pub(crate) matches_no_values_ty: Ty<'tcx>,
751#[note(
752"to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types"
753)]
754pub(crate) uninhabited_note: Option<()>,
755#[label("matches any value")]
756pub(crate) covered_by_catchall: Option<Span>,
757#[subdiagnostic]
758pub(crate) wanted_constant: Option<WantedConstant>,
759#[note(
760"there is a constant of the same name imported in another scope, which could have been used to pattern match against its value instead of introducing a new catch-all binding, but it needs to be imported in the pattern's scope"
761)]
762pub(crate) accessible_constant: Option<Span>,
763#[note(
764"there is a constant of the same name, which could have been used to pattern match against its value instead of introducing a new catch-all binding, but it is not accessible from this scope"
765)]
766pub(crate) inaccessible_constant: Option<Span>,
767#[note(
768"there is a binding of the same name; if you meant to pattern match against the value of that binding, that is a feature of constants that is not available for `let` bindings"
769)]
770pub(crate) pattern_let_binding: Option<Span>,
771#[label("matches all the relevant values")]
772pub(crate) covered_by_one: Option<Span>,
773#[note("multiple earlier patterns match some of the same values")]
774pub(crate) covered_by_many: Option<MultiSpan>,
775#[suggestion("remove the match arm", code = "", applicability = "machine-applicable")]
776pub(crate) suggest_remove: Option<Span>,
777}
778779#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for WantedConstant {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
WantedConstant {
span: __binding_0,
is_typo: __binding_1,
const_name: __binding_2,
const_path: __binding_3 } => {
let __code_4 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_3))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("is_typo".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
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("you might have meant to pattern match against the value of {$is_typo ->\n [true] similarly named constant\n *[false] constant\n } `{$const_name}` instead of introducing a new catch-all binding")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_4, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
780#[suggestion(
781"you might have meant to pattern match against the value of {$is_typo ->
782 [true] similarly named constant
783 *[false] constant
784 } `{$const_name}` instead of introducing a new catch-all binding",
785 code = "{const_path}",
786 applicability = "machine-applicable"
787)]
788pub(crate) struct WantedConstant {
789#[primary_span]
790pub(crate) span: Span,
791pub(crate) is_typo: bool,
792pub(crate) const_name: String,
793pub(crate) const_path: String,
794}
795796#[derive(const _: () =
{
impl<'_sess, 'desc, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
UnreachableDueToUninhabited<'desc, 'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnreachableDueToUninhabited {
descr: __binding_0,
expr: __binding_1,
orig: __binding_2,
ty: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable {$descr}")));
;
diag.arg("descr", __binding_0);
diag.arg("ty", __binding_3);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable {$descr}")));
diag.span_label(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("any code following this expression is unreachable")));
diag.span_note(__binding_2,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression has type `{$ty}`, which is uninhabited")));
diag
}
}
}
}
};Diagnostic)]
797#[diag("unreachable {$descr}")]
798pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
799pub descr: &'desc str,
800#[label("unreachable {$descr}")]
801pub expr: Span,
802#[label("any code following this expression is unreachable")]
803 #[note("this expression has type `{$ty}`, which is uninhabited")]
804pub orig: Span,
805pub ty: Ty<'tcx>,
806}
807808#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstPatternDependsOnGenericParameter where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstPatternDependsOnGenericParameter { span: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant pattern cannot depend on generic parameters")));
diag.code(E0158);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` depends on a generic parameter")));
diag
}
}
}
}
};Diagnostic)]
809#[diag("constant pattern cannot depend on generic parameters", code = E0158)]
810pub(crate) struct ConstPatternDependsOnGenericParameter {
811#[primary_span]
812 #[label("`const` depends on a generic parameter")]
813pub(crate) span: Span,
814}
815816#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CouldNotEvalConstPattern where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CouldNotEvalConstPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not evaluate constant pattern")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not evaluate constant")));
diag
}
}
}
}
};Diagnostic)]
817#[diag("could not evaluate constant pattern")]
818pub(crate) struct CouldNotEvalConstPattern {
819#[primary_span]
820 #[label("could not evaluate constant")]
821pub(crate) span: Span,
822}
823824#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LowerRangeBoundMustBeLessThanOrEqualToUpper where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LowerRangeBoundMustBeLessThanOrEqualToUpper {
span: __binding_0, teach: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lower bound for range pattern must be less than or equal to upper bound")));
diag.code(E0030);
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lower bound larger than upper bound")));
if __binding_1 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("when matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range")));
}
diag
}
}
}
}
};Diagnostic)]
825#[diag("lower bound for range pattern must be less than or equal to upper bound", code = E0030)]
826pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
827#[primary_span]
828 #[label("lower bound larger than upper bound")]
829pub(crate) span: Span,
830#[note(
831"when matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range"
832)]
833pub(crate) teach: bool,
834}
835836#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
LiteralOutOfRange<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LiteralOutOfRange {
span: __binding_0,
ty: __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.arg("ty", __binding_1);
diag.arg("min", __binding_2);
diag.arg("max", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this value does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")));
diag
}
}
}
}
};Diagnostic)]
837#[diag("literal out of range for `{$ty}`")]
838pub(crate) struct LiteralOutOfRange<'tcx> {
839#[primary_span]
840 #[label("this value does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
841pub(crate) span: Span,
842pub(crate) ty: Ty<'tcx>,
843pub(crate) min: i128,
844pub(crate) max: u128,
845}
846847#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LowerRangeBoundMustBeLessThanUpper where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LowerRangeBoundMustBeLessThanUpper { span: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lower bound for range pattern must be less than upper bound")));
diag.code(E0579);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
848#[diag("lower bound for range pattern must be less than upper bound", code = E0579)]
849pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
850#[primary_span]
851pub(crate) span: Span,
852}
853854#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UpperRangeBoundCannotBeMin where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UpperRangeBoundCannotBeMin { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("exclusive upper bound for a range bound cannot be the minimum")));
diag.code(E0579);
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
855#[diag("exclusive upper bound for a range bound cannot be the minimum", code = E0579)]
856pub(crate) struct UpperRangeBoundCannotBeMin {
857#[primary_span]
858pub(crate) span: Span,
859}
860861#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BindingsWithVariantName where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BindingsWithVariantName {
suggestion: __binding_0,
ty_path: __binding_1,
name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`")));
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}::{0}", __binding_2,
__binding_1))
})].into_iter();
diag.code(E0170);
;
diag.arg("ty_path", __binding_1);
diag.arg("name", __binding_2);
if let Some(__binding_0) = __binding_0 {
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to match on the variant, qualify the path")),
__code_5, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
862#[diag("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`", code = E0170)]
863pub(crate) struct BindingsWithVariantName {
864#[suggestion(
865"to match on the variant, qualify the path",
866 code = "{ty_path}::{name}",
867 applicability = "machine-applicable"
868)]
869pub(crate) suggestion: Option<Span>,
870pub(crate) ty_path: String,
871pub(crate) name: Ident,
872}
873874#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IrrefutableLetPatternsIfLet where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IrrefutableLetPatternsIfLet { count: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("irrefutable `if let` {$count ->\n [one] pattern\n *[other] patterns\n}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$count ->\n [one] this pattern\n *[other] these patterns\n} will always match, so the `if let` is useless")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider replacing the `if let` with a `let`")));
;
diag.arg("count", __binding_0);
diag
}
}
}
}
};Diagnostic)]
875#[diag(
876"irrefutable `if let` {$count ->
877 [one] pattern
878 *[other] patterns
879}"
880)]
881#[note(
882"{$count ->
883 [one] this pattern
884 *[other] these patterns
885} will always match, so the `if let` is useless"
886)]
887#[help("consider replacing the `if let` with a `let`")]
888pub(crate) struct IrrefutableLetPatternsIfLet {
889pub(crate) count: usize,
890}
891892#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IrrefutableLetPatternsIfLetGuard where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IrrefutableLetPatternsIfLetGuard { count: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("irrefutable `if let` guard {$count ->\n [one] pattern\n *[other] patterns\n}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$count ->\n [one] this pattern\n *[other] these patterns\n} will always match, so the guard is useless")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the guard and adding a `let` inside the match arm")));
;
diag.arg("count", __binding_0);
diag
}
}
}
}
};Diagnostic)]
893#[diag(
894"irrefutable `if let` guard {$count ->
895 [one] pattern
896 *[other] patterns
897}"
898)]
899#[note(
900"{$count ->
901 [one] this pattern
902 *[other] these patterns
903} will always match, so the guard is useless"
904)]
905#[help("consider removing the guard and adding a `let` inside the match arm")]
906pub(crate) struct IrrefutableLetPatternsIfLetGuard {
907pub(crate) count: usize,
908}
909910#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IrrefutableLetPatternsLetElse where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IrrefutableLetPatternsLetElse { be_replaced: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable `else` clause")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this pattern always matches, so the else clause is unreachable")));
;
if let Some(__binding_0) = __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
911#[diag("unreachable `else` clause")]
912#[note("this pattern always matches, so the else clause is unreachable")]
913pub(crate) struct IrrefutableLetPatternsLetElse {
914#[subdiagnostic]
915pub(crate) be_replaced: Option<LetElseReplacementSuggestion>,
916}
917918#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for LetElseReplacementSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
LetElseReplacementSuggestion {
span: __binding_0, lhs: __binding_1, rhs: __binding_2 } => {
let __code_6 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("let {0} = {1}",
__binding_1, __binding_2))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("lhs".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
sub_args.insert("rhs".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 `let {$lhs} = {$rhs}` to match on a specific variant")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_6, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic, #[automatically_derived]
impl ::core::fmt::Debug for LetElseReplacementSuggestion {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"LetElseReplacementSuggestion", "span", &self.span, "lhs",
&self.lhs, "rhs", &&self.rhs)
}
}Debug)]
919#[suggestion(
920"consider using `let {$lhs} = {$rhs}` to match on a specific variant",
921 code = "let {lhs} = {rhs}",
922 applicability = "machine-applicable"
923)]
924pub(crate) struct LetElseReplacementSuggestion {
925#[primary_span]
926pub(crate) span: Span,
927pub(crate) lhs: String,
928pub(crate) rhs: String,
929}
930931#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IrrefutableLetPatternsWhileLet where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
IrrefutableLetPatternsWhileLet { count: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("irrefutable `while let` {$count ->\n [one] pattern\n *[other] patterns\n}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$count ->\n [one] this pattern\n *[other] these patterns\n} will always match, so the loop will never exit")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider instead using a `loop {\"{\"} ... {\"}\"}` with a `let` inside it")));
;
diag.arg("count", __binding_0);
diag
}
}
}
}
};Diagnostic)]
932#[diag(
933"irrefutable `while let` {$count ->
934 [one] pattern
935 *[other] patterns
936}"
937)]
938#[note(
939"{$count ->
940 [one] this pattern
941 *[other] these patterns
942} will always match, so the loop will never exit"
943)]
944#[help("consider instead using a `loop {\"{\"} ... {\"}\"}` with a `let` inside it")]
945pub(crate) struct IrrefutableLetPatternsWhileLet {
946pub(crate) count: usize,
947}
948949#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
BorrowOfMovedValue<'tcx> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BorrowOfMovedValue {
binding_span: __binding_0,
conflicts_ref: __binding_1,
name: __binding_2,
ty: __binding_3,
suggest_borrowing: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow of moved value")));
let __code_7 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ref "))
})].into_iter();
;
diag.arg("name", __binding_2);
diag.arg("ty", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value moved into `{$name}` here")));
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("move occurs because `{$name}` has type `{$ty}`, which does not implement the `Copy` trait")));
for __binding_1 in __binding_1 {
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value borrowed here after move")));
}
if let Some(__binding_4) = __binding_4 {
diag.span_suggestions_with_style(__binding_4,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("borrow this binding in the pattern to avoid moving the value")),
__code_7, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
950#[diag("borrow of moved value")]
951pub(crate) struct BorrowOfMovedValue<'tcx> {
952#[primary_span]
953 #[label("value moved into `{$name}` here")]
954 #[label(
955"move occurs because `{$name}` has type `{$ty}`, which does not implement the `Copy` trait"
956)]
957pub(crate) binding_span: Span,
958#[label("value borrowed here after move")]
959pub(crate) conflicts_ref: Vec<Span>,
960pub(crate) name: Ident,
961pub(crate) ty: Ty<'tcx>,
962#[suggestion(
963"borrow this binding in the pattern to avoid moving the value",
964 code = "ref ",
965 applicability = "machine-applicable"
966)]
967pub(crate) suggest_borrowing: Option<Span>,
968}
969970#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MultipleMutBorrows where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MultipleMutBorrows {
span: __binding_0, occurrences: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot borrow value as mutable more than once at a time")));
;
diag.span(__binding_0);
for __binding_1 in __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
971#[diag("cannot borrow value as mutable more than once at a time")]
972pub(crate) struct MultipleMutBorrows {
973#[primary_span]
974pub(crate) span: Span,
975#[subdiagnostic]
976pub(crate) occurrences: Vec<Conflict>,
977}
978979#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AlreadyBorrowed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AlreadyBorrowed {
span: __binding_0, occurrences: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot borrow value as mutable because it is also borrowed as immutable")));
;
diag.span(__binding_0);
for __binding_1 in __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
980#[diag("cannot borrow value as mutable because it is also borrowed as immutable")]
981pub(crate) struct AlreadyBorrowed {
982#[primary_span]
983pub(crate) span: Span,
984#[subdiagnostic]
985pub(crate) occurrences: Vec<Conflict>,
986}
987988#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AlreadyMutBorrowed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
AlreadyMutBorrowed {
span: __binding_0, occurrences: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot borrow value as immutable because it is also borrowed as mutable")));
;
diag.span(__binding_0);
for __binding_1 in __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
989#[diag("cannot borrow value as immutable because it is also borrowed as mutable")]
990pub(crate) struct AlreadyMutBorrowed {
991#[primary_span]
992pub(crate) span: Span,
993#[subdiagnostic]
994pub(crate) occurrences: Vec<Conflict>,
995}
996997#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MovedWhileBorrowed where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MovedWhileBorrowed {
span: __binding_0, occurrences: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot move out of value because it is borrowed")));
;
diag.span(__binding_0);
for __binding_1 in __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
998#[diag("cannot move out of value because it is borrowed")]
999pub(crate) struct MovedWhileBorrowed {
1000#[primary_span]
1001pub(crate) span: Span,
1002#[subdiagnostic]
1003pub(crate) occurrences: Vec<Conflict>,
1004}
10051006#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for Conflict {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
Conflict::Mut { span: __binding_0, name: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("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("value is mutably borrowed by `{$name}` here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
Conflict::Ref { span: __binding_0, name: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("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("value is borrowed by `{$name}` here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
Conflict::Moved { span: __binding_0, name: __binding_1 } =>
{
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("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("value is moved into `{$name}` here")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1007pub(crate) enum Conflict {
1008#[label("value is mutably borrowed by `{$name}` here")]
1009Mut {
1010#[primary_span]
1011span: Span,
1012 name: Symbol,
1013 },
1014#[label("value is borrowed by `{$name}` here")]
1015Ref {
1016#[primary_span]
1017span: Span,
1018 name: Symbol,
1019 },
1020#[label("value is moved into `{$name}` here")]
1021Moved {
1022#[primary_span]
1023span: Span,
1024 name: Symbol,
1025 },
1026}
10271028#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnionPattern
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnionPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use unions in constant patterns")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't use a `union` here")));
diag
}
}
}
}
};Diagnostic)]
1029#[diag("cannot use unions in constant patterns")]
1030pub(crate) struct UnionPattern {
1031#[primary_span]
1032 #[label("can't use a `union` here")]
1033pub(crate) span: Span,
1034}
10351036#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
TypeNotStructural<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TypeNotStructural {
span: __binding_0,
ty_def_span: __binding_1,
ty: __binding_2,
manual_partialeq_impl_span: __binding_3,
manual_partialeq_impl_note: __binding_4,
suggestion: __binding_5,
is_local: __binding_6 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant of non-structural type `{$ty}` in a pattern")));
;
diag.arg("ty", __binding_2);
diag.arg("is_local", __binding_6);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant of non-structural type")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$is_local ->\n *[true] `{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns\n [false] `{$ty}` is not usable in patterns\n }")));
if let Some(__binding_3) = __binding_3 {
diag.span_note(__binding_3,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details")));
}
if __binding_4 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details")));
}
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
diag
}
}
}
}
};Diagnostic)]
1037#[diag("constant of non-structural type `{$ty}` in a pattern")]
1038pub(crate) struct TypeNotStructural<'tcx> {
1039#[primary_span]
1040 #[label("constant of non-structural type")]
1041pub(crate) span: Span,
1042#[label(
1043"{$is_local ->
1044 *[true] `{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
1045 [false] `{$ty}` is not usable in patterns
1046 }"
1047)]
1048pub(crate) ty_def_span: Span,
1049pub(crate) ty: Ty<'tcx>,
1050#[note(
1051"the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see \
1052 https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1053)]
1054pub(crate) manual_partialeq_impl_span: Option<Span>,
1055#[note(
1056"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1057)]
1058pub(crate) manual_partialeq_impl_note: bool,
1059#[subdiagnostic]
1060pub(crate) suggestion: Option<SuggestEq<'tcx>>,
1061pub(crate) is_local: bool,
1062}
10631064#[derive(const _: () =
{
impl<'tcx> rustc_errors::Subdiagnostic for SuggestEq<'tcx> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggestEq::AddIf {
pat_span: __binding_0,
if_span: __binding_1,
name: __binding_2,
ty: __binding_3,
manual_partialeq_impl: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("binding"))
});
let __code_9 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" if binding == {0}",
__binding_2))
});
suggestions.push((__binding_0, __code_8));
suggestions.push((__binding_1, __code_9));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("manual_partialeq_impl".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("{$manual_partialeq_impl ->\n [false] if `{$ty}` manually implemented `PartialEq`, you could add\n *[true] add\n } a condition to the match arm checking for equality")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
SuggestEq::AddToIf {
pat_span: __binding_0,
span: __binding_1,
name: __binding_2,
ty: __binding_3,
manual_partialeq_impl: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_10 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("binding"))
});
let __code_11 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" && binding == {0}",
__binding_2))
});
suggestions.push((__binding_0, __code_10));
suggestions.push((__binding_1, __code_11));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("manual_partialeq_impl".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("{$manual_partialeq_impl ->\n [false] if `{$ty}` manually implemented `PartialEq`, you could add\n *[true] add\n } a check for equality to the condition of the match arm")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
SuggestEq::AddToLetChain {
pat_span: __binding_0,
span: __binding_1,
name: __binding_2,
ty: __binding_3,
manual_partialeq_impl: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_12 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("binding"))
});
let __code_13 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" && binding == {0}",
__binding_2))
});
suggestions.push((__binding_0, __code_12));
suggestions.push((__binding_1, __code_13));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("manual_partialeq_impl".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("{$manual_partialeq_impl ->\n [false] if `{$ty}` manually implemented `PartialEq`, you could check\n *[true] check\n } for equality instead of pattern matching")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
SuggestEq::ReplaceWithEq {
removal: __binding_0,
eq: __binding_1,
ty: __binding_2,
manual_partialeq_impl: __binding_3 } => {
let mut suggestions = Vec::new();
let __code_14 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_15 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" == "))
});
suggestions.push((__binding_0, __code_14));
suggestions.push((__binding_1, __code_15));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
sub_args.insert("manual_partialeq_impl".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("{$manual_partialeq_impl ->\n [false] if `{$ty}` manually implemented `PartialEq`, you could check\n *[true] check\n } for equality instead of pattern matching")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
SuggestEq::ReplaceLetElseWithIf {
if_span: __binding_0,
eq: __binding_1,
else_span: __binding_2,
ty: __binding_3,
manual_partialeq_impl: __binding_4 } => {
let mut suggestions = Vec::new();
let __code_16 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
});
let __code_17 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" == "))
});
let __code_18 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
suggestions.push((__binding_0, __code_16));
suggestions.push((__binding_1, __code_17));
suggestions.push((__binding_2, __code_18));
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("ty".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
&mut diag.long_ty_path));
sub_args.insert("manual_partialeq_impl".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("{$manual_partialeq_impl ->\n [false] if `{$ty}` manually implemented `PartialEq`, you could check\n *[true] check\n } for equality instead of pattern matching")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1065pub(crate) enum SuggestEq<'tcx> {
1066#[multipart_suggestion(
1067"{$manual_partialeq_impl ->
1068 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1069 *[true] add
1070 } a condition to the match arm checking for equality",
1071 applicability = "maybe-incorrect",
1072 style = "verbose"
1073)]
1074AddIf {
1075#[suggestion_part(code = "binding")]
1076pat_span: Span,
1077#[suggestion_part(code = " if binding == {name}")]
1078if_span: Span,
1079 name: String,
1080 ty: Ty<'tcx>,
1081 manual_partialeq_impl: bool,
1082 },
1083#[multipart_suggestion(
1084"{$manual_partialeq_impl ->
1085 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1086 *[true] add
1087 } a check for equality to the condition of the match arm",
1088 applicability = "maybe-incorrect",
1089 style = "verbose"
1090)]
1091AddToIf {
1092#[suggestion_part(code = "binding")]
1093pat_span: Span,
1094#[suggestion_part(code = " && binding == {name}")]
1095span: Span,
1096 name: String,
1097 ty: Ty<'tcx>,
1098 manual_partialeq_impl: bool,
1099 },
1100#[multipart_suggestion(
1101"{$manual_partialeq_impl ->
1102 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1103 *[true] check
1104 } for equality instead of pattern matching",
1105 applicability = "maybe-incorrect",
1106 style = "verbose"
1107)]
1108AddToLetChain {
1109#[suggestion_part(code = "binding")]
1110pat_span: Span,
1111#[suggestion_part(code = " && binding == {name}")]
1112span: Span,
1113 name: String,
1114 ty: Ty<'tcx>,
1115 manual_partialeq_impl: bool,
1116 },
1117#[multipart_suggestion(
1118"{$manual_partialeq_impl ->
1119 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1120 *[true] check
1121 } for equality instead of pattern matching",
1122 applicability = "maybe-incorrect",
1123 style = "verbose"
1124)]
1125ReplaceWithEq {
1126#[suggestion_part(code = "")]
1127removal: Span,
1128#[suggestion_part(code = " == ")]
1129eq: Span,
1130 ty: Ty<'tcx>,
1131 manual_partialeq_impl: bool,
1132 },
1133#[multipart_suggestion(
1134"{$manual_partialeq_impl ->
1135 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1136 *[true] check
1137 } for equality instead of pattern matching",
1138 applicability = "maybe-incorrect",
1139 style = "verbose"
1140)]
1141ReplaceLetElseWithIf {
1142#[suggestion_part(code = "if ")]
1143if_span: Span,
1144#[suggestion_part(code = " == ")]
1145eq: Span,
1146#[suggestion_part(code = " ")]
1147else_span: Span,
1148 ty: Ty<'tcx>,
1149 manual_partialeq_impl: bool,
1150 },
1151}
11521153#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
TypeNotPartialEq<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
TypeNotPartialEq { span: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant of non-structural type `{$ty}` in a pattern")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant of non-structural type")));
diag
}
}
}
}
};Diagnostic)]
1154#[diag("constant of non-structural type `{$ty}` in a pattern")]
1155#[note(
1156"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1157)]
1158pub(crate) struct TypeNotPartialEq<'tcx> {
1159#[primary_span]
1160 #[label("constant of non-structural type")]
1161pub(crate) span: Span,
1162pub(crate) ty: Ty<'tcx>,
1163}
11641165#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidPattern<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
InvalidPattern {
span: __binding_0,
non_sm_ty: __binding_1,
prefix: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$prefix} `{$non_sm_ty}` cannot be used in patterns")));
;
diag.arg("non_sm_ty", __binding_1);
diag.arg("prefix", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$prefix} can't be used in patterns")));
diag
}
}
}
}
};Diagnostic)]
1166#[diag("{$prefix} `{$non_sm_ty}` cannot be used in patterns")]
1167pub(crate) struct InvalidPattern<'tcx> {
1168#[primary_span]
1169 #[label("{$prefix} can't be used in patterns")]
1170pub(crate) span: Span,
1171pub(crate) non_sm_ty: Ty<'tcx>,
1172pub(crate) prefix: String,
1173}
11741175#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
UnsizedPattern<'tcx> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsizedPattern { span: __binding_0, non_sm_ty: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use unsized non-slice type `{$non_sm_ty}` in constant patterns")));
;
diag.arg("non_sm_ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1176#[diag("cannot use unsized non-slice type `{$non_sm_ty}` in constant patterns")]
1177pub(crate) struct UnsizedPattern<'tcx> {
1178#[primary_span]
1179pub(crate) span: Span,
1180pub(crate) non_sm_ty: Ty<'tcx>,
1181}
11821183#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NaNPattern
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NaNPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot use NaN in patterns")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("NaNs compare inequal to everything, even themselves, so this pattern would never match")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using the `is_nan` method instead")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("evaluates to `NaN`, which is not allowed in patterns")));
diag
}
}
}
}
};Diagnostic)]
1184#[diag("cannot use NaN in patterns")]
1185#[note("NaNs compare inequal to everything, even themselves, so this pattern would never match")]
1186#[help("try using the `is_nan` method instead")]
1187pub(crate) struct NaNPattern {
1188#[primary_span]
1189 #[label("evaluates to `NaN`, which is not allowed in patterns")]
1190pub(crate) span: Span,
1191}
11921193#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for PointerPattern
where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PointerPattern { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see https://github.com/rust-lang/rust/issues/70861 for details")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't be used in patterns")));
diag
}
}
}
}
};Diagnostic)]
1194#[diag(
1195"function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon"
1196)]
1197#[note("see https://github.com/rust-lang/rust/issues/70861 for details")]
1198pub(crate) struct PointerPattern {
1199#[primary_span]
1200 #[label("can't be used in patterns")]
1201pub(crate) span: Span,
1202}
12031204#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
NonEmptyNeverPattern<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
NonEmptyNeverPattern { span: __binding_0, ty: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mismatched types")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a never pattern must be used on an uninhabited type")));
diag
}
}
}
}
};Diagnostic)]
1205#[diag("mismatched types")]
1206#[note("the matched value is of type `{$ty}`")]
1207pub(crate) struct NonEmptyNeverPattern<'tcx> {
1208#[primary_span]
1209 #[label("a never pattern must be used on an uninhabited type")]
1210pub(crate) span: Span,
1211pub(crate) ty: Ty<'tcx>,
1212}
12131214#[derive(const _: () =
{
impl<'_sess, 's, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
PatternNotCovered<'s, 'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
PatternNotCovered {
span: __binding_0,
origin: __binding_1,
uncovered: __binding_2,
inform: __binding_3,
interpreted_as_const: __binding_4,
interpreted_as_const_sugg: __binding_5,
adt_defined_here: __binding_6,
witness_1_is_privately_uninhabited: __binding_7,
witness_1: __binding_8,
_p: __binding_9,
pattern_ty: __binding_10,
let_suggestion: __binding_11,
misc_suggestion: __binding_12 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("refutable pattern in {$origin}")));
diag.code(E0005);
;
diag.arg("origin", __binding_1);
diag.arg("witness_1", __binding_8);
diag.arg("pattern_ty", __binding_10);
diag.span(__binding_0);
diag.subdiagnostic(__binding_2);
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
if let Some(__binding_4) = __binding_4 {
diag.subdiagnostic(__binding_4);
}
if let Some(__binding_5) = __binding_5 {
diag.subdiagnostic(__binding_5);
}
if let Some(__binding_6) = __binding_6 {
diag.subdiagnostic(__binding_6);
}
if __binding_7 {
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future")));
}
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$pattern_ty}`")));
if let Some(__binding_11) = __binding_11 {
diag.subdiagnostic(__binding_11);
}
if let Some(__binding_12) = __binding_12 {
diag.subdiagnostic(__binding_12);
}
diag
}
}
}
}
};Diagnostic)]
1215#[diag("refutable pattern in {$origin}", code = E0005)]
1216pub(crate) struct PatternNotCovered<'s, 'tcx> {
1217#[primary_span]
1218pub(crate) span: Span,
1219pub(crate) origin: &'s str,
1220#[subdiagnostic]
1221pub(crate) uncovered: Uncovered,
1222#[subdiagnostic]
1223pub(crate) inform: Option<Inform>,
1224#[subdiagnostic]
1225pub(crate) interpreted_as_const: Option<InterpretedAsConst>,
1226#[subdiagnostic]
1227pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConstSugg>,
1228#[subdiagnostic]
1229pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
1230#[note(
1231"pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future"
1232)]
1233pub(crate) witness_1_is_privately_uninhabited: bool,
1234pub(crate) witness_1: String,
1235#[note("the matched value is of type `{$pattern_ty}`")]
1236pub(crate) _p: (),
1237pub(crate) pattern_ty: Ty<'tcx>,
1238#[subdiagnostic]
1239pub(crate) let_suggestion: Option<SuggestLet>,
1240#[subdiagnostic]
1241pub(crate) misc_suggestion: Option<MiscPatternSuggestion>,
1242}
12431244#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for Inform {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
Inform => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`let` bindings require an \"irrefutable pattern\", like a `struct` or an `enum` with only one variant")),
&sub_args);
diag.note(__message);
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
1245#[note(
1246"`let` bindings require an \"irrefutable pattern\", like a `struct` or an `enum` with only one variant"
1247)]
1248#[note("for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html")]
1249pub(crate) struct Inform;
12501251#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InterpretedAsConst {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InterpretedAsConst {
span: __binding_0, variable: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("variable".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("missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1252#[label(
1253"missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable"
1254)]
1255pub(crate) struct InterpretedAsConst {
1256#[primary_span]
1257pub(crate) span: Span,
1258pub(crate) variable: String,
1259}
12601261pub(crate) struct AdtDefinedHere<'tcx> {
1262pub(crate) adt_def_span: Span,
1263pub(crate) ty: Ty<'tcx>,
1264pub(crate) variants: Vec<Variant>,
1265}
12661267pub(crate) struct Variant {
1268pub(crate) span: Span,
1269}
12701271impl<'tcx> Subdiagnosticfor AdtDefinedHere<'tcx> {
1272fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1273diag.arg("ty", self.ty);
1274let mut spans = MultiSpan::from(self.adt_def_span);
12751276for Variant { span } in self.variants {
1277 spans.push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not covered"))msg!("not covered"));
1278 }
12791280diag.span_note(spans, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` defined here"))msg!("`{$ty}` defined here"));
1281 }
1282}
12831284#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for InterpretedAsConstSugg {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InterpretedAsConstSugg {
span: __binding_0, variable: __binding_1 } => {
let __code_19 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}_var", __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("introduce a variable instead")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_19, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1285#[suggestion(
1286"introduce a variable instead",
1287 code = "{variable}_var",
1288 applicability = "maybe-incorrect",
1289 style = "verbose"
1290)]
1291pub(crate) struct InterpretedAsConstSugg {
1292#[primary_span]
1293pub(crate) span: Span,
1294pub(crate) variable: String,
1295}
12961297#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggestLet {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggestLet::If {
start_span: __binding_0,
semi_span: __binding_1,
count: __binding_2 } => {
let mut suggestions = Vec::new();
let __code_20 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
});
let __code_21 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ todo!() }}"))
});
suggestions.push((__binding_0, __code_20));
suggestions.push((__binding_1, __code_21));
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("you might want to use `if let` to ignore the {$count ->\n [one] variant that isn't\n *[other] variants that aren't\n } matched")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
SuggestLet::Else { end_span: __binding_0, count: __binding_1
} => {
let __code_22 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" else {{ todo!() }}"))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("count".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("you might want to use `let...else` to handle the {$count ->\n [one] variant that isn't\n *[other] variants that aren't\n } matched")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_22, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1298pub(crate) enum SuggestLet {
1299#[multipart_suggestion(
1300"you might want to use `if let` to ignore the {$count ->
1301 [one] variant that isn't
1302 *[other] variants that aren't
1303 } matched",
1304 applicability = "has-placeholders"
1305)]
1306If {
1307#[suggestion_part(code = "if ")]
1308start_span: Span,
1309#[suggestion_part(code = " {{ todo!() }}")]
1310semi_span: Span,
1311 count: usize,
1312 },
1313#[suggestion(
1314"you might want to use `let...else` to handle the {$count ->
1315 [one] variant that isn't
1316 *[other] variants that aren't
1317 } matched",
1318 code = " else {{ todo!() }}",
1319 applicability = "has-placeholders"
1320)]
1321Else {
1322#[primary_span]
1323end_span: Span,
1324 count: usize,
1325 },
1326}
13271328#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MiscPatternSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MiscPatternSuggestion::AttemptedIntegerLiteral {
start_span: __binding_0 } => {
let __code_23 =
[::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("alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits")),
&sub_args);
diag.span_suggestions_with_style(__binding_0, __message,
__code_23, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1329pub(crate) enum MiscPatternSuggestion {
1330#[suggestion(
1331"alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits",
1332 code = "_",
1333 applicability = "maybe-incorrect"
1334)]
1335AttemptedIntegerLiteral {
1336#[primary_span]
1337start_span: Span,
1338 },
1339}
13401341#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopMatchInvalidUpdate where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopMatchInvalidUpdate {
lhs: __binding_0, scrutinee: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid update of the `#[loop_match]` state")));
;
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the assignment must update this variable")));
diag
}
}
}
}
};Diagnostic)]
1342#[diag("invalid update of the `#[loop_match]` state")]
1343pub(crate) struct LoopMatchInvalidUpdate {
1344#[primary_span]
1345pub lhs: Span,
1346#[label("the assignment must update this variable")]
1347pub scrutinee: Span,
1348}
13491350#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopMatchInvalidMatch where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopMatchInvalidMatch { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid match on `#[loop_match]` state")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a local variable must be the scrutinee within a `#[loop_match]`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1351#[diag("invalid match on `#[loop_match]` state")]
1352#[note("a local variable must be the scrutinee within a `#[loop_match]`")]
1353pub(crate) struct LoopMatchInvalidMatch {
1354#[primary_span]
1355pub span: Span,
1356}
13571358#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
LoopMatchUnsupportedType<'tcx> where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopMatchUnsupportedType {
span: __binding_0, ty: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `#[loop_match]` state value has type `{$ty}`, which is not supported")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only integers, floats, bool, char, and enums without fields are supported")));
;
diag.arg("ty", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1359#[diag("this `#[loop_match]` state value has type `{$ty}`, which is not supported")]
1360#[note("only integers, floats, bool, char, and enums without fields are supported")]
1361pub(crate) struct LoopMatchUnsupportedType<'tcx> {
1362#[primary_span]
1363pub span: Span,
1364pub ty: Ty<'tcx>,
1365}
13661367#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopMatchBadStatements where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopMatchBadStatements { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("statements are not allowed in this position within a `#[loop_match]`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1368#[diag("statements are not allowed in this position within a `#[loop_match]`")]
1369pub(crate) struct LoopMatchBadStatements {
1370#[primary_span]
1371pub span: Span,
1372}
13731374#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopMatchBadRhs where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopMatchBadRhs { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression must be a single `match` wrapped in a labeled block")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1375#[diag("this expression must be a single `match` wrapped in a labeled block")]
1376pub(crate) struct LoopMatchBadRhs {
1377#[primary_span]
1378pub span: Span,
1379}
13801381#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopMatchMissingAssignment where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopMatchMissingAssignment { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a single assignment expression")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1382#[diag("expected a single assignment expression")]
1383pub(crate) struct LoopMatchMissingAssignment {
1384#[primary_span]
1385pub span: Span,
1386}
13871388#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LoopMatchArmWithGuard where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
LoopMatchArmWithGuard { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("match arms that are part of a `#[loop_match]` cannot have guards")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1389#[diag("match arms that are part of a `#[loop_match]` cannot have guards")]
1390pub(crate) struct LoopMatchArmWithGuard {
1391#[primary_span]
1392pub span: Span,
1393}
13941395#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstContinueNotMonomorphicConst where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstContinueNotMonomorphicConst {
span: __binding_0, reason: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not determine the target branch for this `#[const_continue]`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try extracting the expression into a `const` item")));
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
1396#[diag("could not determine the target branch for this `#[const_continue]`")]
1397#[help("try extracting the expression into a `const` item")]
1398pub(crate) struct ConstContinueNotMonomorphicConst {
1399#[primary_span]
1400pub span: Span,
14011402#[subdiagnostic]
1403pub reason: ConstContinueNotMonomorphicConstReason,
1404}
14051406#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
ConstContinueNotMonomorphicConstReason {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ConstContinueNotMonomorphicConstReason::ConstantParameter {
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("constant parameters may use generics, and are not evaluated early enough")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ConstContinueNotMonomorphicConstReason::ConstBlock {
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("`const` blocks may use generics, and are not evaluated early enough")),
&sub_args);
diag.span_label(__binding_0, __message);
}
ConstContinueNotMonomorphicConstReason::Other {
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("this value must be a literal or a monomorphic const")),
&sub_args);
diag.span_label(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
1407pub(crate) enum ConstContinueNotMonomorphicConstReason {
1408#[label("constant parameters may use generics, and are not evaluated early enough")]
1409ConstantParameter {
1410#[primary_span]
1411span: Span,
1412 },
14131414#[label("`const` blocks may use generics, and are not evaluated early enough")]
1415ConstBlock {
1416#[primary_span]
1417span: Span,
1418 },
14191420#[label("this value must be a literal or a monomorphic const")]
1421Other {
1422#[primary_span]
1423span: Span,
1424 },
1425}
14261427#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstContinueBadConst where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstContinueBadConst { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not determine the target branch for this `#[const_continue]`")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this value is too generic")));
diag
}
}
}
}
};Diagnostic)]
1428#[diag("could not determine the target branch for this `#[const_continue]`")]
1429pub(crate) struct ConstContinueBadConst {
1430#[primary_span]
1431 #[label("this value is too generic")]
1432pub span: Span,
1433}
14341435#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstContinueMissingLabelOrValue where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstContinueMissingLabelOrValue { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `#[const_continue]` must break to a label with a value")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1436#[diag("a `#[const_continue]` must break to a label with a value")]
1437pub(crate) struct ConstContinueMissingLabelOrValue {
1438#[primary_span]
1439pub span: Span,
1440}
14411442#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ConstContinueUnknownJumpTarget where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
ConstContinueUnknownJumpTarget { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the target of this `#[const_continue]` is not statically known")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
1443#[diag("the target of this `#[const_continue]` is not statically known")]
1444pub(crate) struct ConstContinueUnknownJumpTarget {
1445#[primary_span]
1446pub span: Span,
1447}