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("start_of_line_suggestion".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
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}
726727#[derive(const _: () =
{
impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
UnreachablePattern<'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 {
UnreachablePattern {
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,
covered_by_many_n_more_count: __binding_11,
suggest_remove: __binding_12 } => {
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);
diag.arg("covered_by_many_n_more_count", __binding_11);
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_12) = __binding_12 {
diag.span_suggestions_with_style(__binding_12,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the match arm")),
__code_3, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
728#[diag("unreachable pattern")]
729pub(crate) struct UnreachablePattern<'tcx> {
730#[label("no value can reach this")]
731pub(crate) span: Option<Span>,
732#[label("matches no values because `{$matches_no_values_ty}` is uninhabited")]
733pub(crate) matches_no_values: Option<Span>,
734pub(crate) matches_no_values_ty: Ty<'tcx>,
735#[note(
736"to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types"
737)]
738pub(crate) uninhabited_note: Option<()>,
739#[label("matches any value")]
740pub(crate) covered_by_catchall: Option<Span>,
741#[subdiagnostic]
742pub(crate) wanted_constant: Option<WantedConstant>,
743#[note(
744"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"
745)]
746pub(crate) accessible_constant: Option<Span>,
747#[note(
748"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"
749)]
750pub(crate) inaccessible_constant: Option<Span>,
751#[note(
752"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"
753)]
754pub(crate) pattern_let_binding: Option<Span>,
755#[label("matches all the relevant values")]
756pub(crate) covered_by_one: Option<Span>,
757#[note("multiple earlier patterns match some of the same values")]
758pub(crate) covered_by_many: Option<MultiSpan>,
759pub(crate) covered_by_many_n_more_count: usize,
760#[suggestion("remove the match arm", code = "", applicability = "machine-applicable")]
761pub(crate) suggest_remove: Option<Span>,
762}
763764#[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));
sub_args.insert("const_path".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("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)]
765#[suggestion(
766"you might have meant to pattern match against the value of {$is_typo ->
767 [true] similarly named constant
768 *[false] constant
769 } `{$const_name}` instead of introducing a new catch-all binding",
770 code = "{const_path}",
771 applicability = "machine-applicable"
772)]
773pub(crate) struct WantedConstant {
774#[primary_span]
775pub(crate) span: Span,
776pub(crate) is_typo: bool,
777pub(crate) const_name: String,
778pub(crate) const_path: String,
779}
780781#[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)]
782#[diag("unreachable {$descr}")]
783pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
784pub descr: &'desc str,
785#[label("unreachable {$descr}")]
786pub expr: Span,
787#[label("any code following this expression is unreachable")]
788 #[note("this expression has type `{$ty}`, which is uninhabited")]
789pub orig: Span,
790pub ty: Ty<'tcx>,
791}
792793#[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)]
794#[diag("constant pattern cannot depend on generic parameters", code = E0158)]
795pub(crate) struct ConstPatternDependsOnGenericParameter {
796#[primary_span]
797 #[label("`const` depends on a generic parameter")]
798pub(crate) span: Span,
799}
800801#[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)]
802#[diag("could not evaluate constant pattern")]
803pub(crate) struct CouldNotEvalConstPattern {
804#[primary_span]
805 #[label("could not evaluate constant")]
806pub(crate) span: Span,
807}
808809#[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)]
810#[diag("lower bound for range pattern must be less than or equal to upper bound", code = E0030)]
811pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
812#[primary_span]
813 #[label("lower bound larger than upper bound")]
814pub(crate) span: Span,
815#[note(
816"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"
817)]
818pub(crate) teach: bool,
819}
820821#[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)]
822#[diag("literal out of range for `{$ty}`")]
823pub(crate) struct LiteralOutOfRange<'tcx> {
824#[primary_span]
825 #[label("this value does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
826pub(crate) span: Span,
827pub(crate) ty: Ty<'tcx>,
828pub(crate) min: i128,
829pub(crate) max: u128,
830}
831832#[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)]
833#[diag("lower bound for range pattern must be less than upper bound", code = E0579)]
834pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
835#[primary_span]
836pub(crate) span: Span,
837}
838839#[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)]
840#[diag("exclusive upper bound for a range bound cannot be the minimum", code = E0579)]
841pub(crate) struct UpperRangeBoundCannotBeMin {
842#[primary_span]
843pub(crate) span: Span,
844}
845846#[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)]
847#[diag("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`", code = E0170)]
848pub(crate) struct BindingsWithVariantName {
849#[suggestion(
850"to match on the variant, qualify the path",
851 code = "{ty_path}::{name}",
852 applicability = "machine-applicable"
853)]
854pub(crate) suggestion: Option<Span>,
855pub(crate) ty_path: String,
856pub(crate) name: Ident,
857}
858859#[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)]
860#[diag(
861"irrefutable `if let` {$count ->
862 [one] pattern
863 *[other] patterns
864}"
865)]
866#[note(
867"{$count ->
868 [one] this pattern
869 *[other] these patterns
870} will always match, so the `if let` is useless"
871)]
872#[help("consider replacing the `if let` with a `let`")]
873pub(crate) struct IrrefutableLetPatternsIfLet {
874pub(crate) count: usize,
875}
876877#[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)]
878#[diag(
879"irrefutable `if let` guard {$count ->
880 [one] pattern
881 *[other] patterns
882}"
883)]
884#[note(
885"{$count ->
886 [one] this pattern
887 *[other] these patterns
888} will always match, so the guard is useless"
889)]
890#[help("consider removing the guard and adding a `let` inside the match arm")]
891pub(crate) struct IrrefutableLetPatternsIfLetGuard {
892pub(crate) count: usize,
893}
894895#[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)]
896#[diag("unreachable `else` clause")]
897#[note("this pattern always matches, so the else clause is unreachable")]
898pub(crate) struct IrrefutableLetPatternsLetElse {
899#[subdiagnostic]
900pub(crate) be_replaced: Option<LetElseReplacementSuggestion>,
901}
902903#[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)]
904#[suggestion(
905"consider using `let {$lhs} = {$rhs}` to match on a specific variant",
906 code = "let {lhs} = {rhs}",
907 applicability = "machine-applicable"
908)]
909pub(crate) struct LetElseReplacementSuggestion {
910#[primary_span]
911pub(crate) span: Span,
912pub(crate) lhs: String,
913pub(crate) rhs: String,
914}
915916#[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)]
917#[diag(
918"irrefutable `while let` {$count ->
919 [one] pattern
920 *[other] patterns
921}"
922)]
923#[note(
924"{$count ->
925 [one] this pattern
926 *[other] these patterns
927} will always match, so the loop will never exit"
928)]
929#[help("consider instead using a `loop {\"{\"} ... {\"}\"}` with a `let` inside it")]
930pub(crate) struct IrrefutableLetPatternsWhileLet {
931pub(crate) count: usize,
932}
933934#[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)]
935#[diag("borrow of moved value")]
936pub(crate) struct BorrowOfMovedValue<'tcx> {
937#[primary_span]
938 #[label("value moved into `{$name}` here")]
939 #[label(
940"move occurs because `{$name}` has type `{$ty}`, which does not implement the `Copy` trait"
941)]
942pub(crate) binding_span: Span,
943#[label("value borrowed here after move")]
944pub(crate) conflicts_ref: Vec<Span>,
945pub(crate) name: Ident,
946pub(crate) ty: Ty<'tcx>,
947#[suggestion(
948"borrow this binding in the pattern to avoid moving the value",
949 code = "ref ",
950 applicability = "machine-applicable"
951)]
952pub(crate) suggest_borrowing: Option<Span>,
953}
954955#[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)]
956#[diag("cannot borrow value as mutable more than once at a time")]
957pub(crate) struct MultipleMutBorrows {
958#[primary_span]
959pub(crate) span: Span,
960#[subdiagnostic]
961pub(crate) occurrences: Vec<Conflict>,
962}
963964#[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)]
965#[diag("cannot borrow value as mutable because it is also borrowed as immutable")]
966pub(crate) struct AlreadyBorrowed {
967#[primary_span]
968pub(crate) span: Span,
969#[subdiagnostic]
970pub(crate) occurrences: Vec<Conflict>,
971}
972973#[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)]
974#[diag("cannot borrow value as immutable because it is also borrowed as mutable")]
975pub(crate) struct AlreadyMutBorrowed {
976#[primary_span]
977pub(crate) span: Span,
978#[subdiagnostic]
979pub(crate) occurrences: Vec<Conflict>,
980}
981982#[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)]
983#[diag("cannot move out of value because it is borrowed")]
984pub(crate) struct MovedWhileBorrowed {
985#[primary_span]
986pub(crate) span: Span,
987#[subdiagnostic]
988pub(crate) occurrences: Vec<Conflict>,
989}
990991#[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)]
992pub(crate) enum Conflict {
993#[label("value is mutably borrowed by `{$name}` here")]
994Mut {
995#[primary_span]
996span: Span,
997 name: Symbol,
998 },
999#[label("value is borrowed by `{$name}` here")]
1000Ref {
1001#[primary_span]
1002span: Span,
1003 name: Symbol,
1004 },
1005#[label("value is moved into `{$name}` here")]
1006Moved {
1007#[primary_span]
1008span: Span,
1009 name: Symbol,
1010 },
1011}
10121013#[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)]
1014#[diag("cannot use unions in constant patterns")]
1015pub(crate) struct UnionPattern {
1016#[primary_span]
1017 #[label("can't use a `union` here")]
1018pub(crate) span: Span,
1019}
10201021#[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)]
1022#[diag("constant of non-structural type `{$ty}` in a pattern")]
1023pub(crate) struct TypeNotStructural<'tcx> {
1024#[primary_span]
1025 #[label("constant of non-structural type")]
1026pub(crate) span: Span,
1027#[label(
1028"{$is_local ->
1029 *[true] `{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
1030 [false] `{$ty}` is not usable in patterns
1031 }"
1032)]
1033pub(crate) ty_def_span: Span,
1034pub(crate) ty: Ty<'tcx>,
1035#[note(
1036"the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see \
1037 https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1038)]
1039pub(crate) manual_partialeq_impl_span: Option<Span>,
1040#[note(
1041"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1042)]
1043pub(crate) manual_partialeq_impl_note: bool,
1044#[subdiagnostic]
1045pub(crate) suggestion: Option<SuggestEq<'tcx>>,
1046pub(crate) is_local: bool,
1047}
10481049#[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("name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
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("name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
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("name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
&mut diag.long_ty_path));
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)]
1050pub(crate) enum SuggestEq<'tcx> {
1051#[multipart_suggestion(
1052"{$manual_partialeq_impl ->
1053 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1054 *[true] add
1055 } a condition to the match arm checking for equality",
1056 applicability = "maybe-incorrect",
1057 style = "verbose"
1058)]
1059AddIf {
1060#[suggestion_part(code = "binding")]
1061pat_span: Span,
1062#[suggestion_part(code = " if binding == {name}")]
1063if_span: Span,
1064 name: String,
1065 ty: Ty<'tcx>,
1066 manual_partialeq_impl: bool,
1067 },
1068#[multipart_suggestion(
1069"{$manual_partialeq_impl ->
1070 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1071 *[true] add
1072 } a check for equality to the condition of the match arm",
1073 applicability = "maybe-incorrect",
1074 style = "verbose"
1075)]
1076AddToIf {
1077#[suggestion_part(code = "binding")]
1078pat_span: Span,
1079#[suggestion_part(code = " && binding == {name}")]
1080span: Span,
1081 name: String,
1082 ty: Ty<'tcx>,
1083 manual_partialeq_impl: bool,
1084 },
1085#[multipart_suggestion(
1086"{$manual_partialeq_impl ->
1087 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1088 *[true] check
1089 } for equality instead of pattern matching",
1090 applicability = "maybe-incorrect",
1091 style = "verbose"
1092)]
1093AddToLetChain {
1094#[suggestion_part(code = "binding")]
1095pat_span: Span,
1096#[suggestion_part(code = " && binding == {name}")]
1097span: Span,
1098 name: String,
1099 ty: Ty<'tcx>,
1100 manual_partialeq_impl: bool,
1101 },
1102#[multipart_suggestion(
1103"{$manual_partialeq_impl ->
1104 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1105 *[true] check
1106 } for equality instead of pattern matching",
1107 applicability = "maybe-incorrect",
1108 style = "verbose"
1109)]
1110ReplaceWithEq {
1111#[suggestion_part(code = "")]
1112removal: Span,
1113#[suggestion_part(code = " == ")]
1114eq: Span,
1115 ty: Ty<'tcx>,
1116 manual_partialeq_impl: bool,
1117 },
1118#[multipart_suggestion(
1119"{$manual_partialeq_impl ->
1120 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1121 *[true] check
1122 } for equality instead of pattern matching",
1123 applicability = "maybe-incorrect",
1124 style = "verbose"
1125)]
1126ReplaceLetElseWithIf {
1127#[suggestion_part(code = "if ")]
1128if_span: Span,
1129#[suggestion_part(code = " == ")]
1130eq: Span,
1131#[suggestion_part(code = " ")]
1132else_span: Span,
1133 ty: Ty<'tcx>,
1134 manual_partialeq_impl: bool,
1135 },
1136}
11371138#[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)]
1139#[diag("constant of non-structural type `{$ty}` in a pattern")]
1140#[note(
1141"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1142)]
1143pub(crate) struct TypeNotPartialEq<'tcx> {
1144#[primary_span]
1145 #[label("constant of non-structural type")]
1146pub(crate) span: Span,
1147pub(crate) ty: Ty<'tcx>,
1148}
11491150#[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)]
1151#[diag("{$prefix} `{$non_sm_ty}` cannot be used in patterns")]
1152pub(crate) struct InvalidPattern<'tcx> {
1153#[primary_span]
1154 #[label("{$prefix} can't be used in patterns")]
1155pub(crate) span: Span,
1156pub(crate) non_sm_ty: Ty<'tcx>,
1157pub(crate) prefix: String,
1158}
11591160#[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)]
1161#[diag("cannot use unsized non-slice type `{$non_sm_ty}` in constant patterns")]
1162pub(crate) struct UnsizedPattern<'tcx> {
1163#[primary_span]
1164pub(crate) span: Span,
1165pub(crate) non_sm_ty: Ty<'tcx>,
1166}
11671168#[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)]
1169#[diag("cannot use NaN in patterns")]
1170#[note("NaNs compare inequal to everything, even themselves, so this pattern would never match")]
1171#[help("try using the `is_nan` method instead")]
1172pub(crate) struct NaNPattern {
1173#[primary_span]
1174 #[label("evaluates to `NaN`, which is not allowed in patterns")]
1175pub(crate) span: Span,
1176}
11771178#[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)]
1179#[diag(
1180"function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon"
1181)]
1182#[note("see https://github.com/rust-lang/rust/issues/70861 for details")]
1183pub(crate) struct PointerPattern {
1184#[primary_span]
1185 #[label("can't be used in patterns")]
1186pub(crate) span: Span,
1187}
11881189#[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)]
1190#[diag("mismatched types")]
1191#[note("the matched value is of type `{$ty}`")]
1192pub(crate) struct NonEmptyNeverPattern<'tcx> {
1193#[primary_span]
1194 #[label("a never pattern must be used on an uninhabited type")]
1195pub(crate) span: Span,
1196pub(crate) ty: Ty<'tcx>,
1197}
11981199#[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)]
1200#[diag("refutable pattern in {$origin}", code = E0005)]
1201pub(crate) struct PatternNotCovered<'s, 'tcx> {
1202#[primary_span]
1203pub(crate) span: Span,
1204pub(crate) origin: &'s str,
1205#[subdiagnostic]
1206pub(crate) uncovered: Uncovered,
1207#[subdiagnostic]
1208pub(crate) inform: Option<Inform>,
1209#[subdiagnostic]
1210pub(crate) interpreted_as_const: Option<InterpretedAsConst>,
1211#[subdiagnostic]
1212pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConstSugg>,
1213#[subdiagnostic]
1214pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
1215#[note(
1216"pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future"
1217)]
1218pub(crate) witness_1_is_privately_uninhabited: bool,
1219pub(crate) witness_1: String,
1220#[note("the matched value is of type `{$pattern_ty}`")]
1221pub(crate) _p: (),
1222pub(crate) pattern_ty: Ty<'tcx>,
1223#[subdiagnostic]
1224pub(crate) let_suggestion: Option<SuggestLet>,
1225#[subdiagnostic]
1226pub(crate) misc_suggestion: Option<MiscPatternSuggestion>,
1227}
12281229#[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)]
1230#[note(
1231"`let` bindings require an \"irrefutable pattern\", like a `struct` or an `enum` with only one variant"
1232)]
1233#[note("for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html")]
1234pub(crate) struct Inform;
12351236#[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)]
1237#[label(
1238"missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable"
1239)]
1240pub(crate) struct InterpretedAsConst {
1241#[primary_span]
1242pub(crate) span: Span,
1243pub(crate) variable: String,
1244}
12451246pub(crate) struct AdtDefinedHere<'tcx> {
1247pub(crate) adt_def_span: Span,
1248pub(crate) ty: Ty<'tcx>,
1249pub(crate) variants: Vec<Variant>,
1250}
12511252pub(crate) struct Variant {
1253pub(crate) span: Span,
1254}
12551256impl<'tcx> Subdiagnosticfor AdtDefinedHere<'tcx> {
1257fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1258diag.arg("ty", self.ty);
1259let mut spans = MultiSpan::from(self.adt_def_span);
12601261for Variant { span } in self.variants {
1262 spans.push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not covered"))msg!("not covered"));
1263 }
12641265diag.span_note(spans, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` defined here"))msg!("`{$ty}` defined here"));
1266 }
1267}
12681269#[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();
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("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)]
1270#[suggestion(
1271"introduce a variable instead",
1272 code = "{variable}_var",
1273 applicability = "maybe-incorrect",
1274 style = "verbose"
1275)]
1276pub(crate) struct InterpretedAsConstSugg {
1277#[primary_span]
1278pub(crate) span: Span,
1279pub(crate) variable: String,
1280}
12811282#[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)]
1283pub(crate) enum SuggestLet {
1284#[multipart_suggestion(
1285"you might want to use `if let` to ignore the {$count ->
1286 [one] variant that isn't
1287 *[other] variants that aren't
1288 } matched",
1289 applicability = "has-placeholders"
1290)]
1291If {
1292#[suggestion_part(code = "if ")]
1293start_span: Span,
1294#[suggestion_part(code = " {{ todo!() }}")]
1295semi_span: Span,
1296 count: usize,
1297 },
1298#[suggestion(
1299"you might want to use `let...else` to handle the {$count ->
1300 [one] variant that isn't
1301 *[other] variants that aren't
1302 } matched",
1303 code = " else {{ todo!() }}",
1304 applicability = "has-placeholders"
1305)]
1306Else {
1307#[primary_span]
1308end_span: Span,
1309 count: usize,
1310 },
1311}
13121313#[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)]
1314pub(crate) enum MiscPatternSuggestion {
1315#[suggestion(
1316"alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits",
1317 code = "_",
1318 applicability = "maybe-incorrect"
1319)]
1320AttemptedIntegerLiteral {
1321#[primary_span]
1322start_span: Span,
1323 },
1324}
13251326#[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)]
1327#[diag("invalid update of the `#[loop_match]` state")]
1328pub(crate) struct LoopMatchInvalidUpdate {
1329#[primary_span]
1330pub lhs: Span,
1331#[label("the assignment must update this variable")]
1332pub scrutinee: Span,
1333}
13341335#[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)]
1336#[diag("invalid match on `#[loop_match]` state")]
1337#[note("a local variable must be the scrutinee within a `#[loop_match]`")]
1338pub(crate) struct LoopMatchInvalidMatch {
1339#[primary_span]
1340pub span: Span,
1341}
13421343#[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)]
1344#[diag("this `#[loop_match]` state value has type `{$ty}`, which is not supported")]
1345#[note("only integers, floats, bool, char, and enums without fields are supported")]
1346pub(crate) struct LoopMatchUnsupportedType<'tcx> {
1347#[primary_span]
1348pub span: Span,
1349pub ty: Ty<'tcx>,
1350}
13511352#[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)]
1353#[diag("statements are not allowed in this position within a `#[loop_match]`")]
1354pub(crate) struct LoopMatchBadStatements {
1355#[primary_span]
1356pub span: Span,
1357}
13581359#[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)]
1360#[diag("this expression must be a single `match` wrapped in a labeled block")]
1361pub(crate) struct LoopMatchBadRhs {
1362#[primary_span]
1363pub span: Span,
1364}
13651366#[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)]
1367#[diag("expected a single assignment expression")]
1368pub(crate) struct LoopMatchMissingAssignment {
1369#[primary_span]
1370pub span: Span,
1371}
13721373#[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)]
1374#[diag("match arms that are part of a `#[loop_match]` cannot have guards")]
1375pub(crate) struct LoopMatchArmWithGuard {
1376#[primary_span]
1377pub span: Span,
1378}
13791380#[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)]
1381#[diag("could not determine the target branch for this `#[const_continue]`")]
1382#[help("try extracting the expression into a `const` item")]
1383pub(crate) struct ConstContinueNotMonomorphicConst {
1384#[primary_span]
1385pub span: Span,
13861387#[subdiagnostic]
1388pub reason: ConstContinueNotMonomorphicConstReason,
1389}
13901391#[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)]
1392pub(crate) enum ConstContinueNotMonomorphicConstReason {
1393#[label("constant parameters may use generics, and are not evaluated early enough")]
1394ConstantParameter {
1395#[primary_span]
1396span: Span,
1397 },
13981399#[label("`const` blocks may use generics, and are not evaluated early enough")]
1400ConstBlock {
1401#[primary_span]
1402span: Span,
1403 },
14041405#[label("this value must be a literal or a monomorphic const")]
1406Other {
1407#[primary_span]
1408span: Span,
1409 },
1410}
14111412#[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)]
1413#[diag("could not determine the target branch for this `#[const_continue]`")]
1414pub(crate) struct ConstContinueBadConst {
1415#[primary_span]
1416 #[label("this value is too generic")]
1417pub span: Span,
1418}
14191420#[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)]
1421#[diag("a `#[const_continue]` must break to a label with a value")]
1422pub(crate) struct ConstContinueMissingLabelOrValue {
1423#[primary_span]
1424pub span: Span,
1425}
14261427#[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)]
1428#[diag("the target of this `#[const_continue]` is not statically known")]
1429pub(crate) struct ConstContinueUnknownJumpTarget {
1430#[primary_span]
1431pub span: Span,
1432}