2023-12-10 19:42:30 +00:00
|
|
|
use rustc_errors::codes::*;
|
2022-11-26 20:22:49 +00:00
|
|
|
use rustc_errors::{
|
2024-06-18 10:35:56 +00:00
|
|
|
Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
|
2024-03-06 03:00:16 +00:00
|
|
|
MultiSpan, SubdiagMessageOp, Subdiagnostic,
|
2022-11-26 20:22:49 +00:00
|
|
|
};
|
|
|
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
2022-08-26 13:38:21 +00:00
|
|
|
use rustc_middle::ty::{self, Ty};
|
2024-03-13 13:07:44 +00:00
|
|
|
use rustc_pattern_analysis::errors::Uncovered;
|
|
|
|
use rustc_pattern_analysis::rustc::RustcPatCtxt;
|
2023-02-27 17:43:39 +00:00
|
|
|
use rustc_span::symbol::Symbol;
|
|
|
|
use rustc_span::Span;
|
2022-08-20 11:28:43 +00:00
|
|
|
|
2023-12-10 19:42:30 +00:00
|
|
|
use crate::fluent_generated as fluent;
|
2024-07-28 22:13:50 +00:00
|
|
|
|
2022-08-20 11:28:43 +00:00
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_unconditional_recursion)]
|
2022-08-20 11:28:43 +00:00
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnconditionalRecursion {
|
2022-08-20 11:28:43 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-11-26 20:22:49 +00:00
|
|
|
#[label(mir_build_unconditional_recursion_call_site_label)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) call_sites: Vec<Span>,
|
2022-08-20 11:28:43 +00:00
|
|
|
}
|
2022-08-20 20:54:58 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-28 13:16:25 +00:00
|
|
|
#[diag(mir_build_call_to_deprecated_safe_fn_requires_unsafe)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToDeprecatedSafeFnRequiresUnsafe {
|
2024-05-28 13:16:25 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) function: String,
|
2024-07-29 11:31:59 +00:00
|
|
|
pub(crate) guarantee: String,
|
2024-05-28 13:16:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) sub: CallToDeprecatedSafeFnRequiresUnsafeSub,
|
2024-05-28 13:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[multipart_suggestion(mir_build_suggestion, applicability = "machine-applicable")]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToDeprecatedSafeFnRequiresUnsafeSub {
|
2024-07-17 11:45:31 +00:00
|
|
|
pub(crate) start_of_line_suggestion: String,
|
|
|
|
#[suggestion_part(code = "{start_of_line_suggestion}")]
|
2024-06-05 09:06:41 +00:00
|
|
|
pub(crate) start_of_line: Span,
|
2024-05-28 13:16:25 +00:00
|
|
|
#[suggestion_part(code = "unsafe {{ ")]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) left: Span,
|
2024-05-28 13:16:25 +00:00
|
|
|
#[suggestion_part(code = " }}")]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) right: Span,
|
2024-05-28 13:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) function: String,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe, code = E0133)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(
|
|
|
|
mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe,
|
|
|
|
code = E0133
|
|
|
|
)]
|
2022-08-20 20:54:58 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(
|
|
|
|
mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe,
|
|
|
|
code = E0133,
|
|
|
|
)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2024-05-17 12:43:59 +00:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe, code = E0133)]
|
2023-11-28 19:37:02 +00:00
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
|
2022-08-20 20:54:58 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) function: String,
|
|
|
|
pub(crate) missing_target_features: DiagArgValue,
|
|
|
|
pub(crate) missing_target_features_count: usize,
|
2023-11-28 19:37:02 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) note: Option<()>,
|
|
|
|
pub(crate) build_target_features: DiagArgValue,
|
|
|
|
pub(crate) build_target_features_count: usize,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 20:54:58 +00:00
|
|
|
}
|
2022-08-24 08:01:53 +00:00
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToUnsafeFunctionRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) function: String,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_nameless, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToUnsafeFunctionRequiresUnsafeNameless {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) function: String,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[diag(
|
2022-11-26 20:22:49 +00:00
|
|
|
mir_build_call_to_unsafe_fn_requires_unsafe_nameless_unsafe_op_in_unsafe_fn_allowed,
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
code = E0133
|
2022-08-24 08:01:53 +00:00
|
|
|
)]
|
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_inline_assembly_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UseOfInlineAssemblyRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_inline_assembly_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_initializing_type_with_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct InitializingTypeWithRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[diag(
|
2022-11-26 20:22:49 +00:00
|
|
|
mir_build_initializing_type_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
code = E0133
|
2022-08-24 08:01:53 +00:00
|
|
|
)]
|
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_mutable_static_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UseOfMutableStaticRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_mutable_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_extern_static_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UseOfExternStaticRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_deref_raw_pointer_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct DerefOfRawPointerRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_deref_raw_pointer_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_union_field_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct AccessToUnionFieldRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_union_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_mutation_of_layout_constrained_field_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[diag(
|
2022-11-26 20:22:49 +00:00
|
|
|
mir_build_mutation_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
code = E0133
|
2022-08-24 08:01:53 +00:00
|
|
|
)]
|
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_borrow_of_layout_constrained_field_requires_unsafe, code = E0133)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 08:01:53 +00:00
|
|
|
#[diag(
|
2022-11-26 20:22:49 +00:00
|
|
|
mir_build_borrow_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
code = E0133
|
2022-08-24 08:01:53 +00:00
|
|
|
)]
|
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_call_to_fn_with_requires_unsafe, code = E0133)]
|
2023-11-28 19:37:02 +00:00
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToFunctionWithRequiresUnsafe {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) function: String,
|
|
|
|
pub(crate) missing_target_features: DiagArgValue,
|
|
|
|
pub(crate) missing_target_features_count: usize,
|
2023-11-28 19:37:02 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) note: Option<()>,
|
|
|
|
pub(crate) build_target_features: DiagArgValue,
|
|
|
|
pub(crate) build_target_features_count: usize,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2023-11-28 19:37:02 +00:00
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 08:01:53 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) function: String,
|
|
|
|
pub(crate) missing_target_features: DiagArgValue,
|
|
|
|
pub(crate) missing_target_features_count: usize,
|
2023-11-28 19:37:02 +00:00
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) note: Option<()>,
|
|
|
|
pub(crate) build_target_features: DiagArgValue,
|
|
|
|
pub(crate) build_target_features_count: usize,
|
2023-07-15 02:06:32 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2023-07-15 02:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[label(mir_build_unsafe_not_inherited)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeNotInheritedNote {
|
2023-07-15 02:06:32 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-24 08:01:53 +00:00
|
|
|
}
|
2022-08-24 17:16:50 +00:00
|
|
|
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsafeNotInheritedLintNote {
|
|
|
|
pub(crate) signature_span: Span,
|
|
|
|
pub(crate) body_span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
}
|
|
|
|
|
2024-03-06 03:00:16 +00:00
|
|
|
impl Subdiagnostic for UnsafeNotInheritedLintNote {
|
|
|
|
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
Reduce capabilities of `Diagnostic`.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)
`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.
The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)
All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.
There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.
There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-06 05:44:30 +00:00
|
|
|
self,
|
2024-02-22 23:20:45 +00:00
|
|
|
diag: &mut Diag<'_, G>,
|
2024-04-18 19:18:35 +00:00
|
|
|
_f: &F,
|
Reduce capabilities of `Diagnostic`.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)
`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.
The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)
All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.
There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.
There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-06 05:44:30 +00:00
|
|
|
) {
|
2023-10-26 15:39:25 +00:00
|
|
|
diag.span_note(self.signature_span, fluent::mir_build_unsafe_fn_safe_body);
|
|
|
|
let body_start = self.body_span.shrink_to_lo();
|
|
|
|
let body_end = self.body_span.shrink_to_hi();
|
|
|
|
diag.tool_only_multipart_suggestion(
|
|
|
|
fluent::mir_build_wrap_suggestion,
|
|
|
|
vec![(body_start, "{ unsafe ".into()), (body_end, "}".into())],
|
2024-01-13 23:06:34 +00:00
|
|
|
Applicability::MachineApplicable,
|
2023-10-26 15:39:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-24 17:16:50 +00:00
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_unused_unsafe)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnusedUnsafe {
|
2022-08-24 17:16:50 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-24 17:16:50 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) enclosing: Option<UnusedUnsafeEnclosing>,
|
2022-08-24 17:16:50 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) enum UnusedUnsafeEnclosing {
|
2022-11-26 20:22:49 +00:00
|
|
|
#[label(mir_build_unused_unsafe_enclosing_block_label)]
|
2022-08-24 17:16:50 +00:00
|
|
|
Block {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
2022-08-26 13:38:21 +00:00
|
|
|
|
|
|
|
pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) cx: &'m RustcPatCtxt<'p, 'tcx>,
|
|
|
|
pub(crate) scrut_span: Span,
|
|
|
|
pub(crate) braces_span: Option<Span>,
|
|
|
|
pub(crate) ty: Ty<'tcx>,
|
2022-08-26 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
2024-03-06 00:02:56 +00:00
|
|
|
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
2024-06-18 10:35:56 +00:00
|
|
|
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'_, G> {
|
2024-02-22 23:20:45 +00:00
|
|
|
let mut diag =
|
|
|
|
Diag::new(dcx, level, fluent::mir_build_non_exhaustive_patterns_type_not_empty);
|
2024-04-02 23:06:28 +00:00
|
|
|
diag.span(self.scrut_span);
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
diag.code(E0004);
|
2022-08-26 13:38:21 +00:00
|
|
|
let peeled_ty = self.ty.peel_refs();
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.arg("ty", self.ty);
|
|
|
|
diag.arg("peeled_ty", peeled_ty);
|
2022-08-26 13:38:21 +00:00
|
|
|
|
|
|
|
if let ty::Adt(def, _) = peeled_ty.kind() {
|
|
|
|
let def_span = self
|
|
|
|
.cx
|
|
|
|
.tcx
|
|
|
|
.hir()
|
|
|
|
.get_if_local(def.did())
|
|
|
|
.and_then(|node| node.ident())
|
|
|
|
.map(|ident| ident.span)
|
|
|
|
.unwrap_or_else(|| self.cx.tcx.def_span(def.did()));
|
|
|
|
|
|
|
|
// workaround to make test pass
|
|
|
|
let mut span: MultiSpan = def_span.into();
|
|
|
|
span.push_span_label(def_span, "");
|
|
|
|
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.span_note(span, fluent::mir_build_def_note);
|
2022-08-26 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
2023-04-15 18:49:54 +00:00
|
|
|
let is_variant_list_non_exhaustive = matches!(self.ty.kind(),
|
|
|
|
ty::Adt(def, _) if def.is_variant_list_non_exhaustive() && !def.did().is_local());
|
2022-08-26 13:38:21 +00:00
|
|
|
if is_variant_list_non_exhaustive {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.note(fluent::mir_build_non_exhaustive_type_note);
|
2022-08-26 13:38:21 +00:00
|
|
|
} else {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.note(fluent::mir_build_type_note);
|
2022-08-26 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
|
2022-11-26 20:22:49 +00:00
|
|
|
if !sub_ty.is_inhabited_from(self.cx.tcx, self.cx.module, self.cx.param_env) {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.note(fluent::mir_build_reference_note);
|
2022-08-26 13:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let sm = self.cx.tcx.sess.source_map();
|
2024-04-02 23:06:28 +00:00
|
|
|
if let Some(braces_span) = self.braces_span {
|
2022-08-26 13:38:21 +00:00
|
|
|
// Get the span for the empty match body `{}`.
|
2024-04-02 23:06:28 +00:00
|
|
|
let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.scrut_span)
|
|
|
|
{
|
2023-07-25 21:17:39 +00:00
|
|
|
(format!("\n{snippet}"), " ")
|
2022-08-26 13:38:21 +00:00
|
|
|
} else {
|
|
|
|
(" ".to_string(), "")
|
|
|
|
};
|
|
|
|
diag.span_suggestion_verbose(
|
2024-04-02 23:06:28 +00:00
|
|
|
braces_span,
|
2022-10-13 09:13:02 +00:00
|
|
|
fluent::mir_build_suggestion,
|
2024-04-02 23:06:28 +00:00
|
|
|
format!(" {{{indentation}{more}_ => todo!(),{indentation}}}"),
|
2022-08-26 13:38:21 +00:00
|
|
|
Applicability::HasPlaceholders,
|
|
|
|
);
|
|
|
|
} else {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.help(fluent::mir_build_help);
|
2022-08-26 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
2022-08-26 16:30:33 +00:00
|
|
|
|
2023-06-28 05:49:21 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[note(mir_build_non_exhaustive_match_all_arms_guarded)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct NonExhaustiveMatchAllArmsGuarded;
|
2023-06-28 05:49:21 +00:00
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_static_in_pattern, code = E0158)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct StaticInPattern {
|
2022-08-26 16:30:33 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-26 16:30:33 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_const_param_in_pattern, code = E0158)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct ConstParamInPattern {
|
2022-08-26 16:30:33 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-26 16:30:33 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_non_const_path, code = E0080)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct NonConstPath {
|
2022-08-26 16:30:33 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-26 16:30:33 +00:00
|
|
|
}
|
2022-08-27 19:06:06 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_unreachable_pattern)]
|
2024-07-21 12:46:05 +00:00
|
|
|
pub(crate) struct UnreachablePattern<'tcx> {
|
2022-08-27 19:06:06 +00:00
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Option<Span>,
|
2024-07-21 12:46:05 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub(crate) matches_no_values: Option<UnreachableMatchesNoValues<'tcx>>,
|
|
|
|
#[label(mir_build_unreachable_covered_by_catchall)]
|
|
|
|
pub(crate) covered_by_catchall: Option<Span>,
|
|
|
|
#[label(mir_build_unreachable_covered_by_one)]
|
|
|
|
pub(crate) covered_by_one: Option<Span>,
|
2024-07-24 06:40:04 +00:00
|
|
|
#[note(mir_build_unreachable_covered_by_many)]
|
|
|
|
pub(crate) covered_by_many: Option<MultiSpan>,
|
2024-07-21 12:46:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[note(mir_build_unreachable_matches_no_values)]
|
|
|
|
pub(crate) struct UnreachableMatchesNoValues<'tcx> {
|
|
|
|
pub(crate) ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
2024-07-13 16:32:10 +00:00
|
|
|
#[diag(mir_build_const_pattern_depends_on_generic_parameter, code = E0158)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct ConstPatternDependsOnGenericParameter {
|
2022-08-27 19:17:10 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-27 19:17:10 +00:00
|
|
|
}
|
2022-08-27 19:25:09 +00:00
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_could_not_eval_const_pattern)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct CouldNotEvalConstPattern {
|
2022-08-27 19:25:09 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-27 19:25:09 +00:00
|
|
|
}
|
2022-08-27 19:48:18 +00:00
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper, code = E0030)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
|
2022-08-27 19:48:18 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-10-13 09:13:02 +00:00
|
|
|
#[note(mir_build_teach_note)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) teach: Option<()>,
|
2022-08-27 19:48:18 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 07:10:17 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_literal_in_range_out_of_bounds)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct LiteralOutOfRange<'tcx> {
|
2023-01-09 07:10:17 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) ty: Ty<'tcx>,
|
|
|
|
pub(crate) min: i128,
|
|
|
|
pub(crate) max: u128,
|
2023-01-09 07:10:17 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_lower_range_bound_must_be_less_than_upper, code = E0579)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
|
2022-08-27 19:48:18 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-08-27 19:48:18 +00:00
|
|
|
}
|
2022-08-28 18:48:09 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_leading_irrefutable_let_patterns)]
|
2022-08-28 18:48:09 +00:00
|
|
|
#[note]
|
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct LeadingIrrefutableLetPatterns {
|
|
|
|
pub(crate) count: usize,
|
2022-08-28 18:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_trailing_irrefutable_let_patterns)]
|
2022-08-28 18:48:09 +00:00
|
|
|
#[note]
|
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct TrailingIrrefutableLetPatterns {
|
|
|
|
pub(crate) count: usize,
|
2022-08-28 18:48:09 +00:00
|
|
|
}
|
2022-08-29 07:06:50 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_bindings_with_variant_name, code = E0170)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct BindingsWithVariantName {
|
2023-02-27 17:43:39 +00:00
|
|
|
#[suggestion(code = "{ty_path}::{name}", applicability = "machine-applicable")]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) suggestion: Option<Span>,
|
|
|
|
pub(crate) ty_path: String,
|
|
|
|
pub(crate) name: Symbol,
|
2022-08-29 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_if_let)]
|
2022-08-29 08:21:25 +00:00
|
|
|
#[note]
|
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct IrrefutableLetPatternsIfLet {
|
|
|
|
pub(crate) count: usize,
|
2022-08-29 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_if_let_guard)]
|
2022-08-29 08:21:25 +00:00
|
|
|
#[note]
|
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct IrrefutableLetPatternsIfLetGuard {
|
|
|
|
pub(crate) count: usize,
|
2022-08-29 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_let_else)]
|
2022-08-29 08:21:25 +00:00
|
|
|
#[note]
|
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct IrrefutableLetPatternsLetElse {
|
|
|
|
pub(crate) count: usize,
|
2022-08-29 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 20:22:49 +00:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_while_let)]
|
2022-08-29 08:21:25 +00:00
|
|
|
#[note]
|
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct IrrefutableLetPatternsWhileLet {
|
|
|
|
pub(crate) count: usize,
|
2022-08-29 08:21:25 +00:00
|
|
|
}
|
2022-08-30 17:01:28 +00:00
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_borrow_of_moved_value)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct BorrowOfMovedValue<'tcx> {
|
2022-08-30 17:01:28 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2022-10-13 09:13:02 +00:00
|
|
|
#[label(mir_build_occurs_because_label)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) binding_span: Span,
|
2022-10-13 09:13:02 +00:00
|
|
|
#[label(mir_build_value_borrowed_label)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) conflicts_ref: Vec<Span>,
|
|
|
|
pub(crate) name: Symbol,
|
|
|
|
pub(crate) ty: Ty<'tcx>,
|
2022-08-30 17:01:28 +00:00
|
|
|
#[suggestion(code = "ref ", applicability = "machine-applicable")]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) suggest_borrowing: Option<Span>,
|
2022-08-30 17:01:28 +00:00
|
|
|
}
|
2022-08-30 17:38:10 +00:00
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_multiple_mut_borrows)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct MultipleMutBorrows {
|
2022-08-30 17:38:10 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-12-17 18:20:44 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) occurrences: Vec<Conflict>,
|
2023-01-17 12:48:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_already_borrowed)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct AlreadyBorrowed {
|
2023-01-17 12:48:43 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-01-17 12:48:43 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) occurrences: Vec<Conflict>,
|
2023-01-17 12:48:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_already_mut_borrowed)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct AlreadyMutBorrowed {
|
2023-01-17 12:48:43 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-01-17 12:48:43 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) occurrences: Vec<Conflict>,
|
2023-01-17 12:48:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_moved_while_borrowed)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct MovedWhileBorrowed {
|
2023-01-17 12:48:43 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-01-17 12:48:43 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) occurrences: Vec<Conflict>,
|
2022-08-30 17:38:10 +00:00
|
|
|
}
|
|
|
|
|
2022-11-26 20:22:49 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) enum Conflict {
|
2023-01-17 12:48:43 +00:00
|
|
|
#[label(mir_build_mutable_borrow)]
|
|
|
|
Mut {
|
2022-08-30 17:38:10 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
2023-02-27 17:43:39 +00:00
|
|
|
name: Symbol,
|
2022-08-30 17:38:10 +00:00
|
|
|
},
|
2023-01-17 12:48:43 +00:00
|
|
|
#[label(mir_build_borrow)]
|
|
|
|
Ref {
|
2022-08-30 17:38:10 +00:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
2023-02-27 17:43:39 +00:00
|
|
|
name: Symbol,
|
2022-08-30 17:38:10 +00:00
|
|
|
},
|
2023-01-17 12:48:43 +00:00
|
|
|
#[label(mir_build_moved)]
|
2022-08-30 17:38:10 +00:00
|
|
|
Moved {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
2023-02-27 17:43:39 +00:00
|
|
|
name: Symbol,
|
2022-08-30 17:38:10 +00:00
|
|
|
},
|
|
|
|
}
|
2022-12-19 23:28:33 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_union_pattern)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnionPattern {
|
2022-12-19 23:28:33 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2022-12-19 23:28:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_type_not_structural)]
|
2023-03-27 14:14:08 +00:00
|
|
|
#[note(mir_build_type_not_structural_tip)]
|
|
|
|
#[note(mir_build_type_not_structural_more_info)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct TypeNotStructural<'tcx> {
|
2022-12-19 23:28:33 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) non_sm_ty: Ty<'tcx>,
|
2022-12-19 23:28:33 +00:00
|
|
|
}
|
|
|
|
|
2024-02-08 19:08:19 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_non_partial_eq_match)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct TypeNotPartialEq<'tcx> {
|
2024-02-08 19:08:19 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) non_peq_ty: Ty<'tcx>,
|
2024-02-08 19:08:19 +00:00
|
|
|
}
|
|
|
|
|
2022-12-19 23:28:33 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_invalid_pattern)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct InvalidPattern<'tcx> {
|
2022-12-19 23:28:33 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) non_sm_ty: Ty<'tcx>,
|
2022-12-19 23:28:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_unsized_pattern)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct UnsizedPattern<'tcx> {
|
2022-12-19 23:28:33 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) non_sm_ty: Ty<'tcx>,
|
2022-12-19 23:28:33 +00:00
|
|
|
}
|
|
|
|
|
2023-09-30 06:15:34 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_nan_pattern)]
|
|
|
|
#[note]
|
|
|
|
#[help]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct NaNPattern {
|
2023-09-30 06:15:34 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-09-30 06:15:34 +00:00
|
|
|
}
|
2022-12-19 23:28:33 +00:00
|
|
|
|
2024-05-03 13:49:10 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-12-19 23:28:33 +00:00
|
|
|
#[diag(mir_build_pointer_pattern)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct PointerPattern {
|
2024-05-03 13:49:10 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2024-05-03 13:49:10 +00:00
|
|
|
}
|
2022-12-19 23:28:33 +00:00
|
|
|
|
2024-01-05 16:21:09 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_non_empty_never_pattern)]
|
|
|
|
#[note]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct NonEmptyNeverPattern<'tcx> {
|
2024-01-05 16:21:09 +00:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) ty: Ty<'tcx>,
|
2024-01-05 16:21:09 +00:00
|
|
|
}
|
|
|
|
|
2022-12-23 20:02:23 +00:00
|
|
|
#[derive(Diagnostic)]
|
2024-05-30 03:16:07 +00:00
|
|
|
#[diag(mir_build_exceeds_mcdc_condition_limit)]
|
|
|
|
pub(crate) struct MCDCExceedsConditionLimit {
|
2024-04-19 02:43:53 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) num_conditions: usize,
|
|
|
|
pub(crate) max_conditions: usize,
|
2024-04-19 02:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(mir_build_pattern_not_covered, code = E0005)]
|
2022-12-23 20:02:23 +00:00
|
|
|
pub(crate) struct PatternNotCovered<'s, 'tcx> {
|
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) origin: &'s str,
|
2022-12-23 20:02:23 +00:00
|
|
|
#[subdiagnostic]
|
2024-07-28 05:12:14 +00:00
|
|
|
pub(crate) uncovered: Uncovered,
|
2022-12-23 20:02:23 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) inform: Option<Inform>,
|
2022-12-23 20:02:23 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) interpreted_as_const: Option<InterpretedAsConst>,
|
2022-12-23 20:02:23 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
|
2023-04-09 08:09:43 +00:00
|
|
|
#[note(mir_build_privately_uninhabited)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) witness_1_is_privately_uninhabited: Option<()>,
|
2022-10-13 09:13:02 +00:00
|
|
|
#[note(mir_build_pattern_ty)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) _p: (),
|
|
|
|
pub(crate) pattern_ty: Ty<'tcx>,
|
2022-12-23 20:02:23 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) let_suggestion: Option<SuggestLet>,
|
2022-12-23 20:02:23 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) misc_suggestion: Option<MiscPatternSuggestion>,
|
2022-12-23 20:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[note(mir_build_inform_irrefutable)]
|
|
|
|
#[note(mir_build_more_information)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct Inform;
|
2022-12-23 20:02:23 +00:00
|
|
|
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct AdtDefinedHere<'tcx> {
|
|
|
|
pub(crate) adt_def_span: Span,
|
|
|
|
pub(crate) ty: Ty<'tcx>,
|
|
|
|
pub(crate) variants: Vec<Variant>,
|
2022-12-23 20:02:23 +00:00
|
|
|
}
|
|
|
|
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct Variant {
|
|
|
|
pub(crate) span: Span,
|
2022-12-23 20:02:23 +00:00
|
|
|
}
|
|
|
|
|
2024-03-06 03:00:16 +00:00
|
|
|
impl<'tcx> Subdiagnostic for AdtDefinedHere<'tcx> {
|
|
|
|
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
Reduce capabilities of `Diagnostic`.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)
`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.
The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)
All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.
There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.
There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-06 05:44:30 +00:00
|
|
|
self,
|
2024-02-22 23:20:45 +00:00
|
|
|
diag: &mut Diag<'_, G>,
|
2024-04-18 19:18:35 +00:00
|
|
|
_f: &F,
|
Reduce capabilities of `Diagnostic`.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)
`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.
The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)
All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.
There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.
There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-06 05:44:30 +00:00
|
|
|
) {
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.arg("ty", self.ty);
|
2022-12-23 20:02:23 +00:00
|
|
|
let mut spans = MultiSpan::from(self.adt_def_span);
|
|
|
|
|
|
|
|
for Variant { span } in self.variants {
|
2022-10-13 09:13:02 +00:00
|
|
|
spans.push_span_label(span, fluent::mir_build_variant_defined_here);
|
2022-12-23 20:02:23 +00:00
|
|
|
}
|
|
|
|
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.span_note(spans, fluent::mir_build_adt_defined_here);
|
2022-12-23 20:02:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[suggestion(
|
|
|
|
mir_build_interpreted_as_const,
|
|
|
|
code = "{variable}_var",
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
)]
|
|
|
|
#[label(mir_build_confused)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct InterpretedAsConst {
|
2022-12-23 20:02:23 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
|
|
|
pub(crate) variable: String,
|
2022-12-23 20:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) enum SuggestLet {
|
2022-12-23 20:02:23 +00:00
|
|
|
#[multipart_suggestion(mir_build_suggest_if_let, applicability = "has-placeholders")]
|
2022-12-23 21:23:37 +00:00
|
|
|
If {
|
2022-12-23 20:02:23 +00:00
|
|
|
#[suggestion_part(code = "if ")]
|
|
|
|
start_span: Span,
|
|
|
|
#[suggestion_part(code = " {{ todo!() }}")]
|
|
|
|
semi_span: Span,
|
|
|
|
count: usize,
|
|
|
|
},
|
2022-12-23 21:23:37 +00:00
|
|
|
#[suggestion(
|
|
|
|
mir_build_suggest_let_else,
|
|
|
|
code = " else {{ todo!() }}",
|
|
|
|
applicability = "has-placeholders"
|
|
|
|
)]
|
|
|
|
Else {
|
|
|
|
#[primary_span]
|
2022-12-23 20:02:23 +00:00
|
|
|
end_span: Span,
|
|
|
|
count: usize,
|
|
|
|
},
|
|
|
|
}
|
2023-01-13 01:14:26 +00:00
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) enum MiscPatternSuggestion {
|
2023-01-13 01:14:26 +00:00
|
|
|
#[suggestion(
|
|
|
|
mir_build_suggest_attempted_int_lit,
|
|
|
|
code = "_",
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
)]
|
|
|
|
AttemptedIntegerLiteral {
|
|
|
|
#[primary_span]
|
|
|
|
start_span: Span,
|
|
|
|
},
|
|
|
|
}
|
2023-02-27 01:32:07 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_rustc_box_attribute_error)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct RustcBoxAttributeError {
|
2023-02-27 01:32:07 +00:00
|
|
|
#[primary_span]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) span: Span,
|
2023-02-27 01:32:07 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) reason: RustcBoxAttrReason,
|
2023-02-27 01:32:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) enum RustcBoxAttrReason {
|
2023-02-27 01:32:07 +00:00
|
|
|
#[note(mir_build_attributes)]
|
|
|
|
Attributes,
|
|
|
|
#[note(mir_build_not_box)]
|
|
|
|
NotBoxNew,
|
|
|
|
#[note(mir_build_missing_box)]
|
|
|
|
MissingBox,
|
|
|
|
}
|
2024-05-02 23:55:03 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
|
|
|
#[diag(mir_build_rust_2024_incompatible_pat)]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct Rust2024IncompatiblePat {
|
2024-05-02 23:55:03 +00:00
|
|
|
#[subdiagnostic]
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) sugg: Rust2024IncompatiblePatSugg,
|
2024-05-02 23:55:03 +00:00
|
|
|
}
|
|
|
|
|
2024-06-04 05:28:09 +00:00
|
|
|
pub(crate) struct Rust2024IncompatiblePatSugg {
|
|
|
|
pub(crate) suggestion: Vec<(Span, String)>,
|
2024-05-02 23:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Subdiagnostic for Rust2024IncompatiblePatSugg {
|
|
|
|
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
|
|
|
self,
|
|
|
|
diag: &mut Diag<'_, G>,
|
|
|
|
_f: &F,
|
|
|
|
) {
|
|
|
|
let applicability =
|
|
|
|
if self.suggestion.iter().all(|(span, _)| span.can_be_used_for_suggestions()) {
|
|
|
|
Applicability::MachineApplicable
|
|
|
|
} else {
|
|
|
|
Applicability::MaybeIncorrect
|
|
|
|
};
|
|
|
|
diag.multipart_suggestion("desugar the match ergonomics", self.suggestion, applicability);
|
|
|
|
}
|
|
|
|
}
|