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
UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe 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 {
UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
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 `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing a layout restricted type's field with a value outside the valid range is undefined behavior")));
;
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing type with `rustc_layout_scalar_valid_range` attr")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
70#[diag("initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe block", code = E0133)]
71#[note(
72"initializing a layout restricted type's field with a value outside the valid range is undefined behavior"
73)]
74pub(crate) struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
75#[label("initializing type with `rustc_layout_scalar_valid_range` attr")]
76pub(crate) span: Span,
77#[subdiagnostic]
78pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
79}
8081#[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)]
82#[diag("initializing type with an unsafe field is unsafe and requires unsafe block", code = E0133)]
83#[note("unsafe fields may carry library invariants")]
84pub(crate) struct UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsafe {
85#[label("initialization of struct with unsafe field")]
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
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)]
92#[diag("use of mutable static is unsafe and requires unsafe block", code = E0133)]
93#[note(
94"mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior"
95)]
96pub(crate) struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
97#[label("use of mutable 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
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)]
104#[diag("use of extern static is unsafe and requires unsafe block", code = E0133)]
105#[note(
106"extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior"
107)]
108pub(crate) struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
109#[label("use of extern static")]
110pub(crate) span: Span,
111#[subdiagnostic]
112pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
113}
114115#[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)]
116#[diag("use of unsafe field is unsafe and requires unsafe block", code = E0133)]
117#[note("unsafe fields may carry library invariants")]
118pub(crate) struct UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe {
119#[label("use of unsafe field")]
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
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)]
126#[diag("dereference of raw pointer is unsafe and requires unsafe block", code = E0133)]
127#[note(
128"raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior"
129)]
130pub(crate) struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
131#[label("dereference of raw pointer")]
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
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)]
138#[diag("access to union field is unsafe and requires unsafe block", code = E0133)]
139#[note(
140"the field may not be properly initialized: using uninitialized data will cause undefined behavior"
141)]
142pub(crate) struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
143#[label("access to union field")]
144pub(crate) span: Span,
145#[subdiagnostic]
146pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
147}
148149#[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)]
150#[diag(
151"mutation of layout constrained field is unsafe and requires unsafe block",
152 code = E0133
153)]
154#[note("mutating layout constrained fields cannot statically be checked for valid values")]
155pub(crate) struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
156#[label("mutation of layout constrained field")]
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
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)]
163#[diag(
164"borrow of layout constrained field with interior mutability is unsafe and requires unsafe block",
165 code = E0133,
166)]
167pub(crate) struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
168#[label("borrow of layout constrained field with interior mutability")]
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
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)]
175#[diag(
176"unsafe binder cast is unsafe and requires unsafe block information that may be required to uphold safety guarantees of a type",
177 code = E0133,
178)]
179pub(crate) struct UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe {
180#[label("unsafe binder cast")]
181pub(crate) span: Span,
182#[subdiagnostic]
183pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
184}
185186#[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)]
187#[diag("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block", code = E0133)]
188#[help(
189"in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
190 [1] feature
191 *[count] features
192 }: {$missing_target_features}"
193)]
194pub(crate) struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
195#[label("call to function with `#[target_feature]`")]
196pub(crate) span: Span,
197pub(crate) function: String,
198pub(crate) missing_target_features: DiagArgValue,
199pub(crate) missing_target_features_count: usize,
200#[note("the {$build_target_features} target {$build_target_features_count ->
201 [1] feature
202 *[count] features
203 } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->
204 [1] it
205 *[count] them
206 } in `#[target_feature]`")]
207pub(crate) note: bool,
208pub(crate) build_target_features: DiagArgValue,
209pub(crate) build_target_features_count: usize,
210#[subdiagnostic]
211pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
212}
213214#[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)]
215#[diag("call to unsafe function `{$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 CallToUnsafeFunctionRequiresUnsafe {
218#[primary_span]
219 #[label("call to unsafe function")]
220pub(crate) span: Span,
221pub(crate) function: String,
222#[subdiagnostic]
223pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
224}
225226#[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)]
227#[diag("call to unsafe function is unsafe and requires unsafe block", code = E0133)]
228#[note("consult the function's documentation for information on how to avoid undefined behavior")]
229pub(crate) struct CallToUnsafeFunctionRequiresUnsafeNameless {
230#[primary_span]
231 #[label("call to unsafe function")]
232pub(crate) span: Span,
233#[subdiagnostic]
234pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
235}
236237#[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)]
238#[diag("call to unsafe function `{$function}` is unsafe and requires unsafe function or block", code = E0133)]
239#[note("consult the function's documentation for information on how to avoid undefined behavior")]
240pub(crate) struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
241#[primary_span]
242 #[label("call to unsafe function")]
243pub(crate) span: Span,
244pub(crate) function: String,
245#[subdiagnostic]
246pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
247}
248249#[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)]
250#[diag(
251"call to unsafe function is unsafe and requires unsafe function or block",
252 code = E0133
253)]
254#[note("consult the function's documentation for information on how to avoid undefined behavior")]
255pub(crate) struct CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
256#[primary_span]
257 #[label("call to unsafe function")]
258pub(crate) span: Span,
259#[subdiagnostic]
260pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
261}
262263#[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)]
264#[diag("use of inline assembly is unsafe and requires unsafe block", code = E0133)]
265#[note("inline assembly is entirely unchecked and can cause undefined behavior")]
266pub(crate) struct UseOfInlineAssemblyRequiresUnsafe {
267#[primary_span]
268 #[label("use of inline assembly")]
269pub(crate) span: Span,
270#[subdiagnostic]
271pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
272}
273274#[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)]
275#[diag("use of inline assembly is unsafe and requires unsafe function or block", code = E0133)]
276#[note("inline assembly is entirely unchecked and can cause undefined behavior")]
277pub(crate) struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
278#[primary_span]
279 #[label("use of inline assembly")]
280pub(crate) span: Span,
281#[subdiagnostic]
282pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
283}
284285#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InitializingTypeWithRequiresUnsafe 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 {
InitializingTypeWithRequiresUnsafe {
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 `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing a layout restricted type's field with a value outside the valid range is undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing type with `rustc_layout_scalar_valid_range` attr")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
286#[diag("initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe block", code = E0133)]
287#[note(
288"initializing a layout restricted type's field with a value outside the valid range is undefined behavior"
289)]
290pub(crate) struct InitializingTypeWithRequiresUnsafe {
291#[primary_span]
292 #[label("initializing type with `rustc_layout_scalar_valid_range` attr")]
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
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)]
299#[diag("initializing type with an unsafe field is unsafe and requires unsafe block", code = E0133)]
300#[note("unsafe fields may carry library invariants")]
301pub(crate) struct InitializingTypeWithUnsafeFieldRequiresUnsafe {
302#[primary_span]
303 #[label("initialization of struct with unsafe field")]
304pub(crate) span: Span,
305#[subdiagnostic]
306pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
307}
308309#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed 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 {
InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
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 `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe function or block")));
diag.code(E0133);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing a layout restricted type's field with a value outside the valid range is undefined behavior")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("initializing type with `rustc_layout_scalar_valid_range` attr")));
if let Some(__binding_1) = __binding_1 {
diag.subdiagnostic(__binding_1);
}
diag
}
}
}
}
};Diagnostic)]
310#[diag(
311"initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe function or block",
312 code = E0133
313)]
314#[note(
315"initializing a layout restricted type's field with a value outside the valid range is undefined behavior"
316)]
317pub(crate) struct InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
318#[primary_span]
319 #[label("initializing type with `rustc_layout_scalar_valid_range` attr")]
320pub(crate) span: Span,
321#[subdiagnostic]
322pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
323}
324325#[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)]
326#[diag(
327"initializing type with an unsafe field is unsafe and requires unsafe block",
328 code = E0133
329)]
330#[note("unsafe fields may carry library invariants")]
331pub(crate) struct InitializingTypeWithUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
332#[primary_span]
333 #[label("initialization of struct with unsafe field")]
334pub(crate) span: Span,
335#[subdiagnostic]
336pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
337}
338339#[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)]
340#[diag("use of mutable static is unsafe and requires unsafe block", code = E0133)]
341#[note(
342"mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior"
343)]
344pub(crate) struct UseOfMutableStaticRequiresUnsafe {
345#[primary_span]
346 #[label("use of mutable static")]
347pub(crate) span: Span,
348#[subdiagnostic]
349pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
350}
351352#[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)]
353#[diag("use of mutable static is unsafe and requires unsafe function or block", code = E0133)]
354#[note(
355"mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior"
356)]
357pub(crate) struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
358#[primary_span]
359 #[label("use of mutable static")]
360pub(crate) span: Span,
361#[subdiagnostic]
362pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
363}
364365#[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)]
366#[diag("use of extern static is unsafe and requires unsafe block", code = E0133)]
367#[note(
368"extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior"
369)]
370pub(crate) struct UseOfExternStaticRequiresUnsafe {
371#[primary_span]
372 #[label("use of extern static")]
373pub(crate) span: Span,
374#[subdiagnostic]
375pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
376}
377378#[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)]
379#[diag("use of extern static is unsafe and requires unsafe function or block", code = E0133)]
380#[note(
381"extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior"
382)]
383pub(crate) struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
384#[primary_span]
385 #[label("use of extern static")]
386pub(crate) span: Span,
387#[subdiagnostic]
388pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
389}
390391#[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)]
392#[diag("use of unsafe field is unsafe and requires unsafe block", code = E0133)]
393#[note("unsafe fields may carry library invariants")]
394pub(crate) struct UseOfUnsafeFieldRequiresUnsafe {
395#[primary_span]
396 #[label("use of unsafe field")]
397pub(crate) span: Span,
398#[subdiagnostic]
399pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
400}
401402#[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)]
403#[diag("use of unsafe field is unsafe and requires unsafe block", code = E0133)]
404#[note("unsafe fields may carry library invariants")]
405pub(crate) struct UseOfUnsafeFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
406#[primary_span]
407 #[label("use of unsafe field")]
408pub(crate) span: Span,
409#[subdiagnostic]
410pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
411}
412413#[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)]
414#[diag("dereference of raw pointer is unsafe and requires unsafe block", code = E0133)]
415#[note(
416"raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior"
417)]
418pub(crate) struct DerefOfRawPointerRequiresUnsafe {
419#[primary_span]
420 #[label("dereference of raw pointer")]
421pub(crate) span: Span,
422#[subdiagnostic]
423pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
424}
425426#[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)]
427#[diag("dereference of raw pointer is unsafe and requires unsafe function or block", code = E0133)]
428#[note(
429"raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior"
430)]
431pub(crate) struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
432#[primary_span]
433 #[label("dereference of raw pointer")]
434pub(crate) span: Span,
435#[subdiagnostic]
436pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
437}
438439#[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)]
440#[diag("access to union field is unsafe and requires unsafe block", code = E0133)]
441#[note(
442"the field may not be properly initialized: using uninitialized data will cause undefined behavior"
443)]
444pub(crate) struct AccessToUnionFieldRequiresUnsafe {
445#[primary_span]
446 #[label("access to union field")]
447pub(crate) span: Span,
448#[subdiagnostic]
449pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
450}
451452#[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)]
453#[diag("access to union field is unsafe and requires unsafe function or block", code = E0133)]
454#[note(
455"the field may not be properly initialized: using uninitialized data will cause undefined behavior"
456)]
457pub(crate) struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
458#[primary_span]
459 #[label("access to union field")]
460pub(crate) span: Span,
461#[subdiagnostic]
462pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
463}
464465#[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)]
466#[diag("mutation of layout constrained field is unsafe and requires unsafe block", code = E0133)]
467#[note("mutating layout constrained fields cannot statically be checked for valid values")]
468pub(crate) struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
469#[primary_span]
470 #[label("mutation of layout constrained field")]
471pub(crate) span: Span,
472#[subdiagnostic]
473pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
474}
475476#[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)]
477#[diag(
478"mutation of layout constrained field is unsafe and requires unsafe function or block",
479 code = E0133
480)]
481#[note("mutating layout constrained fields cannot statically be checked for valid values")]
482pub(crate) struct MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
483#[primary_span]
484 #[label("mutation of layout constrained field")]
485pub(crate) span: Span,
486#[subdiagnostic]
487pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
488}
489490#[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)]
491#[diag("borrow of layout constrained field with interior mutability is unsafe and requires unsafe block", code = E0133)]
492#[note(
493"references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values"
494)]
495pub(crate) struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
496#[primary_span]
497 #[label("borrow of layout constrained field with interior mutability")]
498pub(crate) span: Span,
499#[subdiagnostic]
500pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
501}
502503#[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)]
504#[diag(
505"borrow of layout constrained field with interior mutability is unsafe and requires unsafe function or block",
506 code = E0133
507)]
508#[note(
509"references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values"
510)]
511pub(crate) struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
512#[primary_span]
513 #[label("borrow of layout constrained field with interior mutability")]
514pub(crate) span: Span,
515#[subdiagnostic]
516pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
517}
518519#[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)]
520#[diag("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block", code = E0133)]
521#[help(
522"in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
523 [1] feature
524 *[count] features
525}: {$missing_target_features}"
526)]
527pub(crate) struct CallToFunctionWithRequiresUnsafe {
528#[primary_span]
529 #[label("call to function with `#[target_feature]`")]
530pub(crate) span: Span,
531pub(crate) function: String,
532pub(crate) missing_target_features: DiagArgValue,
533pub(crate) missing_target_features_count: usize,
534#[note("the {$build_target_features} target {$build_target_features_count ->
535 [1] feature
536 *[count] features
537 } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->
538 [1] it
539 *[count] them
540 } in `#[target_feature]`")]
541pub(crate) note: bool,
542pub(crate) build_target_features: DiagArgValue,
543pub(crate) build_target_features_count: usize,
544#[subdiagnostic]
545pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
546}
547548#[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)]
549#[diag(
550"call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe function or block",
551 code = E0133,
552)]
553#[help(
554"in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
555 [1] feature
556 *[count] features
557}: {$missing_target_features}"
558)]
559pub(crate) struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
560#[primary_span]
561 #[label("call to function with `#[target_feature]`")]
562pub(crate) span: Span,
563pub(crate) function: String,
564pub(crate) missing_target_features: DiagArgValue,
565pub(crate) missing_target_features_count: usize,
566#[note("the {$build_target_features} target {$build_target_features_count ->
567 [1] feature
568 *[count] features
569 } being enabled in the build configuration does not remove the requirement to list {$build_target_features_count ->
570 [1] it
571 *[count] them
572 } in `#[target_feature]`")]
573pub(crate) note: bool,
574pub(crate) build_target_features: DiagArgValue,
575pub(crate) build_target_features_count: usize,
576#[subdiagnostic]
577pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
578}
579580#[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)]
581#[diag(
582"unsafe binder cast is unsafe and requires unsafe block information that may be required to uphold safety guarantees of a type",
583 code = E0133,
584)]
585pub(crate) struct UnsafeBinderCastRequiresUnsafe {
586#[primary_span]
587 #[label("unsafe binder cast")]
588pub(crate) span: Span,
589#[subdiagnostic]
590pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
591}
592593#[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)]
594#[diag(
595"unsafe binder cast is unsafe and requires unsafe block or unsafe fn information that may be required to uphold safety guarantees of a type",
596 code = E0133,
597)]
598pub(crate) struct UnsafeBinderCastRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
599#[primary_span]
600 #[label("unsafe binder cast")]
601pub(crate) span: Span,
602#[subdiagnostic]
603pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
604}
605606#[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)]
607#[label("items do not inherit unsafety from separate enclosing items")]
608pub(crate) struct UnsafeNotInheritedNote {
609#[primary_span]
610pub(crate) span: Span,
611}
612613pub(crate) struct UnsafeNotInheritedLintNote {
614pub(crate) signature_span: Span,
615pub(crate) body_span: Span,
616}
617618impl Subdiagnosticfor UnsafeNotInheritedLintNote {
619fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
620diag.span_note(
621self.signature_span,
622rustc_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"),
623 );
624let body_start = self.body_span.shrink_to_lo();
625let body_end = self.body_span.shrink_to_hi();
626diag.tool_only_multipart_suggestion(
627rustc_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"),
628::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())],
629 Applicability::MachineApplicable,
630 );
631 }
632}
633634#[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)]
635#[diag("unnecessary `unsafe` block")]
636pub(crate) struct UnusedUnsafe {
637#[label("unnecessary `unsafe` block")]
638pub(crate) span: Span,
639#[subdiagnostic]
640pub(crate) enclosing: Option<UnusedUnsafeEnclosing>,
641}
642643#[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)]
644pub(crate) enum UnusedUnsafeEnclosing {
645#[label("because it's nested under this `unsafe` block")]
646Block {
647#[primary_span]
648span: Span,
649 },
650}
651652pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
653pub(crate) cx: &'m RustcPatCtxt<'p, 'tcx>,
654pub(crate) scrut_span: Span,
655pub(crate) braces_span: Option<Span>,
656pub(crate) ty: Ty<'tcx>,
657}
658659impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
660fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
661let mut diag =
662Diag::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"));
663diag.span(self.scrut_span);
664diag.code(E0004);
665let peeled_ty = self.ty.peel_refs();
666diag.arg("ty", self.ty);
667diag.arg("peeled_ty", peeled_ty);
668669if let ty::Adt(def, _) = peeled_ty.kind() {
670let def_span = self671 .cx
672 .tcx
673 .hir_get_if_local(def.did())
674 .and_then(|node| node.ident())
675 .map(|ident| ident.span)
676 .unwrap_or_else(|| self.cx.tcx.def_span(def.did()));
677678// workaround to make test pass
679let mut span: MultiSpan = def_span.into();
680span.push_span_label(def_span, "");
681682diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$peeled_ty}` defined here"))msg!("`{$peeled_ty}` defined here"));
683 }
684685let 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(),
686 ty::Adt(def, _) if def.variant_list_has_applicable_non_exhaustive());
687if is_non_exhaustive {
688diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`, which is marked as non-exhaustive"))msg!(
689"the matched value is of type `{$ty}`, which is marked as non-exhaustive"
690));
691 } else {
692diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`"))msg!("the matched value is of type `{$ty}`"));
693 }
694695if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
696if !sub_ty.is_inhabited_from(self.cx.tcx, self.cx.module, self.cx.typing_env) {
697diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are always considered inhabited"))msg!("references are always considered inhabited"));
698 }
699 }
700701let sm = self.cx.tcx.sess.source_map();
702if let Some(braces_span) = self.braces_span {
703// Get the span for the empty match body `{}`.
704let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.scrut_span)
705 {
706 (::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\n{0}", snippet))
})format!("\n{snippet}"), " ")
707 } else {
708 (" ".to_string(), "")
709 };
710diag.span_suggestion_verbose(
711braces_span,
712rustc_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"),
713::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{{0}{1}_ => todo!(),{0}}}",
indentation, more))
})format!(" {{{indentation}{more}_ => todo!(),{indentation}}}"),
714 Applicability::HasPlaceholders,
715 );
716 } else {
717diag.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!(
718"ensure that all possible cases are being handled by adding a match arm with a wildcard pattern"
719));
720 }
721722diag723 }
724}
725726#[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)]
727#[note("match arms with guards don't count towards exhaustivity")]
728pub(crate) struct NonExhaustiveMatchAllArmsGuarded;
729730#[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)]
731#[diag("statics cannot be referenced in patterns", code = E0158)]
732pub(crate) struct StaticInPattern {
733#[primary_span]
734 #[label("can't be used in patterns")]
735pub(crate) span: Span,
736#[label("`static` defined here")]
737pub(crate) static_span: Span,
738}
739740#[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)]
741#[diag("constant parameters cannot be referenced in patterns", code = E0158)]
742pub(crate) struct ConstParamInPattern {
743#[primary_span]
744 #[label("can't be used in patterns")]
745pub(crate) span: Span,
746#[label("constant defined here")]
747pub(crate) const_span: Span,
748}
749750#[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)]
751#[diag("runtime values cannot be referenced in patterns", code = E0080)]
752pub(crate) struct NonConstPath {
753#[primary_span]
754 #[label("references a runtime value")]
755pub(crate) span: Span,
756}
757758#[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)]
759#[diag("unreachable pattern")]
760pub(crate) struct UnreachablePattern<'tcx> {
761#[label("no value can reach this")]
762pub(crate) span: Option<Span>,
763#[label("matches no values because `{$matches_no_values_ty}` is uninhabited")]
764pub(crate) matches_no_values: Option<Span>,
765pub(crate) matches_no_values_ty: Ty<'tcx>,
766#[note(
767"to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types"
768)]
769pub(crate) uninhabited_note: Option<()>,
770#[label("matches any value")]
771pub(crate) covered_by_catchall: Option<Span>,
772#[subdiagnostic]
773pub(crate) wanted_constant: Option<WantedConstant>,
774#[note(
775"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"
776)]
777pub(crate) accessible_constant: Option<Span>,
778#[note(
779"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"
780)]
781pub(crate) inaccessible_constant: Option<Span>,
782#[note(
783"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"
784)]
785pub(crate) pattern_let_binding: Option<Span>,
786#[label("matches all the relevant values")]
787pub(crate) covered_by_one: Option<Span>,
788#[note("multiple earlier patterns match some of the same values")]
789pub(crate) covered_by_many: Option<MultiSpan>,
790pub(crate) covered_by_many_n_more_count: usize,
791#[suggestion("remove the match arm", code = "", applicability = "machine-applicable")]
792pub(crate) suggest_remove: Option<Span>,
793}
794795#[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)]
796#[suggestion(
797"you might have meant to pattern match against the value of {$is_typo ->
798 [true] similarly named constant
799 *[false] constant
800 } `{$const_name}` instead of introducing a new catch-all binding",
801 code = "{const_path}",
802 applicability = "machine-applicable"
803)]
804pub(crate) struct WantedConstant {
805#[primary_span]
806pub(crate) span: Span,
807pub(crate) is_typo: bool,
808pub(crate) const_name: String,
809pub(crate) const_path: String,
810}
811812#[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)]
813#[diag("unreachable {$descr}")]
814pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
815pub descr: &'desc str,
816#[label("unreachable {$descr}")]
817pub expr: Span,
818#[label("any code following this expression is unreachable")]
819 #[note("this expression has type `{$ty}`, which is uninhabited")]
820pub orig: Span,
821pub ty: Ty<'tcx>,
822}
823824#[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)]
825#[diag("constant pattern cannot depend on generic parameters", code = E0158)]
826pub(crate) struct ConstPatternDependsOnGenericParameter {
827#[primary_span]
828 #[label("`const` depends on a generic parameter")]
829pub(crate) span: Span,
830}
831832#[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)]
833#[diag("could not evaluate constant pattern")]
834pub(crate) struct CouldNotEvalConstPattern {
835#[primary_span]
836 #[label("could not evaluate constant")]
837pub(crate) span: Span,
838}
839840#[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)]
841#[diag("lower bound for range pattern must be less than or equal to upper bound", code = E0030)]
842pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
843#[primary_span]
844 #[label("lower bound larger than upper bound")]
845pub(crate) span: Span,
846#[note(
847"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"
848)]
849pub(crate) teach: bool,
850}
851852#[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)]
853#[diag("literal out of range for `{$ty}`")]
854pub(crate) struct LiteralOutOfRange<'tcx> {
855#[primary_span]
856 #[label("this value does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
857pub(crate) span: Span,
858pub(crate) ty: Ty<'tcx>,
859pub(crate) min: i128,
860pub(crate) max: u128,
861}
862863#[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)]
864#[diag("lower bound for range pattern must be less than upper bound", code = E0579)]
865pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
866#[primary_span]
867pub(crate) span: Span,
868}
869870#[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)]
871#[diag("exclusive upper bound for a range bound cannot be the minimum", code = E0579)]
872pub(crate) struct UpperRangeBoundCannotBeMin {
873#[primary_span]
874pub(crate) span: Span,
875}
876877#[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)]
878#[diag("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`", code = E0170)]
879pub(crate) struct BindingsWithVariantName {
880#[suggestion(
881"to match on the variant, qualify the path",
882 code = "{ty_path}::{name}",
883 applicability = "machine-applicable"
884)]
885pub(crate) suggestion: Option<Span>,
886pub(crate) ty_path: String,
887pub(crate) name: Ident,
888}
889890#[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)]
891#[diag(
892"irrefutable `if let` {$count ->
893 [one] pattern
894 *[other] patterns
895}"
896)]
897#[note(
898"{$count ->
899 [one] this pattern
900 *[other] these patterns
901} will always match, so the `if let` is useless"
902)]
903#[help("consider replacing the `if let` with a `let`")]
904pub(crate) struct IrrefutableLetPatternsIfLet {
905pub(crate) count: usize,
906}
907908#[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)]
909#[diag(
910"irrefutable `if let` guard {$count ->
911 [one] pattern
912 *[other] patterns
913}"
914)]
915#[note(
916"{$count ->
917 [one] this pattern
918 *[other] these patterns
919} will always match, so the guard is useless"
920)]
921#[help("consider removing the guard and adding a `let` inside the match arm")]
922pub(crate) struct IrrefutableLetPatternsIfLetGuard {
923pub(crate) count: usize,
924}
925926#[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 {
count: __binding_0, else_span: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("irrefutable `let...else` {$count ->\n [one] pattern\n *[other] patterns\n}")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$count ->\n [one] this pattern always matches, so the else clause is unreachable\n *[other] these patterns always match, so the else clause is unreachable\n}")));
;
diag.arg("count", __binding_0);
if let Some(__binding_1) = __binding_1 {
diag.span_help(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this `else` block")));
}
diag
}
}
}
}
};Diagnostic)]
927#[diag(
928"irrefutable `let...else` {$count ->
929 [one] pattern
930 *[other] patterns
931}"
932)]
933#[note(
934"{$count ->
935 [one] this pattern always matches, so the else clause is unreachable
936 *[other] these patterns always match, so the else clause is unreachable
937}"
938)]
939pub(crate) struct IrrefutableLetPatternsLetElse {
940pub(crate) count: usize,
941#[help("remove this `else` block")]
942pub(crate) else_span: Option<Span>,
943}
944945#[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)]
946#[diag(
947"irrefutable `while let` {$count ->
948 [one] pattern
949 *[other] patterns
950}"
951)]
952#[note(
953"{$count ->
954 [one] this pattern
955 *[other] these patterns
956} will always match, so the loop will never exit"
957)]
958#[help("consider instead using a `loop {\"{\"} ... {\"}\"}` with a `let` inside it")]
959pub(crate) struct IrrefutableLetPatternsWhileLet {
960pub(crate) count: usize,
961}
962963#[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_6 =
[::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_6, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
diag
}
}
}
}
};Diagnostic)]
964#[diag("borrow of moved value")]
965pub(crate) struct BorrowOfMovedValue<'tcx> {
966#[primary_span]
967 #[label("value moved into `{$name}` here")]
968 #[label(
969"move occurs because `{$name}` has type `{$ty}`, which does not implement the `Copy` trait"
970)]
971pub(crate) binding_span: Span,
972#[label("value borrowed here after move")]
973pub(crate) conflicts_ref: Vec<Span>,
974pub(crate) name: Ident,
975pub(crate) ty: Ty<'tcx>,
976#[suggestion(
977"borrow this binding in the pattern to avoid moving the value",
978 code = "ref ",
979 applicability = "machine-applicable"
980)]
981pub(crate) suggest_borrowing: Option<Span>,
982}
983984#[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)]
985#[diag("cannot borrow value as mutable more than once at a time")]
986pub(crate) struct MultipleMutBorrows {
987#[primary_span]
988pub(crate) span: Span,
989#[subdiagnostic]
990pub(crate) occurrences: Vec<Conflict>,
991}
992993#[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)]
994#[diag("cannot borrow value as mutable because it is also borrowed as immutable")]
995pub(crate) struct AlreadyBorrowed {
996#[primary_span]
997pub(crate) span: Span,
998#[subdiagnostic]
999pub(crate) occurrences: Vec<Conflict>,
1000}
10011002#[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)]
1003#[diag("cannot borrow value as immutable because it is also borrowed as mutable")]
1004pub(crate) struct AlreadyMutBorrowed {
1005#[primary_span]
1006pub(crate) span: Span,
1007#[subdiagnostic]
1008pub(crate) occurrences: Vec<Conflict>,
1009}
10101011#[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)]
1012#[diag("cannot move out of value because it is borrowed")]
1013pub(crate) struct MovedWhileBorrowed {
1014#[primary_span]
1015pub(crate) span: Span,
1016#[subdiagnostic]
1017pub(crate) occurrences: Vec<Conflict>,
1018}
10191020#[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)]
1021pub(crate) enum Conflict {
1022#[label("value is mutably borrowed by `{$name}` here")]
1023Mut {
1024#[primary_span]
1025span: Span,
1026 name: Symbol,
1027 },
1028#[label("value is borrowed by `{$name}` here")]
1029Ref {
1030#[primary_span]
1031span: Span,
1032 name: Symbol,
1033 },
1034#[label("value is moved into `{$name}` here")]
1035Moved {
1036#[primary_span]
1037span: Span,
1038 name: Symbol,
1039 },
1040}
10411042#[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)]
1043#[diag("cannot use unions in constant patterns")]
1044pub(crate) struct UnionPattern {
1045#[primary_span]
1046 #[label("can't use a `union` here")]
1047pub(crate) span: Span,
1048}
10491050#[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)]
1051#[diag("constant of non-structural type `{$ty}` in a pattern")]
1052pub(crate) struct TypeNotStructural<'tcx> {
1053#[primary_span]
1054 #[label("constant of non-structural type")]
1055pub(crate) span: Span,
1056#[label(
1057"{$is_local ->
1058 *[true] `{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
1059 [false] `{$ty}` is not usable in patterns
1060 }"
1061)]
1062pub(crate) ty_def_span: Span,
1063pub(crate) ty: Ty<'tcx>,
1064#[note(
1065"the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see \
1066 https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1067)]
1068pub(crate) manual_partialeq_impl_span: Option<Span>,
1069#[note(
1070"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1071)]
1072pub(crate) manual_partialeq_impl_note: bool,
1073#[subdiagnostic]
1074pub(crate) suggestion: Option<SuggestEq<'tcx>>,
1075pub(crate) is_local: bool,
1076}
10771078#[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_7 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("binding"))
});
let __code_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" if binding == {0}",
__binding_2))
});
suggestions.push((__binding_0, __code_7));
suggestions.push((__binding_1, __code_8));
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_9 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("binding"))
});
let __code_10 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" && binding == {0}",
__binding_2))
});
suggestions.push((__binding_0, __code_9));
suggestions.push((__binding_1, __code_10));
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_11 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("binding"))
});
let __code_12 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" && binding == {0}",
__binding_2))
});
suggestions.push((__binding_0, __code_11));
suggestions.push((__binding_1, __code_12));
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_13 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(""))
});
let __code_14 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" == "))
});
suggestions.push((__binding_0, __code_13));
suggestions.push((__binding_1, __code_14));
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_15 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
});
let __code_16 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" == "))
});
let __code_17 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" "))
});
suggestions.push((__binding_0, __code_15));
suggestions.push((__binding_1, __code_16));
suggestions.push((__binding_2, __code_17));
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)]
1079pub(crate) enum SuggestEq<'tcx> {
1080#[multipart_suggestion(
1081"{$manual_partialeq_impl ->
1082 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1083 *[true] add
1084 } a condition to the match arm checking for equality",
1085 applicability = "maybe-incorrect",
1086 style = "verbose"
1087)]
1088AddIf {
1089#[suggestion_part(code = "binding")]
1090pat_span: Span,
1091#[suggestion_part(code = " if binding == {name}")]
1092if_span: Span,
1093 name: String,
1094 ty: Ty<'tcx>,
1095 manual_partialeq_impl: bool,
1096 },
1097#[multipart_suggestion(
1098"{$manual_partialeq_impl ->
1099 [false] if `{$ty}` manually implemented `PartialEq`, you could add
1100 *[true] add
1101 } a check for equality to the condition of the match arm",
1102 applicability = "maybe-incorrect",
1103 style = "verbose"
1104)]
1105AddToIf {
1106#[suggestion_part(code = "binding")]
1107pat_span: Span,
1108#[suggestion_part(code = " && binding == {name}")]
1109span: Span,
1110 name: String,
1111 ty: Ty<'tcx>,
1112 manual_partialeq_impl: bool,
1113 },
1114#[multipart_suggestion(
1115"{$manual_partialeq_impl ->
1116 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1117 *[true] check
1118 } for equality instead of pattern matching",
1119 applicability = "maybe-incorrect",
1120 style = "verbose"
1121)]
1122AddToLetChain {
1123#[suggestion_part(code = "binding")]
1124pat_span: Span,
1125#[suggestion_part(code = " && binding == {name}")]
1126span: Span,
1127 name: String,
1128 ty: Ty<'tcx>,
1129 manual_partialeq_impl: bool,
1130 },
1131#[multipart_suggestion(
1132"{$manual_partialeq_impl ->
1133 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1134 *[true] check
1135 } for equality instead of pattern matching",
1136 applicability = "maybe-incorrect",
1137 style = "verbose"
1138)]
1139ReplaceWithEq {
1140#[suggestion_part(code = "")]
1141removal: Span,
1142#[suggestion_part(code = " == ")]
1143eq: Span,
1144 ty: Ty<'tcx>,
1145 manual_partialeq_impl: bool,
1146 },
1147#[multipart_suggestion(
1148"{$manual_partialeq_impl ->
1149 [false] if `{$ty}` manually implemented `PartialEq`, you could check
1150 *[true] check
1151 } for equality instead of pattern matching",
1152 applicability = "maybe-incorrect",
1153 style = "verbose"
1154)]
1155ReplaceLetElseWithIf {
1156#[suggestion_part(code = "if ")]
1157if_span: Span,
1158#[suggestion_part(code = " == ")]
1159eq: Span,
1160#[suggestion_part(code = " ")]
1161else_span: Span,
1162 ty: Ty<'tcx>,
1163 manual_partialeq_impl: bool,
1164 },
1165}
11661167#[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)]
1168#[diag("constant of non-structural type `{$ty}` in a pattern")]
1169#[note(
1170"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1171)]
1172pub(crate) struct TypeNotPartialEq<'tcx> {
1173#[primary_span]
1174 #[label("constant of non-structural type")]
1175pub(crate) span: Span,
1176pub(crate) ty: Ty<'tcx>,
1177}
11781179#[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)]
1180#[diag("{$prefix} `{$non_sm_ty}` cannot be used in patterns")]
1181pub(crate) struct InvalidPattern<'tcx> {
1182#[primary_span]
1183 #[label("{$prefix} can't be used in patterns")]
1184pub(crate) span: Span,
1185pub(crate) non_sm_ty: Ty<'tcx>,
1186pub(crate) prefix: String,
1187}
11881189#[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)]
1190#[diag("cannot use unsized non-slice type `{$non_sm_ty}` in constant patterns")]
1191pub(crate) struct UnsizedPattern<'tcx> {
1192#[primary_span]
1193pub(crate) span: Span,
1194pub(crate) non_sm_ty: Ty<'tcx>,
1195}
11961197#[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)]
1198#[diag("cannot use NaN in patterns")]
1199#[note("NaNs compare inequal to everything, even themselves, so this pattern would never match")]
1200#[help("try using the `is_nan` method instead")]
1201pub(crate) struct NaNPattern {
1202#[primary_span]
1203 #[label("evaluates to `NaN`, which is not allowed in patterns")]
1204pub(crate) span: Span,
1205}
12061207#[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)]
1208#[diag(
1209"function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon"
1210)]
1211#[note("see https://github.com/rust-lang/rust/issues/70861 for details")]
1212pub(crate) struct PointerPattern {
1213#[primary_span]
1214 #[label("can't be used in patterns")]
1215pub(crate) span: Span,
1216}
12171218#[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)]
1219#[diag("mismatched types")]
1220#[note("the matched value is of type `{$ty}`")]
1221pub(crate) struct NonEmptyNeverPattern<'tcx> {
1222#[primary_span]
1223 #[label("a never pattern must be used on an uninhabited type")]
1224pub(crate) span: Span,
1225pub(crate) ty: Ty<'tcx>,
1226}
12271228#[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)]
1229#[diag("refutable pattern in {$origin}", code = E0005)]
1230pub(crate) struct PatternNotCovered<'s, 'tcx> {
1231#[primary_span]
1232pub(crate) span: Span,
1233pub(crate) origin: &'s str,
1234#[subdiagnostic]
1235pub(crate) uncovered: Uncovered,
1236#[subdiagnostic]
1237pub(crate) inform: Option<Inform>,
1238#[subdiagnostic]
1239pub(crate) interpreted_as_const: Option<InterpretedAsConst>,
1240#[subdiagnostic]
1241pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConstSugg>,
1242#[subdiagnostic]
1243pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
1244#[note(
1245"pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future"
1246)]
1247pub(crate) witness_1_is_privately_uninhabited: bool,
1248pub(crate) witness_1: String,
1249#[note("the matched value is of type `{$pattern_ty}`")]
1250pub(crate) _p: (),
1251pub(crate) pattern_ty: Ty<'tcx>,
1252#[subdiagnostic]
1253pub(crate) let_suggestion: Option<SuggestLet>,
1254#[subdiagnostic]
1255pub(crate) misc_suggestion: Option<MiscPatternSuggestion>,
1256}
12571258#[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)]
1259#[note(
1260"`let` bindings require an \"irrefutable pattern\", like a `struct` or an `enum` with only one variant"
1261)]
1262#[note("for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html")]
1263pub(crate) struct Inform;
12641265#[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)]
1266#[label(
1267"missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable"
1268)]
1269pub(crate) struct InterpretedAsConst {
1270#[primary_span]
1271pub(crate) span: Span,
1272pub(crate) variable: String,
1273}
12741275pub(crate) struct AdtDefinedHere<'tcx> {
1276pub(crate) adt_def_span: Span,
1277pub(crate) ty: Ty<'tcx>,
1278pub(crate) variants: Vec<Variant>,
1279}
12801281pub(crate) struct Variant {
1282pub(crate) span: Span,
1283}
12841285impl<'tcx> Subdiagnosticfor AdtDefinedHere<'tcx> {
1286fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1287diag.arg("ty", self.ty);
1288let mut spans = MultiSpan::from(self.adt_def_span);
12891290for Variant { span } in self.variants {
1291 spans.push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not covered"))msg!("not covered"));
1292 }
12931294diag.span_note(spans, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` defined here"))msg!("`{$ty}` defined here"));
1295 }
1296}
12971298#[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_18 =
[::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_18, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
}
}
}
}
};Subdiagnostic)]
1299#[suggestion(
1300"introduce a variable instead",
1301 code = "{variable}_var",
1302 applicability = "maybe-incorrect",
1303 style = "verbose"
1304)]
1305pub(crate) struct InterpretedAsConstSugg {
1306#[primary_span]
1307pub(crate) span: Span,
1308pub(crate) variable: String,
1309}
13101311#[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_19 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
});
let __code_20 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ todo!() }}"))
});
suggestions.push((__binding_0, __code_19));
suggestions.push((__binding_1, __code_20));
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_21 =
[::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_21, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1312pub(crate) enum SuggestLet {
1313#[multipart_suggestion(
1314"you might want to use `if let` to ignore the {$count ->
1315 [one] variant that isn't
1316 *[other] variants that aren't
1317 } matched",
1318 applicability = "has-placeholders"
1319)]
1320If {
1321#[suggestion_part(code = "if ")]
1322start_span: Span,
1323#[suggestion_part(code = " {{ todo!() }}")]
1324semi_span: Span,
1325 count: usize,
1326 },
1327#[suggestion(
1328"you might want to use `let...else` to handle the {$count ->
1329 [one] variant that isn't
1330 *[other] variants that aren't
1331 } matched",
1332 code = " else {{ todo!() }}",
1333 applicability = "has-placeholders"
1334)]
1335Else {
1336#[primary_span]
1337end_span: Span,
1338 count: usize,
1339 },
1340}
13411342#[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_22 =
[::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_22, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
1343pub(crate) enum MiscPatternSuggestion {
1344#[suggestion(
1345"alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits",
1346 code = "_",
1347 applicability = "maybe-incorrect"
1348)]
1349AttemptedIntegerLiteral {
1350#[primary_span]
1351start_span: Span,
1352 },
1353}
13541355#[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)]
1356#[diag("invalid update of the `#[loop_match]` state")]
1357pub(crate) struct LoopMatchInvalidUpdate {
1358#[primary_span]
1359pub lhs: Span,
1360#[label("the assignment must update this variable")]
1361pub scrutinee: Span,
1362}
13631364#[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)]
1365#[diag("invalid match on `#[loop_match]` state")]
1366#[note("a local variable must be the scrutinee within a `#[loop_match]`")]
1367pub(crate) struct LoopMatchInvalidMatch {
1368#[primary_span]
1369pub span: Span,
1370}
13711372#[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)]
1373#[diag("this `#[loop_match]` state value has type `{$ty}`, which is not supported")]
1374#[note("only integers, floats, bool, char, and enums without fields are supported")]
1375pub(crate) struct LoopMatchUnsupportedType<'tcx> {
1376#[primary_span]
1377pub span: Span,
1378pub ty: Ty<'tcx>,
1379}
13801381#[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)]
1382#[diag("statements are not allowed in this position within a `#[loop_match]`")]
1383pub(crate) struct LoopMatchBadStatements {
1384#[primary_span]
1385pub span: Span,
1386}
13871388#[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)]
1389#[diag("this expression must be a single `match` wrapped in a labeled block")]
1390pub(crate) struct LoopMatchBadRhs {
1391#[primary_span]
1392pub span: Span,
1393}
13941395#[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)]
1396#[diag("expected a single assignment expression")]
1397pub(crate) struct LoopMatchMissingAssignment {
1398#[primary_span]
1399pub span: Span,
1400}
14011402#[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)]
1403#[diag("match arms that are part of a `#[loop_match]` cannot have guards")]
1404pub(crate) struct LoopMatchArmWithGuard {
1405#[primary_span]
1406pub span: Span,
1407}
14081409#[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)]
1410#[diag("could not determine the target branch for this `#[const_continue]`")]
1411#[help("try extracting the expression into a `const` item")]
1412pub(crate) struct ConstContinueNotMonomorphicConst {
1413#[primary_span]
1414pub span: Span,
14151416#[subdiagnostic]
1417pub reason: ConstContinueNotMonomorphicConstReason,
1418}
14191420#[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)]
1421pub(crate) enum ConstContinueNotMonomorphicConstReason {
1422#[label("constant parameters may use generics, and are not evaluated early enough")]
1423ConstantParameter {
1424#[primary_span]
1425span: Span,
1426 },
14271428#[label("`const` blocks may use generics, and are not evaluated early enough")]
1429ConstBlock {
1430#[primary_span]
1431span: Span,
1432 },
14331434#[label("this value must be a literal or a monomorphic const")]
1435Other {
1436#[primary_span]
1437span: Span,
1438 },
1439}
14401441#[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)]
1442#[diag("could not determine the target branch for this `#[const_continue]`")]
1443pub(crate) struct ConstContinueBadConst {
1444#[primary_span]
1445 #[label("this value is too generic")]
1446pub span: Span,
1447}
14481449#[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)]
1450#[diag("a `#[const_continue]` must break to a label with a value")]
1451pub(crate) struct ConstContinueMissingLabelOrValue {
1452#[primary_span]
1453pub span: Span,
1454}
14551456#[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)]
1457#[diag("the target of this `#[const_continue]` is not statically known")]
1458pub(crate) struct ConstContinueUnknownJumpTarget {
1459#[primary_span]
1460pub span: Span,
1461}