1use rustc_errors::codes::*;
2use rustc_errors::{
3Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
4MultiSpan, Subdiagnostic, inline_fluent,
5};
6use rustc_macros::{Diagnostic, LintDiagnostic, 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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
CallToDeprecatedSafeFnRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
CallToDeprecatedSafeFnRequiresUnsafe {
span: __binding_0,
function: __binding_1,
guarantee: __binding_2,
sub: __binding_3 } => {
diag.primary_message(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.arg("guarantee", __binding_2);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to unsafe function")));
diag.subdiagnostic(__binding_3);
diag
}
};
}
}
};LintDiagnostic)]
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,
18pub(crate) guarantee: String,
19#[subdiagnostic]
20pub(crate) sub: CallToDeprecatedSafeFnRequiresUnsafeSub,
21}
2223#[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 } => {
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));
diag.store_args();
diag.arg("start_of_line_suggestion", __binding_0);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can wrap the call in an `unsafe` block if you can guarantee {$guarantee}")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
24#[multipart_suggestion(
25"you can wrap the call in an `unsafe` block if you can guarantee {$guarantee}",
26 applicability = "machine-applicable"
27)]
28pub(crate) struct CallToDeprecatedSafeFnRequiresUnsafeSub {
29pub(crate) start_of_line_suggestion: String,
30#[suggestion_part(code = "{start_of_line_suggestion}")]
31pub(crate) start_of_line: Span,
32#[suggestion_part(code = "unsafe {{ ")]
33pub(crate) left: Span,
34#[suggestion_part(code = " }}")]
35pub(crate) right: Span,
36}
3738#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
span: __binding_0,
function: __binding_1,
unsafe_not_inherited_note: __binding_2 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe {
span: __binding_0, unsafe_not_inherited_note: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
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 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
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 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items do not inherit unsafety from separate enclosing items")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};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"))inline_fluent!(
623"an unsafe function restricts its caller, but its body is safe by default"
624),
625 );
626let body_start = self.body_span.shrink_to_lo();
627let body_end = self.body_span.shrink_to_hi();
628diag.tool_only_multipart_suggestion(
629rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider wrapping the function body in an unsafe block"))inline_fluent!("consider wrapping the function body in an unsafe block"),
630<[_]>::into_vec(::alloc::boxed::box_new([(body_start, "{ unsafe ".into()),
(body_end, "}".into())]))vec![(body_start, "{ unsafe ".into()), (body_end, "}".into())],
631 Applicability::MachineApplicable,
632 );
633 }
634}
635636#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for UnusedUnsafe {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnusedUnsafe { span: __binding_0, enclosing: __binding_1 }
=> {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
637#[diag("unnecessary `unsafe` block")]
638pub(crate) struct UnusedUnsafe {
639#[label("unnecessary `unsafe` block")]
640pub(crate) span: Span,
641#[subdiagnostic]
642pub(crate) enclosing: Option<UnusedUnsafeEnclosing>,
643}
644645#[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 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("because it's nested under this `unsafe` block")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
646pub(crate) enum UnusedUnsafeEnclosing {
647#[label("because it's nested under this `unsafe` block")]
648Block {
649#[primary_span]
650span: Span,
651 },
652}
653654pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
655pub(crate) cx: &'m RustcPatCtxt<'p, 'tcx>,
656pub(crate) scrut_span: Span,
657pub(crate) braces_span: Option<Span>,
658pub(crate) ty: Ty<'tcx>,
659}
660661impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
662fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
663let mut diag = Diag::new(
664dcx,
665level,
666rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-exhaustive patterns: type `{$ty}` is non-empty"))inline_fluent!("non-exhaustive patterns: type `{$ty}` is non-empty"),
667 );
668diag.span(self.scrut_span);
669diag.code(E0004);
670let peeled_ty = self.ty.peel_refs();
671diag.arg("ty", self.ty);
672diag.arg("peeled_ty", peeled_ty);
673674if let ty::Adt(def, _) = peeled_ty.kind() {
675let def_span = self676 .cx
677 .tcx
678 .hir_get_if_local(def.did())
679 .and_then(|node| node.ident())
680 .map(|ident| ident.span)
681 .unwrap_or_else(|| self.cx.tcx.def_span(def.did()));
682683// workaround to make test pass
684let mut span: MultiSpan = def_span.into();
685span.push_span_label(def_span, "");
686687diag.span_note(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$peeled_ty}` defined here"))inline_fluent!("`{$peeled_ty}` defined here"));
688 }
689690let 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(),
691 ty::Adt(def, _) if def.variant_list_has_applicable_non_exhaustive());
692if is_non_exhaustive {
693diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`, which is marked as non-exhaustive"))inline_fluent!(
694"the matched value is of type `{$ty}`, which is marked as non-exhaustive"
695));
696 } else {
697diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the matched value is of type `{$ty}`"))inline_fluent!("the matched value is of type `{$ty}`"));
698 }
699700if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
701if !sub_ty.is_inhabited_from(self.cx.tcx, self.cx.module, self.cx.typing_env) {
702diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are always considered inhabited"))inline_fluent!("references are always considered inhabited"));
703 }
704 }
705706let sm = self.cx.tcx.sess.source_map();
707if let Some(braces_span) = self.braces_span {
708// Get the span for the empty match body `{}`.
709let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.scrut_span)
710 {
711 (::alloc::__export::must_use({
::alloc::fmt::format(format_args!("\n{0}", snippet))
})format!("\n{snippet}"), " ")
712 } else {
713 (" ".to_string(), "")
714 };
715diag.span_suggestion_verbose(
716braces_span,
717rustc_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"))inline_fluent!("ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown"),
718::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{{0}{1}_ => todo!(),{0}}}",
indentation, more))
})format!(" {{{indentation}{more}_ => todo!(),{indentation}}}"),
719 Applicability::HasPlaceholders,
720 );
721 } else {
722diag.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"))inline_fluent!(
723"ensure that all possible cases are being handled by adding a match arm with a wildcard pattern"
724));
725 }
726727diag728 }
729}
730731#[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 => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("match arms with guards don't count towards exhaustivity")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
732#[note("match arms with guards don't count towards exhaustivity")]
733pub(crate) struct NonExhaustiveMatchAllArmsGuarded;
734735#[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)]
736#[diag("statics cannot be referenced in patterns", code = E0158)]
737pub(crate) struct StaticInPattern {
738#[primary_span]
739 #[label("can't be used in patterns")]
740pub(crate) span: Span,
741#[label("`static` defined here")]
742pub(crate) static_span: Span,
743}
744745#[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)]
746#[diag("constant parameters cannot be referenced in patterns", code = E0158)]
747pub(crate) struct ConstParamInPattern {
748#[primary_span]
749 #[label("can't be used in patterns")]
750pub(crate) span: Span,
751#[label("constant defined here")]
752pub(crate) const_span: Span,
753}
754755#[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)]
756#[diag("runtime values cannot be referenced in patterns", code = E0080)]
757pub(crate) struct NonConstPath {
758#[primary_span]
759 #[label("references a runtime value")]
760pub(crate) span: Span,
761}
762763#[derive(const _: () =
{
impl<'__a, 'tcx> rustc_errors::LintDiagnostic<'__a, ()> for
UnreachablePattern<'tcx> {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
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 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
764#[diag("unreachable pattern")]
765pub(crate) struct UnreachablePattern<'tcx> {
766#[label("no value can reach this")]
767pub(crate) span: Option<Span>,
768#[label("matches no values because `{$matches_no_values_ty}` is uninhabited")]
769pub(crate) matches_no_values: Option<Span>,
770pub(crate) matches_no_values_ty: Ty<'tcx>,
771#[note(
772"to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types"
773)]
774pub(crate) uninhabited_note: Option<()>,
775#[label("matches any value")]
776pub(crate) covered_by_catchall: Option<Span>,
777#[subdiagnostic]
778pub(crate) wanted_constant: Option<WantedConstant>,
779#[note(
780"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"
781)]
782pub(crate) accessible_constant: Option<Span>,
783#[note(
784"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"
785)]
786pub(crate) inaccessible_constant: Option<Span>,
787#[note(
788"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"
789)]
790pub(crate) pattern_let_binding: Option<Span>,
791#[label("matches all the relevant values")]
792pub(crate) covered_by_one: Option<Span>,
793#[note("multiple earlier patterns match some of the same values")]
794pub(crate) covered_by_many: Option<MultiSpan>,
795pub(crate) covered_by_many_n_more_count: usize,
796#[suggestion("remove the match arm", code = "", applicability = "machine-applicable")]
797pub(crate) suggest_remove: Option<Span>,
798}
799800#[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();
diag.store_args();
diag.arg("is_typo", __binding_1);
diag.arg("const_name", __binding_2);
diag.arg("const_path", __binding_3);
let __message =
diag.eagerly_translate(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")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_4, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
801#[suggestion(
802"you might have meant to pattern match against the value of {$is_typo ->
803 [true] similarly named constant
804 *[false] constant
805 } `{$const_name}` instead of introducing a new catch-all binding",
806 code = "{const_path}",
807 applicability = "machine-applicable"
808)]
809pub(crate) struct WantedConstant {
810#[primary_span]
811pub(crate) span: Span,
812pub(crate) is_typo: bool,
813pub(crate) const_name: String,
814pub(crate) const_path: String,
815}
816817#[derive(const _: () =
{
impl<'__a, 'desc, 'tcx> rustc_errors::LintDiagnostic<'__a, ()> for
UnreachableDueToUninhabited<'desc, 'tcx> {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
UnreachableDueToUninhabited {
descr: __binding_0,
expr: __binding_1,
orig: __binding_2,
ty: __binding_3 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
818#[diag("unreachable {$descr}")]
819pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
820pub descr: &'desc str,
821#[label("unreachable {$descr}")]
822pub expr: Span,
823#[label("any code following this expression is unreachable")]
824 #[note("this expression has type `{$ty}`, which is uninhabited")]
825pub orig: Span,
826pub ty: Ty<'tcx>,
827}
828829#[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)]
830#[diag("constant pattern cannot depend on generic parameters", code = E0158)]
831pub(crate) struct ConstPatternDependsOnGenericParameter {
832#[primary_span]
833 #[label("`const` depends on a generic parameter")]
834pub(crate) span: Span,
835}
836837#[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)]
838#[diag("could not evaluate constant pattern")]
839pub(crate) struct CouldNotEvalConstPattern {
840#[primary_span]
841 #[label("could not evaluate constant")]
842pub(crate) span: Span,
843}
844845#[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)]
846#[diag("lower bound for range pattern must be less than or equal to upper bound", code = E0030)]
847pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
848#[primary_span]
849 #[label("lower bound larger than upper bound")]
850pub(crate) span: Span,
851#[note(
852"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"
853)]
854pub(crate) teach: bool,
855}
856857#[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)]
858#[diag("literal out of range for `{$ty}`")]
859pub(crate) struct LiteralOutOfRange<'tcx> {
860#[primary_span]
861 #[label("this value does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
862pub(crate) span: Span,
863pub(crate) ty: Ty<'tcx>,
864pub(crate) min: i128,
865pub(crate) max: u128,
866}
867868#[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)]
869#[diag("lower bound for range pattern must be less than upper bound", code = E0579)]
870pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
871#[primary_span]
872pub(crate) span: Span,
873}
874875#[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)]
876#[diag("exclusive upper bound for a range bound cannot be the minimum", code = E0579)]
877pub(crate) struct UpperRangeBoundCannotBeMin {
878#[primary_span]
879pub(crate) span: Span,
880}
881882#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
LeadingIrrefutableLetPatterns {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
LeadingIrrefutableLetPatterns { count: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("leading irrefutable {$count ->\n [one] pattern\n *[other] patterns\n} in let chain")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$count ->\n [one] this pattern\n *[other] these patterns\n} will always match")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving {$count ->\n [one] it\n *[other] them\n} outside of the construct")));
;
diag.arg("count", __binding_0);
diag
}
};
}
}
};LintDiagnostic)]
883#[diag(
884"leading irrefutable {$count ->
885 [one] pattern
886 *[other] patterns
887} in let chain"
888)]
889#[note(
890"{$count ->
891 [one] this pattern
892 *[other] these patterns
893} will always match"
894)]
895#[help(
896"consider moving {$count ->
897 [one] it
898 *[other] them
899} outside of the construct"
900)]
901pub(crate) struct LeadingIrrefutableLetPatterns {
902pub(crate) count: usize,
903}
904905#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
TrailingIrrefutableLetPatterns {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
TrailingIrrefutableLetPatterns { count: __binding_0 } => {
diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trailing irrefutable {$count ->\n [one] pattern\n *[other] patterns\n} in let chain")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$count ->\n [one] this pattern\n *[other] these patterns\n} will always match")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider moving {$count ->\n [one] it\n *[other] them\n} into the body")));
;
diag.arg("count", __binding_0);
diag
}
};
}
}
};LintDiagnostic)]
906#[diag(
907"trailing irrefutable {$count ->
908 [one] pattern
909 *[other] patterns
910} in let chain"
911)]
912#[note(
913"{$count ->
914 [one] this pattern
915 *[other] these patterns
916} will always match"
917)]
918#[help(
919"consider moving {$count ->
920 [one] it
921 *[other] them
922} into the body"
923)]
924pub(crate) struct TrailingIrrefutableLetPatterns {
925pub(crate) count: usize,
926}
927928#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
BindingsWithVariantName {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
BindingsWithVariantName {
suggestion: __binding_0,
ty_path: __binding_1,
name: __binding_2 } => {
diag.primary_message(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}`")));
diag.code(E0170);
;
let __code_5 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{1}::{0}", __binding_2,
__binding_1))
})].into_iter();
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
}
};
}
}
};LintDiagnostic)]
929#[diag("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`", code = E0170)]
930pub(crate) struct BindingsWithVariantName {
931#[suggestion(
932"to match on the variant, qualify the path",
933 code = "{ty_path}::{name}",
934 applicability = "machine-applicable"
935)]
936pub(crate) suggestion: Option<Span>,
937pub(crate) ty_path: String,
938pub(crate) name: Ident,
939}
940941#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
IrrefutableLetPatternsIfLet {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
IrrefutableLetPatternsIfLet { count: __binding_0 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
942#[diag(
943"irrefutable `if let` {$count ->
944 [one] pattern
945 *[other] patterns
946}"
947)]
948#[note(
949"{$count ->
950 [one] this pattern
951 *[other] these patterns
952} will always match, so the `if let` is useless"
953)]
954#[help("consider replacing the `if let` with a `let`")]
955pub(crate) struct IrrefutableLetPatternsIfLet {
956pub(crate) count: usize,
957}
958959#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
IrrefutableLetPatternsIfLetGuard {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
IrrefutableLetPatternsIfLetGuard { count: __binding_0 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
960#[diag(
961"irrefutable `if let` guard {$count ->
962 [one] pattern
963 *[other] patterns
964}"
965)]
966#[note(
967"{$count ->
968 [one] this pattern
969 *[other] these patterns
970} will always match, so the guard is useless"
971)]
972#[help("consider removing the guard and adding a `let` inside the match arm")]
973pub(crate) struct IrrefutableLetPatternsIfLetGuard {
974pub(crate) count: usize,
975}
976977#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
IrrefutableLetPatternsLetElse {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
IrrefutableLetPatternsLetElse { count: __binding_0 } => {
diag.primary_message(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\n *[other] these patterns\n} will always match, so the `else` clause is useless")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the `else` clause")));
;
diag.arg("count", __binding_0);
diag
}
};
}
}
};LintDiagnostic)]
978#[diag(
979"irrefutable `let...else` {$count ->
980 [one] pattern
981 *[other] patterns
982}"
983)]
984#[note(
985"{$count ->
986 [one] this pattern
987 *[other] these patterns
988} will always match, so the `else` clause is useless"
989)]
990#[help("consider removing the `else` clause")]
991pub(crate) struct IrrefutableLetPatternsLetElse {
992pub(crate) count: usize,
993}
994995#[derive(const _: () =
{
impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
IrrefutableLetPatternsWhileLet {
#[track_caller]
fn decorate_lint<'__b>(self,
diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
match self {
IrrefutableLetPatternsWhileLet { count: __binding_0 } => {
diag.primary_message(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
}
};
}
}
};LintDiagnostic)]
996#[diag(
997"irrefutable `while let` {$count ->
998 [one] pattern
999 *[other] patterns
1000}"
1001)]
1002#[note(
1003"{$count ->
1004 [one] this pattern
1005 *[other] these patterns
1006} will always match, so the loop will never exit"
1007)]
1008#[help("consider instead using a `loop {\"{\"} ... {\"}\"}` with a `let` inside it")]
1009pub(crate) struct IrrefutableLetPatternsWhileLet {
1010pub(crate) count: usize,
1011}
10121013#[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)]
1014#[diag("borrow of moved value")]
1015pub(crate) struct BorrowOfMovedValue<'tcx> {
1016#[primary_span]
1017 #[label("value moved into `{$name}` here")]
1018 #[label(
1019"move occurs because `{$name}` has type `{$ty}`, which does not implement the `Copy` trait"
1020)]
1021pub(crate) binding_span: Span,
1022#[label("value borrowed here after move")]
1023pub(crate) conflicts_ref: Vec<Span>,
1024pub(crate) name: Ident,
1025pub(crate) ty: Ty<'tcx>,
1026#[suggestion(
1027"borrow this binding in the pattern to avoid moving the value",
1028 code = "ref ",
1029 applicability = "machine-applicable"
1030)]
1031pub(crate) suggest_borrowing: Option<Span>,
1032}
10331034#[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)]
1035#[diag("cannot borrow value as mutable more than once at a time")]
1036pub(crate) struct MultipleMutBorrows {
1037#[primary_span]
1038pub(crate) span: Span,
1039#[subdiagnostic]
1040pub(crate) occurrences: Vec<Conflict>,
1041}
10421043#[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)]
1044#[diag("cannot borrow value as mutable because it is also borrowed as immutable")]
1045pub(crate) struct AlreadyBorrowed {
1046#[primary_span]
1047pub(crate) span: Span,
1048#[subdiagnostic]
1049pub(crate) occurrences: Vec<Conflict>,
1050}
10511052#[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)]
1053#[diag("cannot borrow value as immutable because it is also borrowed as mutable")]
1054pub(crate) struct AlreadyMutBorrowed {
1055#[primary_span]
1056pub(crate) span: Span,
1057#[subdiagnostic]
1058pub(crate) occurrences: Vec<Conflict>,
1059}
10601061#[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)]
1062#[diag("cannot move out of value because it is borrowed")]
1063pub(crate) struct MovedWhileBorrowed {
1064#[primary_span]
1065pub(crate) span: Span,
1066#[subdiagnostic]
1067pub(crate) occurrences: Vec<Conflict>,
1068}
10691070#[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 } => {
diag.store_args();
diag.arg("name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value is mutably borrowed by `{$name}` here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
Conflict::Ref { span: __binding_0, name: __binding_1 } => {
diag.store_args();
diag.arg("name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value is borrowed by `{$name}` here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
Conflict::Moved { span: __binding_0, name: __binding_1 } =>
{
diag.store_args();
diag.arg("name", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value is moved into `{$name}` here")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1071pub(crate) enum Conflict {
1072#[label("value is mutably borrowed by `{$name}` here")]
1073Mut {
1074#[primary_span]
1075span: Span,
1076 name: Symbol,
1077 },
1078#[label("value is borrowed by `{$name}` here")]
1079Ref {
1080#[primary_span]
1081span: Span,
1082 name: Symbol,
1083 },
1084#[label("value is moved into `{$name}` here")]
1085Moved {
1086#[primary_span]
1087span: Span,
1088 name: Symbol,
1089 },
1090}
10911092#[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)]
1093#[diag("cannot use unions in constant patterns")]
1094pub(crate) struct UnionPattern {
1095#[primary_span]
1096 #[label("can't use a `union` here")]
1097pub(crate) span: Span,
1098}
10991100#[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 } => {
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.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("`{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns")));
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")));
}
diag
}
}
}
}
};Diagnostic)]
1101#[diag("constant of non-structural type `{$ty}` in a pattern")]
1102pub(crate) struct TypeNotStructural<'tcx> {
1103#[primary_span]
1104 #[label("constant of non-structural type")]
1105pub(crate) span: Span,
1106#[label("`{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns")]
1107pub(crate) ty_def_span: Span,
1108pub(crate) ty: Ty<'tcx>,
1109#[note(
1110"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"
1111)]
1112pub(crate) manual_partialeq_impl_span: Option<Span>,
1113#[note(
1114"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1115)]
1116pub(crate) manual_partialeq_impl_note: bool,
1117}
11181119#[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)]
1120#[diag("constant of non-structural type `{$ty}` in a pattern")]
1121#[note(
1122"see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
1123)]
1124pub(crate) struct TypeNotPartialEq<'tcx> {
1125#[primary_span]
1126 #[label("constant of non-structural type")]
1127pub(crate) span: Span,
1128pub(crate) ty: Ty<'tcx>,
1129}
11301131#[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)]
1132#[diag("{$prefix} `{$non_sm_ty}` cannot be used in patterns")]
1133pub(crate) struct InvalidPattern<'tcx> {
1134#[primary_span]
1135 #[label("{$prefix} can't be used in patterns")]
1136pub(crate) span: Span,
1137pub(crate) non_sm_ty: Ty<'tcx>,
1138pub(crate) prefix: String,
1139}
11401141#[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)]
1142#[diag("cannot use unsized non-slice type `{$non_sm_ty}` in constant patterns")]
1143pub(crate) struct UnsizedPattern<'tcx> {
1144#[primary_span]
1145pub(crate) span: Span,
1146pub(crate) non_sm_ty: Ty<'tcx>,
1147}
11481149#[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)]
1150#[diag("cannot use NaN in patterns")]
1151#[note("NaNs compare inequal to everything, even themselves, so this pattern would never match")]
1152#[help("try using the `is_nan` method instead")]
1153pub(crate) struct NaNPattern {
1154#[primary_span]
1155 #[label("evaluates to `NaN`, which is not allowed in patterns")]
1156pub(crate) span: Span,
1157}
11581159#[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)]
1160#[diag(
1161"function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon"
1162)]
1163#[note("see https://github.com/rust-lang/rust/issues/70861 for details")]
1164pub(crate) struct PointerPattern {
1165#[primary_span]
1166 #[label("can't be used in patterns")]
1167pub(crate) span: Span,
1168}
11691170#[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)]
1171#[diag("mismatched types")]
1172#[note("the matched value is of type `{$ty}`")]
1173pub(crate) struct NonEmptyNeverPattern<'tcx> {
1174#[primary_span]
1175 #[label("a never pattern must be used on an uninhabited type")]
1176pub(crate) span: Span,
1177pub(crate) ty: Ty<'tcx>,
1178}
11791180#[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)]
1181#[diag("refutable pattern in {$origin}", code = E0005)]
1182pub(crate) struct PatternNotCovered<'s, 'tcx> {
1183#[primary_span]
1184pub(crate) span: Span,
1185pub(crate) origin: &'s str,
1186#[subdiagnostic]
1187pub(crate) uncovered: Uncovered,
1188#[subdiagnostic]
1189pub(crate) inform: Option<Inform>,
1190#[subdiagnostic]
1191pub(crate) interpreted_as_const: Option<InterpretedAsConst>,
1192#[subdiagnostic]
1193pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConstSugg>,
1194#[subdiagnostic]
1195pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
1196#[note(
1197"pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future"
1198)]
1199pub(crate) witness_1_is_privately_uninhabited: bool,
1200pub(crate) witness_1: String,
1201#[note("the matched value is of type `{$pattern_ty}`")]
1202pub(crate) _p: (),
1203pub(crate) pattern_ty: Ty<'tcx>,
1204#[subdiagnostic]
1205pub(crate) let_suggestion: Option<SuggestLet>,
1206#[subdiagnostic]
1207pub(crate) misc_suggestion: Option<MiscPatternSuggestion>,
1208}
12091210#[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 => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`let` bindings require an \"irrefutable pattern\", like a `struct` or an `enum` with only one variant")));
diag.note(__message);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html")));
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1211#[note(
1212"`let` bindings require an \"irrefutable pattern\", like a `struct` or an `enum` with only one variant"
1213)]
1214#[note("for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html")]
1215pub(crate) struct Inform;
12161217#[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 } => {
diag.store_args();
diag.arg("variable", __binding_1);
let __message =
diag.eagerly_translate(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")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1218#[label(
1219"missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable"
1220)]
1221pub(crate) struct InterpretedAsConst {
1222#[primary_span]
1223pub(crate) span: Span,
1224pub(crate) variable: String,
1225}
12261227pub(crate) struct AdtDefinedHere<'tcx> {
1228pub(crate) adt_def_span: Span,
1229pub(crate) ty: Ty<'tcx>,
1230pub(crate) variants: Vec<Variant>,
1231}
12321233pub(crate) struct Variant {
1234pub(crate) span: Span,
1235}
12361237impl<'tcx> Subdiagnosticfor AdtDefinedHere<'tcx> {
1238fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1239diag.arg("ty", self.ty);
1240let mut spans = MultiSpan::from(self.adt_def_span);
12411242for Variant { span } in self.variants {
1243 spans.push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not covered"))inline_fluent!("not covered"));
1244 }
12451246diag.span_note(spans, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ty}` defined here"))inline_fluent!("`{$ty}` defined here"));
1247 }
1248}
12491250#[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_7 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}_var", __binding_1))
})].into_iter();
diag.store_args();
diag.arg("variable", __binding_1);
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("introduce a variable instead")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_7, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowAlways);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1251#[suggestion(
1252"introduce a variable instead",
1253 code = "{variable}_var",
1254 applicability = "maybe-incorrect",
1255 style = "verbose"
1256)]
1257pub(crate) struct InterpretedAsConstSugg {
1258#[primary_span]
1259pub(crate) span: Span,
1260pub(crate) variable: String,
1261}
12621263#[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_8 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("if "))
});
let __code_9 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" {{ todo!() }}"))
});
suggestions.push((__binding_0, __code_8));
suggestions.push((__binding_1, __code_9));
diag.store_args();
diag.arg("count", __binding_2);
let __message =
diag.eagerly_translate(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")));
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
SuggestLet::Else { end_span: __binding_0, count: __binding_1
} => {
let __code_10 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" else {{ todo!() }}"))
})].into_iter();
diag.store_args();
diag.arg("count", __binding_1);
let __message =
diag.eagerly_translate(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")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_10, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1264pub(crate) enum SuggestLet {
1265#[multipart_suggestion(
1266"you might want to use `if let` to ignore the {$count ->
1267 [one] variant that isn't
1268 *[other] variants that aren't
1269 } matched",
1270 applicability = "has-placeholders"
1271)]
1272If {
1273#[suggestion_part(code = "if ")]
1274start_span: Span,
1275#[suggestion_part(code = " {{ todo!() }}")]
1276semi_span: Span,
1277 count: usize,
1278 },
1279#[suggestion(
1280"you might want to use `let...else` to handle the {$count ->
1281 [one] variant that isn't
1282 *[other] variants that aren't
1283 } matched",
1284 code = " else {{ todo!() }}",
1285 applicability = "has-placeholders"
1286)]
1287Else {
1288#[primary_span]
1289end_span: Span,
1290 count: usize,
1291 },
1292}
12931294#[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_11 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("_"))
})].into_iter();
diag.store_args();
let __message =
diag.eagerly_translate(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")));
diag.span_suggestions_with_style(__binding_0, __message,
__code_11, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1295pub(crate) enum MiscPatternSuggestion {
1296#[suggestion(
1297"alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits",
1298 code = "_",
1299 applicability = "maybe-incorrect"
1300)]
1301AttemptedIntegerLiteral {
1302#[primary_span]
1303start_span: Span,
1304 },
1305}
13061307#[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)]
1308#[diag("invalid update of the `#[loop_match]` state")]
1309pub(crate) struct LoopMatchInvalidUpdate {
1310#[primary_span]
1311pub lhs: Span,
1312#[label("the assignment must update this variable")]
1313pub scrutinee: Span,
1314}
13151316#[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)]
1317#[diag("invalid match on `#[loop_match]` state")]
1318#[note("a local variable must be the scrutinee within a `#[loop_match]`")]
1319pub(crate) struct LoopMatchInvalidMatch {
1320#[primary_span]
1321pub span: Span,
1322}
13231324#[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)]
1325#[diag("this `#[loop_match]` state value has type `{$ty}`, which is not supported")]
1326#[note("only integers, floats, bool, char, and enums without fields are supported")]
1327pub(crate) struct LoopMatchUnsupportedType<'tcx> {
1328#[primary_span]
1329pub span: Span,
1330pub ty: Ty<'tcx>,
1331}
13321333#[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)]
1334#[diag("statements are not allowed in this position within a `#[loop_match]`")]
1335pub(crate) struct LoopMatchBadStatements {
1336#[primary_span]
1337pub span: Span,
1338}
13391340#[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)]
1341#[diag("this expression must be a single `match` wrapped in a labeled block")]
1342pub(crate) struct LoopMatchBadRhs {
1343#[primary_span]
1344pub span: Span,
1345}
13461347#[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)]
1348#[diag("expected a single assignment expression")]
1349pub(crate) struct LoopMatchMissingAssignment {
1350#[primary_span]
1351pub span: Span,
1352}
13531354#[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)]
1355#[diag("match arms that are part of a `#[loop_match]` cannot have guards")]
1356pub(crate) struct LoopMatchArmWithGuard {
1357#[primary_span]
1358pub span: Span,
1359}
13601361#[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)]
1362#[diag("could not determine the target branch for this `#[const_continue]`")]
1363#[help("try extracting the expression into a `const` item")]
1364pub(crate) struct ConstContinueNotMonomorphicConst {
1365#[primary_span]
1366pub span: Span,
13671368#[subdiagnostic]
1369pub reason: ConstContinueNotMonomorphicConstReason,
1370}
13711372#[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 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("constant parameters may use generics, and are not evaluated early enough")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
ConstContinueNotMonomorphicConstReason::ConstBlock {
span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`const` blocks may use generics, and are not evaluated early enough")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
ConstContinueNotMonomorphicConstReason::Other {
span: __binding_0 } => {
diag.store_args();
let __message =
diag.eagerly_translate(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this value must be a literal or a monomorphic const")));
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
1373pub(crate) enum ConstContinueNotMonomorphicConstReason {
1374#[label("constant parameters may use generics, and are not evaluated early enough")]
1375ConstantParameter {
1376#[primary_span]
1377span: Span,
1378 },
13791380#[label("`const` blocks may use generics, and are not evaluated early enough")]
1381ConstBlock {
1382#[primary_span]
1383span: Span,
1384 },
13851386#[label("this value must be a literal or a monomorphic const")]
1387Other {
1388#[primary_span]
1389span: Span,
1390 },
1391}
13921393#[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)]
1394#[diag("could not determine the target branch for this `#[const_continue]`")]
1395pub(crate) struct ConstContinueBadConst {
1396#[primary_span]
1397 #[label("this value is too generic")]
1398pub span: Span,
1399}
14001401#[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)]
1402#[diag("a `#[const_continue]` must break to a label with a value")]
1403pub(crate) struct ConstContinueMissingLabelOrValue {
1404#[primary_span]
1405pub span: Span,
1406}
14071408#[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)]
1409#[diag("the target of this `#[const_continue]` is not statically known")]
1410pub(crate) struct ConstContinueUnknownJumpTarget {
1411#[primary_span]
1412pub span: Span,
1413}