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 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)]
566#[label("items do not inherit unsafety from separate enclosing items")]
567pub(crate) struct UnsafeNotInheritedNote {
568#[primary_span]
569pub(crate) span: Span,
570}
571572pub(crate) struct UnsafeNotInheritedLintNote {
573pub(crate) signature_span: Span,
574pub(crate) body_span: Span,
575}
576577impl Subdiagnosticfor UnsafeNotInheritedLintNote {
578fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
579diag.span_note(
580self.signature_span,
581rustc_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"),
582 );
583let body_start = self.body_span.shrink_to_lo();
584let body_end = self.body_span.shrink_to_hi();
585diag.tool_only_multipart_suggestion(
586rustc_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"),
587::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())],
588 Applicability::MachineApplicable,
589 );
590 }
591}
592593#[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)]
594#[diag("unnecessary `unsafe` block")]
595pub(crate) struct UnusedUnsafe {
596#[label("unnecessary `unsafe` block")]
597pub(crate) span: Span,
598#[subdiagnostic]
599pub(crate) enclosing: Option<UnusedUnsafeEnclosing>,
600}
601602#[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)]
603pub(crate) enum UnusedUnsafeEnclosing {
604#[label("because it's nested under this `unsafe` block")]
605Block {
606#[primary_span]
607span: Span,
608 },
609}
610611pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'a, 'tcx> {
612pub(crate) cx: &'a RustcPatCtxt<'a, 'tcx>,
613pub(crate) scrut_span: Span,
614pub(crate) braces_span: Option<Span>,
615pub(crate) ty: Ty<'tcx>,
616}
617618impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_> {
619fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
620let mut diag =
621Diag::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"));
622diag.span(self.scrut_span);
623diag.code(E0004);
624let peeled_ty = self.ty.peel_refs();
625diag.arg("ty", self.ty);
626diag.arg("peeled_ty", peeled_ty);
627628if let ty::Adt(def, _) = peeled_ty.kind() {
629let def_span = self630 .cx
631 .tcx
632 .hir_get_if_local(def.did())
633 .and_then(|node| node.ident())
634 .map(|ident| ident.span)
635 .unwrap_or_else(|| self.cx.tcx.def_span(def.did()));
636637// workaround to make test pass
638let mut span: MultiSpan = def_span.into();
639span.push_span_label(def_span, "");
640641diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$peeled_ty}` defined here"))msg!("`{$peeled_ty}` defined here"));
642 }
643644let 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(),
645 ty::Adt(def, _) if def.variant_list_has_applicable_non_exhaustive());
646if is_non_exhaustive {
647diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`, which is marked as non-exhaustive"))msg!(
648"the matched value is of type `{$ty}`, which is marked as non-exhaustive"
649));
650 } else {
651diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`"))msg!("the matched value is of type `{$ty}`"));
652 }
653654if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
655if !sub_ty.is_inhabited_from(self.cx.tcx, self.cx.module, self.cx.typing_env) {
656diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are always considered inhabited"))msg!("references are always considered inhabited"));
657 }
658 }
659660let sm = self.cx.tcx.sess.source_map();
661if let Some(braces_span) = self.braces_span {
662// Get the span for the empty match body `{}`.
663let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.scrut_span)
664 {
665 (::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\n{0}", snippet))
})format!("\n{snippet}"), " ")
666 } else {
667 (" ".to_string(), "")
668 };
669diag.span_suggestion_verbose(
670braces_span,
671rustc_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"),
672::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{{0}{1}_ => todo!(),{0}}}",
indentation, more))
})format!(" {{{indentation}{more}_ => todo!(),{indentation}}}"),
673 Applicability::HasPlaceholders,
674 );
675 } else {
676diag.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!(
677"ensure that all possible cases are being handled by adding a match arm with a wildcard pattern"
678));
679 }
680681diag682 }
683}
684685#[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)]
686#[note("match arms with guards don't count towards exhaustivity")]
687pub(crate) struct NonExhaustiveMatchAllArmsGuarded;
688689#[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)]
690#[diag("statics cannot be referenced in patterns", code = E0158)]
691pub(crate) struct StaticInPattern {
692#[primary_span]
693 #[label("can't be used in patterns")]
694pub(crate) span: Span,
695#[label("`static` defined here")]
696pub(crate) static_span: Span,
697}
698699#[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)]
700#[diag("constant parameters cannot be referenced in patterns", code = E0158)]
701pub(crate) struct ConstParamInPattern {
702#[primary_span]
703 #[label("can't be used in patterns")]
704pub(crate) span: Span,
705#[label("constant defined here")]
706pub(crate) const_span: Span,
707}
708709#[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)]
710#[diag("runtime values cannot be referenced in patterns", code = E0080)]
711pub(crate) struct NonConstPath {
712#[primary_span]
713 #[label("references a runtime value")]
714pub(crate) span: Span,
715}
716717#[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)]
718#[diag("unreachable pattern")]
719pub(crate) struct UnreachablePattern<'tcx> {
720#[label("no value can reach this")]
721pub(crate) span: Option<Span>,
722#[label("matches no values because `{$matches_no_values_ty}` is uninhabited")]
723pub(crate) matches_no_values: Option<Span>,
724pub(crate) matches_no_values_ty: Ty<'tcx>,
725#[note(
726"to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types"
727)]
728pub(crate) uninhabited_note: Option<()>,
729#[label("matches any value")]
730pub(crate) covered_by_catchall: Option<Span>,
731#[subdiagnostic]
732pub(crate) wanted_constant: Option<WantedConstant>,
733#[note(
734"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"
735)]
736pub(crate) accessible_constant: Option<Span>,
737#[note(
738"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"
739)]
740pub(crate) inaccessible_constant: Option<Span>,
741#[note(
742"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"
743)]
744pub(crate) pattern_let_binding: Option<Span>,
745#[label("matches all the relevant values")]
746pub(crate) covered_by_one: Option<Span>,
747#[note("multiple earlier patterns match some of the same values")]
748pub(crate) covered_by_many: Option<MultiSpan>,
749pub(crate) covered_by_many_n_more_count: usize,
750#[suggestion("remove the match arm", code = "", applicability = "machine-applicable")]
751pub(crate) suggest_remove: Option<Span>,
752}
753754#[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)]
755#[suggestion(
756"you might have meant to pattern match against the value of {$is_typo ->
757 [true] similarly named constant
758 *[false] constant
759 } `{$const_name}` instead of introducing a new catch-all binding",
760 code = "{const_path}",
761 applicability = "machine-applicable"
762)]
763pub(crate) struct WantedConstant {
764#[primary_span]
765pub(crate) span: Span,
766pub(crate) is_typo: bool,
767pub(crate) const_name: String,
768pub(crate) const_path: String,
769}
770771#[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)]
772#[diag("unreachable {$descr}")]
773pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
774pub descr: &'desc str,
775#[label("unreachable {$descr}")]
776pub expr: Span,
777#[label("any code following this expression is unreachable")]
778 #[note("this expression has type `{$ty}`, which is uninhabited")]
779pub orig: Span,
780pub ty: Ty<'tcx>,
781}
782783#[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)]
784#[diag("constant pattern cannot depend on generic parameters", code = E0158)]
785pub(crate) struct ConstPatternDependsOnGenericParameter {
786#[primary_span]
787 #[label("`const` depends on a generic parameter")]
788pub(crate) span: Span,
789}
790791#[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)]
792#[diag("could not evaluate constant pattern")]
793pub(crate) struct CouldNotEvalConstPattern {
794#[primary_span]
795 #[label("could not evaluate constant")]
796pub(crate) span: Span,
797}
798799#[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)]
800#[diag("lower bound for range pattern must be less than or equal to upper bound", code = E0030)]
801pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
802#[primary_span]
803 #[label("lower bound larger than upper bound")]
804pub(crate) span: Span,
805#[note(
806"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"
807)]
808pub(crate) teach: bool,
809}
810811#[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)]
812#[diag("literal out of range for `{$ty}`")]
813pub(crate) struct LiteralOutOfRange<'tcx> {
814#[primary_span]
815 #[label("this value does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
816pub(crate) span: Span,
817pub(crate) ty: Ty<'tcx>,
818pub(crate) min: i128,
819pub(crate) max: u128,
820}
821822#[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)]
823#[diag("lower bound for range pattern must be less than upper bound", code = E0579)]
824pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
825#[primary_span]
826pub(crate) span: Span,
827}
828829#[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)]
830#[diag("exclusive upper bound for a range bound cannot be the minimum", code = E0579)]
831pub(crate) struct UpperRangeBoundCannotBeMin {
832#[primary_span]
833pub(crate) span: Span,
834}
835836#[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)]
837#[diag("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`", code = E0170)]
838pub(crate) struct BindingsWithVariantName {
839#[suggestion(
840"to match on the variant, qualify the path",
841 code = "{ty_path}::{name}",
842 applicability = "machine-applicable"
843)]
844pub(crate) suggestion: Option<Span>,
845pub(crate) ty_path: String,
846pub(crate) name: Ident,
847}
848849#[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)]
850#[diag(
851"irrefutable `if let` {$count ->
852 [one] pattern
853 *[other] patterns
854}"
855)]
856#[note(
857"{$count ->
858 [one] this pattern
859 *[other] these patterns
860} will always match, so the `if let` is useless"
861)]
862#[help("consider replacing the `if let` with a `let`")]
863pub(crate) struct IrrefutableLetPatternsIfLet {
864pub(crate) count: usize,
865}
866867#[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)]
868#[diag(
869"irrefutable `if let` guard {$count ->
870 [one] pattern
871 *[other] patterns
872}"
873)]
874#[note(
875"{$count ->
876 [one] this pattern
877 *[other] these patterns
878} will always match, so the guard is useless"
879)]
880#[help("consider removing the guard and adding a `let` inside the match arm")]
881pub(crate) struct IrrefutableLetPatternsIfLetGuard {
882pub(crate) count: usize,
883}
884885#[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)]
886#[diag("unreachable `else` clause")]
887#[note("this pattern always matches, so the else clause is unreachable")]
888pub(crate) struct IrrefutableLetPatternsLetElse {
889#[subdiagnostic]
890pub(crate) be_replaced: Option<LetElseReplacementSuggestion>,
891}
892893#[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)]
894#[suggestion(
895"consider using `let {$lhs} = {$rhs}` to match on a specific variant",
896 code = "let {lhs} = {rhs}",
897 applicability = "machine-applicable"
898)]
899pub(crate) struct LetElseReplacementSuggestion {
900#[primary_span]
901pub(crate) span: Span,
902pub(crate) lhs: String,
903pub(crate) rhs: String,
904}
905906#[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)]
907#[diag(
908"irrefutable `while let` {$count ->
909 [one] pattern
910 *[other] patterns
911}"
912)]
913#[note(
914"{$count ->
915 [one] this pattern
916 *[other] these patterns
917} will always match, so the loop will never exit"
918)]
919#[help("consider instead using a `loop {\"{\"} ... {\"}\"}` with a `let` inside it")]
920pub(crate) struct IrrefutableLetPatternsWhileLet {
921pub(crate) count: usize,
922}
923924#[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)]
925#[diag("borrow of moved value")]
926pub(crate) struct BorrowOfMovedValue<'tcx> {
927#[primary_span]
928 #[label("value moved into `{$name}` here")]
929 #[label(
930"move occurs because `{$name}` has type `{$ty}`, which does not implement the `Copy` trait"
931)]
932pub(crate) binding_span: Span,
933#[label("value borrowed here after move")]
934pub(crate) conflicts_ref: Vec<Span>,
935pub(crate) name: Ident,
936pub(crate) ty: Ty<'tcx>,
937#[suggestion(
938"borrow this binding in the pattern to avoid moving the value",
939 code = "ref ",
940 applicability = "machine-applicable"
941)]
942pub(crate) suggest_borrowing: Option<Span>,
943}
944945#[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)]
946#[diag("cannot borrow value as mutable more than once at a time")]
947pub(crate) struct MultipleMutBorrows {
948#[primary_span]
949pub(crate) span: Span,
950#[subdiagnostic]
951pub(crate) occurrences: Vec<Conflict>,
952}
953954#[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)]
955#[diag("cannot borrow value as mutable because it is also borrowed as immutable")]
956pub(crate) struct AlreadyBorrowed {
957#[primary_span]
958pub(crate) span: Span,
959#[subdiagnostic]
960pub(crate) occurrences: Vec<Conflict>,
961}
962963#[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)]
964#[diag("cannot borrow value as immutable because it is also borrowed as mutable")]
965pub(crate) struct AlreadyMutBorrowed {
966#[primary_span]
967pub(crate) span: Span,
968#[subdiagnostic]
969pub(crate) occurrences: Vec<Conflict>,
970}
971972#[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)]
973#[diag("cannot move out of value because it is borrowed")]
974pub(crate) struct MovedWhileBorrowed {
975#[primary_span]
976pub(crate) span: Span,
977#[subdiagnostic]
978pub(crate) occurrences: Vec<Conflict>,
979}
980981#[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)]
982pub(crate) enum Conflict {
983#[label("value is mutably borrowed by `{$name}` here")]
984Mut {
985#[primary_span]
986span: Span,
987 name: Symbol,
988 },
989#[label("value is borrowed by `{$name}` here")]
990Ref {
991#[primary_span]
992span: Span,
993 name: Symbol,
994 },
995#[label("value is moved into `{$name}` here")]
996Moved {
997#[primary_span]
998span: Span,
999 name: Symbol,
1000 },
1001}
10021003#[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)]
1004#[diag("cannot use unions in constant patterns")]
1005pub(crate) struct UnionPattern {
1006#[primary_span]
1007 #[label("can't use a `union` here")]
1008pub(crate) span: Span,
1009}
10101011#[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)]
1012#[diag("constant of non-structural type `{$ty}` in a pattern")]
1013pub(crate) struct TypeNotStructural<'tcx> {
1014#[primary_span]
1015 #[label("constant of non-structural type")]
1016pub(crate) span: Span,
1017#[label(
1018"{$is_local ->
1019 *[true] `{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
1020 [false] `{$ty}` is not usable in patterns
1021 }"
1022)]
1023pub(crate) ty_def_span: Span,
1024pub(crate) ty: Ty<'tcx>,
1025#[note(
1026"the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see \
1027 https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1028)]
1029pub(crate) manual_partialeq_impl_span: Option<Span>,
1030#[note(
1031"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1032)]
1033pub(crate) manual_partialeq_impl_note: bool,
1034#[subdiagnostic]
1035pub(crate) suggestion: Option<SuggestEq<'tcx>>,
1036pub(crate) is_local: bool,
1037}
10381039#[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)]
1040pub(crate) enum SuggestEq<'tcx> {
1041#[multipart_suggestion(
1042"{$manual_partialeq_impl ->
1043 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1044 *[true] add
1045 } a condition to the match arm checking for equality",
1046 applicability = "maybe-incorrect",
1047 style = "verbose"
1048)]
1049AddIf {
1050#[suggestion_part(code = "binding")]
1051pat_span: Span,
1052#[suggestion_part(code = " if binding == {name}")]
1053if_span: Span,
1054 name: String,
1055 ty: Ty<'tcx>,
1056 manual_partialeq_impl: bool,
1057 },
1058#[multipart_suggestion(
1059"{$manual_partialeq_impl ->
1060 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1061 *[true] add
1062 } a check for equality to the condition of the match arm",
1063 applicability = "maybe-incorrect",
1064 style = "verbose"
1065)]
1066AddToIf {
1067#[suggestion_part(code = "binding")]
1068pat_span: Span,
1069#[suggestion_part(code = " && binding == {name}")]
1070span: Span,
1071 name: String,
1072 ty: Ty<'tcx>,
1073 manual_partialeq_impl: bool,
1074 },
1075#[multipart_suggestion(
1076"{$manual_partialeq_impl ->
1077 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1078 *[true] check
1079 } for equality instead of pattern matching",
1080 applicability = "maybe-incorrect",
1081 style = "verbose"
1082)]
1083AddToLetChain {
1084#[suggestion_part(code = "binding")]
1085pat_span: Span,
1086#[suggestion_part(code = " && binding == {name}")]
1087span: Span,
1088 name: String,
1089 ty: Ty<'tcx>,
1090 manual_partialeq_impl: bool,
1091 },
1092#[multipart_suggestion(
1093"{$manual_partialeq_impl ->
1094 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1095 *[true] check
1096 } for equality instead of pattern matching",
1097 applicability = "maybe-incorrect",
1098 style = "verbose"
1099)]
1100ReplaceWithEq {
1101#[suggestion_part(code = "")]
1102removal: Span,
1103#[suggestion_part(code = " == ")]
1104eq: Span,
1105 ty: Ty<'tcx>,
1106 manual_partialeq_impl: bool,
1107 },
1108#[multipart_suggestion(
1109"{$manual_partialeq_impl ->
1110 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1111 *[true] check
1112 } for equality instead of pattern matching",
1113 applicability = "maybe-incorrect",
1114 style = "verbose"
1115)]
1116ReplaceLetElseWithIf {
1117#[suggestion_part(code = "if ")]
1118if_span: Span,
1119#[suggestion_part(code = " == ")]
1120eq: Span,
1121#[suggestion_part(code = " ")]
1122else_span: Span,
1123 ty: Ty<'tcx>,
1124 manual_partialeq_impl: bool,
1125 },
1126}
11271128#[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)]
1129#[diag("constant of non-structural type `{$ty}` in a pattern")]
1130#[note(
1131"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1132)]
1133pub(crate) struct TypeNotPartialEq<'tcx> {
1134#[primary_span]
1135 #[label("constant of non-structural type")]
1136pub(crate) span: Span,
1137pub(crate) ty: Ty<'tcx>,
1138}
11391140#[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)]
1141#[diag("{$prefix} `{$non_sm_ty}` cannot be used in patterns")]
1142pub(crate) struct InvalidPattern<'tcx> {
1143#[primary_span]
1144 #[label("{$prefix} can't be used in patterns")]
1145pub(crate) span: Span,
1146pub(crate) non_sm_ty: Ty<'tcx>,
1147pub(crate) prefix: String,
1148}
11491150#[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)]
1151#[diag("cannot use unsized non-slice type `{$non_sm_ty}` in constant patterns")]
1152pub(crate) struct UnsizedPattern<'tcx> {
1153#[primary_span]
1154pub(crate) span: Span,
1155pub(crate) non_sm_ty: Ty<'tcx>,
1156}
11571158#[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)]
1159#[diag("cannot use NaN in patterns")]
1160#[note("NaNs compare inequal to everything, even themselves, so this pattern would never match")]
1161#[help("try using the `is_nan` method instead")]
1162pub(crate) struct NaNPattern {
1163#[primary_span]
1164 #[label("evaluates to `NaN`, which is not allowed in patterns")]
1165pub(crate) span: Span,
1166}
11671168#[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)]
1169#[diag(
1170"function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon"
1171)]
1172#[note("see https://github.com/rust-lang/rust/issues/70861 for details")]
1173pub(crate) struct PointerPattern {
1174#[primary_span]
1175 #[label("can't be used in patterns")]
1176pub(crate) span: Span,
1177}
11781179#[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)]
1180#[diag("mismatched types")]
1181#[note("the matched value is of type `{$ty}`")]
1182pub(crate) struct NonEmptyNeverPattern<'tcx> {
1183#[primary_span]
1184 #[label("a never pattern must be used on an uninhabited type")]
1185pub(crate) span: Span,
1186pub(crate) ty: Ty<'tcx>,
1187}
11881189#[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)]
1190#[diag("refutable pattern in {$origin}", code = E0005)]
1191pub(crate) struct PatternNotCovered<'s, 'tcx> {
1192#[primary_span]
1193pub(crate) span: Span,
1194pub(crate) origin: &'s str,
1195#[subdiagnostic]
1196pub(crate) uncovered: Uncovered,
1197#[subdiagnostic]
1198pub(crate) inform: Option<Inform>,
1199#[subdiagnostic]
1200pub(crate) interpreted_as_const: Option<InterpretedAsConst>,
1201#[subdiagnostic]
1202pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConstSugg>,
1203#[subdiagnostic]
1204pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
1205#[note(
1206"pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future"
1207)]
1208pub(crate) witness_1_is_privately_uninhabited: bool,
1209pub(crate) witness_1: String,
1210#[note("the matched value is of type `{$pattern_ty}`")]
1211pub(crate) _p: (),
1212pub(crate) pattern_ty: Ty<'tcx>,
1213#[subdiagnostic]
1214pub(crate) let_suggestion: Option<SuggestLet>,
1215#[subdiagnostic]
1216pub(crate) misc_suggestion: Option<MiscPatternSuggestion>,
1217}
12181219#[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)]
1220#[note(
1221"`let` bindings require an \"irrefutable pattern\", like a `struct` or an `enum` with only one variant"
1222)]
1223#[note("for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html")]
1224pub(crate) struct Inform;
12251226#[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)]
1227#[label(
1228"missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable"
1229)]
1230pub(crate) struct InterpretedAsConst {
1231#[primary_span]
1232pub(crate) span: Span,
1233pub(crate) variable: String,
1234}
12351236pub(crate) struct AdtDefinedHere<'tcx> {
1237pub(crate) adt_def_span: Span,
1238pub(crate) ty: Ty<'tcx>,
1239pub(crate) variants: Vec<Variant>,
1240}
12411242pub(crate) struct Variant {
1243pub(crate) span: Span,
1244}
12451246impl<'tcx> Subdiagnosticfor AdtDefinedHere<'tcx> {
1247fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1248diag.arg("ty", self.ty);
1249let mut spans = MultiSpan::from(self.adt_def_span);
12501251for Variant { span } in self.variants {
1252 spans.push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not covered"))msg!("not covered"));
1253 }
12541255diag.span_note(spans, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` defined here"))msg!("`{$ty}` defined here"));
1256 }
1257}
12581259#[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)]
1260#[suggestion(
1261"introduce a variable instead",
1262 code = "{variable}_var",
1263 applicability = "maybe-incorrect",
1264 style = "verbose"
1265)]
1266pub(crate) struct InterpretedAsConstSugg {
1267#[primary_span]
1268pub(crate) span: Span,
1269pub(crate) variable: String,
1270}
12711272#[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)]
1273pub(crate) enum SuggestLet {
1274#[multipart_suggestion(
1275"you might want to use `if let` to ignore the {$count ->
1276 [one] variant that isn't
1277 *[other] variants that aren't
1278 } matched",
1279 applicability = "has-placeholders"
1280)]
1281If {
1282#[suggestion_part(code = "if ")]
1283start_span: Span,
1284#[suggestion_part(code = " {{ todo!() }}")]
1285semi_span: Span,
1286 count: usize,
1287 },
1288#[suggestion(
1289"you might want to use `let...else` to handle the {$count ->
1290 [one] variant that isn't
1291 *[other] variants that aren't
1292 } matched",
1293 code = " else {{ todo!() }}",
1294 applicability = "has-placeholders"
1295)]
1296Else {
1297#[primary_span]
1298end_span: Span,
1299 count: usize,
1300 },
1301}
13021303#[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)]
1304pub(crate) enum MiscPatternSuggestion {
1305#[suggestion(
1306"alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits",
1307 code = "_",
1308 applicability = "maybe-incorrect"
1309)]
1310AttemptedIntegerLiteral {
1311#[primary_span]
1312start_span: Span,
1313 },
1314}
13151316#[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)]
1317#[diag("invalid update of the `#[loop_match]` state")]
1318pub(crate) struct LoopMatchInvalidUpdate {
1319#[primary_span]
1320pub lhs: Span,
1321#[label("the assignment must update this variable")]
1322pub scrutinee: Span,
1323}
13241325#[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)]
1326#[diag("invalid match on `#[loop_match]` state")]
1327#[note("a local variable must be the scrutinee within a `#[loop_match]`")]
1328pub(crate) struct LoopMatchInvalidMatch {
1329#[primary_span]
1330pub span: Span,
1331}
13321333#[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)]
1334#[diag("this `#[loop_match]` state value has type `{$ty}`, which is not supported")]
1335#[note("only integers, floats, bool, char, and enums without fields are supported")]
1336pub(crate) struct LoopMatchUnsupportedType<'tcx> {
1337#[primary_span]
1338pub span: Span,
1339pub ty: Ty<'tcx>,
1340}
13411342#[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)]
1343#[diag("statements are not allowed in this position within a `#[loop_match]`")]
1344pub(crate) struct LoopMatchBadStatements {
1345#[primary_span]
1346pub span: Span,
1347}
13481349#[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)]
1350#[diag("this expression must be a single `match` wrapped in a labeled block")]
1351pub(crate) struct LoopMatchBadRhs {
1352#[primary_span]
1353pub span: Span,
1354}
13551356#[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)]
1357#[diag("expected a single assignment expression")]
1358pub(crate) struct LoopMatchMissingAssignment {
1359#[primary_span]
1360pub span: Span,
1361}
13621363#[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)]
1364#[diag("match arms that are part of a `#[loop_match]` cannot have guards")]
1365pub(crate) struct LoopMatchArmWithGuard {
1366#[primary_span]
1367pub span: Span,
1368}
13691370#[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)]
1371#[diag("could not determine the target branch for this `#[const_continue]`")]
1372#[help("try extracting the expression into a `const` item")]
1373pub(crate) struct ConstContinueNotMonomorphicConst {
1374#[primary_span]
1375pub span: Span,
13761377#[subdiagnostic]
1378pub reason: ConstContinueNotMonomorphicConstReason,
1379}
13801381#[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)]
1382pub(crate) enum ConstContinueNotMonomorphicConstReason {
1383#[label("constant parameters may use generics, and are not evaluated early enough")]
1384ConstantParameter {
1385#[primary_span]
1386span: Span,
1387 },
13881389#[label("`const` blocks may use generics, and are not evaluated early enough")]
1390ConstBlock {
1391#[primary_span]
1392span: Span,
1393 },
13941395#[label("this value must be a literal or a monomorphic const")]
1396Other {
1397#[primary_span]
1398span: Span,
1399 },
1400}
14011402#[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)]
1403#[diag("could not determine the target branch for this `#[const_continue]`")]
1404pub(crate) struct ConstContinueBadConst {
1405#[primary_span]
1406 #[label("this value is too generic")]
1407pub span: Span,
1408}
14091410#[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)]
1411#[diag("a `#[const_continue]` must break to a label with a value")]
1412pub(crate) struct ConstContinueMissingLabelOrValue {
1413#[primary_span]
1414pub span: Span,
1415}
14161417#[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)]
1418#[diag("the target of this `#[const_continue]` is not statically known")]
1419pub(crate) struct ConstContinueUnknownJumpTarget {
1420#[primary_span]
1421pub span: Span,
1422}