2023-12-10 20:42:30 +01:00
|
|
|
use crate::fluent_generated as fluent;
|
2024-02-23 14:37:48 +11:00
|
|
|
use rustc_errors::DiagArgValue;
|
2022-11-26 21:22:49 +01:00
|
|
|
use rustc_errors::{
|
2024-03-06 14:00:16 +11:00
|
|
|
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
|
|
|
SubdiagMessageOp, Subdiagnostic,
|
2022-11-26 21:22:49 +01:00
|
|
|
};
|
|
|
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
2022-08-26 16:38:21 +03:00
|
|
|
use rustc_middle::ty::{self, Ty};
|
2023-12-14 17:54:11 +01:00
|
|
|
use rustc_pattern_analysis::{errors::Uncovered, rustc::RustcMatchCheckCtxt};
|
2023-02-27 17:43:39 +00:00
|
|
|
use rustc_span::symbol::Symbol;
|
|
|
|
use rustc_span::Span;
|
2022-08-20 14:28:43 +03:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unconditional_recursion)]
|
2022-08-20 14:28:43 +03:00
|
|
|
#[help]
|
|
|
|
pub struct UnconditionalRecursion {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2022-11-26 21:22:49 +01:00
|
|
|
#[label(mir_build_unconditional_recursion_call_site_label)]
|
2022-08-20 14:28:43 +03:00
|
|
|
pub call_sites: Vec<Span>,
|
|
|
|
}
|
2022-08-20 23:54:58 +03:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
2024-01-30 15:44:37 +11:00
|
|
|
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
|
2022-08-20 23:54:58 +03:00
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2024-01-30 15:44:37 +11:00
|
|
|
pub function: String,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe)]
|
2022-08-20 23:54:58 +03:00
|
|
|
pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)]
|
2023-11-28 20:37:02 +01:00
|
|
|
#[help]
|
2024-01-30 15:44:37 +11:00
|
|
|
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
|
2022-08-20 23:54:58 +03:00
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2024-01-30 15:44:37 +11:00
|
|
|
pub function: String,
|
2024-02-23 14:37:48 +11:00
|
|
|
pub missing_target_features: DiagArgValue,
|
2023-11-28 20:37:02 +01:00
|
|
|
pub missing_target_features_count: usize,
|
|
|
|
#[note]
|
|
|
|
pub note: Option<()>,
|
2024-02-23 14:37:48 +11:00
|
|
|
pub build_target_features: DiagArgValue,
|
2023-11-28 20:37:02 +01:00
|
|
|
pub build_target_features_count: usize,
|
2023-10-26 15:39:25 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
2022-08-20 23:54:58 +03:00
|
|
|
}
|
2022-08-24 11:01:53 +03:00
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
2024-01-30 15:44:37 +11:00
|
|
|
pub struct CallToUnsafeFunctionRequiresUnsafe {
|
2022-08-24 11:01:53 +03:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2024-01-30 15:44:37 +11:00
|
|
|
pub function: String,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_nameless, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
2024-01-30 15:44:37 +11:00
|
|
|
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 11:01:53 +03:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2024-01-30 15:44:37 +11:00
|
|
|
pub function: String,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[diag(
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
code = E0133
|
2022-08-24 11:01:53 +03:00
|
|
|
)]
|
|
|
|
#[note]
|
|
|
|
pub struct CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_inline_assembly_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UseOfInlineAssemblyRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_inline_assembly_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_initializing_type_with_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct InitializingTypeWithRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[diag(
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
code = E0133
|
2022-08-24 11:01:53 +03:00
|
|
|
)]
|
|
|
|
#[note]
|
|
|
|
pub struct InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_mutable_static_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UseOfMutableStaticRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_mutable_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_extern_static_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UseOfExternStaticRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_deref_raw_pointer_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct DerefOfRawPointerRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_deref_raw_pointer_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_union_field_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct AccessToUnionFieldRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_union_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_mutation_of_layout_constrained_field_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[diag(
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
code = E0133
|
2022-08-24 11:01:53 +03:00
|
|
|
)]
|
|
|
|
#[note]
|
|
|
|
pub struct MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_borrow_of_layout_constrained_field_requires_unsafe, code = E0133)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[note]
|
|
|
|
pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
2022-08-24 11:01:53 +03:00
|
|
|
#[diag(
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
code = E0133
|
2022-08-24 11:01:53 +03:00
|
|
|
)]
|
|
|
|
#[note]
|
|
|
|
pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_call_to_fn_with_requires_unsafe, code = E0133)]
|
2023-11-28 20:37:02 +01:00
|
|
|
#[help]
|
2024-01-30 15:44:37 +11:00
|
|
|
pub struct CallToFunctionWithRequiresUnsafe {
|
2022-08-24 11:01:53 +03:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2024-01-30 15:44:37 +11:00
|
|
|
pub function: String,
|
2024-02-23 14:37:48 +11:00
|
|
|
pub missing_target_features: DiagArgValue,
|
2023-11-28 20:37:02 +01:00
|
|
|
pub missing_target_features_count: usize,
|
|
|
|
#[note]
|
|
|
|
pub note: Option<()>,
|
2024-02-23 14:37:48 +11:00
|
|
|
pub build_target_features: DiagArgValue,
|
2023-11-28 20:37:02 +01:00
|
|
|
pub build_target_features_count: usize,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
2023-11-28 20:37:02 +01:00
|
|
|
#[help]
|
2024-01-30 15:44:37 +11:00
|
|
|
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
2022-08-24 11:01:53 +03:00
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2024-01-30 15:44:37 +11:00
|
|
|
pub function: String,
|
2024-02-23 14:37:48 +11:00
|
|
|
pub missing_target_features: DiagArgValue,
|
2023-11-28 20:37:02 +01:00
|
|
|
pub missing_target_features_count: usize,
|
|
|
|
#[note]
|
|
|
|
pub note: Option<()>,
|
2024-02-23 14:37:48 +11:00
|
|
|
pub build_target_features: DiagArgValue,
|
2023-11-28 20:37:02 +01:00
|
|
|
pub build_target_features_count: usize,
|
2023-07-14 22:06:32 -04:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[label(mir_build_unsafe_not_inherited)]
|
|
|
|
pub struct UnsafeNotInheritedNote {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-24 11:01:53 +03:00
|
|
|
}
|
2022-08-24 20:16:50 +03:00
|
|
|
|
2023-10-26 15:39:25 +00:00
|
|
|
pub struct UnsafeNotInheritedLintNote {
|
|
|
|
pub signature_span: Span,
|
|
|
|
pub body_span: Span,
|
|
|
|
}
|
|
|
|
|
2024-03-06 14:00:16 +11: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 16:44:30 +11:00
|
|
|
self,
|
2024-02-23 10:20:45 +11:00
|
|
|
diag: &mut Diag<'_, 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 16:44:30 +11:00
|
|
|
_f: F,
|
|
|
|
) {
|
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 20:16:50 +03:00
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unused_unsafe)]
|
2022-08-24 20:16:50 +03:00
|
|
|
pub struct UnusedUnsafe {
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub enclosing: Option<UnusedUnsafeEnclosing>,
|
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-24 20:16:50 +03:00
|
|
|
pub enum UnusedUnsafeEnclosing {
|
2022-11-26 21:22:49 +01:00
|
|
|
#[label(mir_build_unused_unsafe_enclosing_block_label)]
|
2022-08-24 20:16:50 +03:00
|
|
|
Block {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
2022-08-26 16:38:21 +03:00
|
|
|
|
|
|
|
pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
|
2023-12-14 17:54:11 +01:00
|
|
|
pub cx: &'m RustcMatchCheckCtxt<'p, 'tcx>,
|
2022-08-26 16:38:21 +03:00
|
|
|
pub expr_span: Span,
|
|
|
|
pub span: Span,
|
|
|
|
pub ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
2024-03-06 11:02:56 +11:00
|
|
|
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
|
|
|
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'_, G> {
|
2024-02-23 10:20:45 +11:00
|
|
|
let mut diag =
|
|
|
|
Diag::new(dcx, level, fluent::mir_build_non_exhaustive_patterns_type_not_empty);
|
2023-12-24 09:08:41 +11:00
|
|
|
diag.span(self.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-14 10:57:07 +11:00
|
|
|
diag.code(E0004);
|
2022-08-26 16:38:21 +03:00
|
|
|
let peeled_ty = self.ty.peel_refs();
|
2023-12-24 09:08:41 +11:00
|
|
|
diag.arg("ty", self.ty);
|
|
|
|
diag.arg("peeled_ty", peeled_ty);
|
2022-08-26 16:38:21 +03: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 10:13:02 +01:00
|
|
|
diag.span_note(span, fluent::mir_build_def_note);
|
2022-08-26 16:38:21 +03:00
|
|
|
}
|
|
|
|
|
2023-04-15 20:49:54 +02: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 16:38:21 +03:00
|
|
|
if is_variant_list_non_exhaustive {
|
2022-10-13 10:13:02 +01:00
|
|
|
diag.note(fluent::mir_build_non_exhaustive_type_note);
|
2022-08-26 16:38:21 +03:00
|
|
|
} else {
|
2022-10-13 10:13:02 +01:00
|
|
|
diag.note(fluent::mir_build_type_note);
|
2022-08-26 16:38:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
|
2022-11-26 21:22:49 +01:00
|
|
|
if !sub_ty.is_inhabited_from(self.cx.tcx, self.cx.module, self.cx.param_env) {
|
2022-10-13 10:13:02 +01:00
|
|
|
diag.note(fluent::mir_build_reference_note);
|
2022-08-26 16:38:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut suggestion = None;
|
|
|
|
let sm = self.cx.tcx.sess.source_map();
|
|
|
|
if self.span.eq_ctxt(self.expr_span) {
|
|
|
|
// Get the span for the empty match body `{}`.
|
|
|
|
let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.span) {
|
2023-07-25 23:17:39 +02:00
|
|
|
(format!("\n{snippet}"), " ")
|
2022-08-26 16:38:21 +03:00
|
|
|
} else {
|
|
|
|
(" ".to_string(), "")
|
|
|
|
};
|
|
|
|
suggestion = Some((
|
|
|
|
self.span.shrink_to_hi().with_hi(self.expr_span.hi()),
|
2023-07-25 23:17:39 +02:00
|
|
|
format!(" {{{indentation}{more}_ => todo!(),{indentation}}}",),
|
2022-08-26 16:38:21 +03:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some((span, sugg)) = suggestion {
|
|
|
|
diag.span_suggestion_verbose(
|
|
|
|
span,
|
2022-10-13 10:13:02 +01:00
|
|
|
fluent::mir_build_suggestion,
|
2022-08-26 16:38:21 +03:00
|
|
|
sugg,
|
|
|
|
Applicability::HasPlaceholders,
|
|
|
|
);
|
|
|
|
} else {
|
2022-10-13 10:13:02 +01:00
|
|
|
diag.help(fluent::mir_build_help);
|
2022-08-26 16:38:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
2022-08-26 19:30:33 +03:00
|
|
|
|
2023-06-28 01:49:21 -04:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[note(mir_build_non_exhaustive_match_all_arms_guarded)]
|
|
|
|
pub struct NonExhaustiveMatchAllArmsGuarded;
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_static_in_pattern, code = E0158)]
|
2022-08-26 19:30:33 +03:00
|
|
|
pub struct StaticInPattern {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_assoc_const_in_pattern, code = E0158)]
|
2022-08-26 19:30:33 +03:00
|
|
|
pub struct AssocConstInPattern {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_const_param_in_pattern, code = E0158)]
|
2022-08-26 19:30:33 +03:00
|
|
|
pub struct ConstParamInPattern {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_non_const_path, code = E0080)]
|
2022-08-26 19:30:33 +03:00
|
|
|
pub struct NonConstPath {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-08-27 22:06:06 +03:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_unreachable_pattern)]
|
2022-08-27 22:06:06 +03:00
|
|
|
pub struct UnreachablePattern {
|
|
|
|
#[label]
|
|
|
|
pub span: Option<Span>,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[label(mir_build_catchall_label)]
|
2022-08-27 22:06:06 +03:00
|
|
|
pub catchall: Option<Span>,
|
|
|
|
}
|
2022-08-27 22:17:10 +03:00
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_const_pattern_depends_on_generic_parameter)]
|
2022-08-27 22:17:10 +03:00
|
|
|
pub struct ConstPatternDependsOnGenericParameter {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-08-27 22:25:09 +03:00
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_could_not_eval_const_pattern)]
|
2022-08-27 22:25:09 +03:00
|
|
|
pub struct CouldNotEvalConstPattern {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-08-27 22:48:18 +03:00
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper, code = E0030)]
|
2022-08-27 22:48:18 +03:00
|
|
|
pub struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(mir_build_teach_note)]
|
2022-08-27 22:48:18 +03:00
|
|
|
pub teach: Option<()>,
|
|
|
|
}
|
|
|
|
|
2023-01-09 07:10:17 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_literal_in_range_out_of_bounds)]
|
|
|
|
pub struct LiteralOutOfRange<'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
pub ty: Ty<'tcx>,
|
2023-10-11 04:54:21 +02:00
|
|
|
pub min: i128,
|
2023-01-09 07:10:17 +00:00
|
|
|
pub max: u128,
|
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_lower_range_bound_must_be_less_than_upper, code = E0579)]
|
2022-08-27 22:48:18 +03:00
|
|
|
pub struct LowerRangeBoundMustBeLessThanUpper {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-08-28 21:48:09 +03:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_leading_irrefutable_let_patterns)]
|
2022-08-28 21:48:09 +03:00
|
|
|
#[note]
|
|
|
|
#[help]
|
|
|
|
pub struct LeadingIrrefutableLetPatterns {
|
|
|
|
pub count: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_trailing_irrefutable_let_patterns)]
|
2022-08-28 21:48:09 +03:00
|
|
|
#[note]
|
|
|
|
#[help]
|
|
|
|
pub struct TrailingIrrefutableLetPatterns {
|
|
|
|
pub count: usize,
|
|
|
|
}
|
2022-08-29 10:06:50 +03: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_bindings_with_variant_name, code = E0170)]
|
2022-08-29 10:06:50 +03:00
|
|
|
pub struct BindingsWithVariantName {
|
2023-02-27 17:43:39 +00:00
|
|
|
#[suggestion(code = "{ty_path}::{name}", applicability = "machine-applicable")]
|
2022-08-29 10:06:50 +03:00
|
|
|
pub suggestion: Option<Span>,
|
|
|
|
pub ty_path: String,
|
2023-02-27 17:43:39 +00:00
|
|
|
pub name: Symbol,
|
2022-08-29 11:21:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_if_let)]
|
2022-08-29 11:21:25 +03:00
|
|
|
#[note]
|
|
|
|
#[help]
|
|
|
|
pub struct IrrefutableLetPatternsIfLet {
|
|
|
|
pub count: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_if_let_guard)]
|
2022-08-29 11:21:25 +03:00
|
|
|
#[note]
|
|
|
|
#[help]
|
|
|
|
pub struct IrrefutableLetPatternsIfLetGuard {
|
|
|
|
pub count: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_let_else)]
|
2022-08-29 11:21:25 +03:00
|
|
|
#[note]
|
|
|
|
#[help]
|
|
|
|
pub struct IrrefutableLetPatternsLetElse {
|
|
|
|
pub count: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-11-26 21:22:49 +01:00
|
|
|
#[diag(mir_build_irrefutable_let_patterns_while_let)]
|
2022-08-29 11:21:25 +03:00
|
|
|
#[note]
|
|
|
|
#[help]
|
|
|
|
pub struct IrrefutableLetPatternsWhileLet {
|
|
|
|
pub count: usize,
|
|
|
|
}
|
2022-08-30 20:01:28 +03:00
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_borrow_of_moved_value)]
|
2022-08-30 20:01:28 +03:00
|
|
|
pub struct BorrowOfMovedValue<'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
2022-10-13 10:13:02 +01:00
|
|
|
#[label(mir_build_occurs_because_label)]
|
2022-08-30 20:01:28 +03:00
|
|
|
pub binding_span: Span,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[label(mir_build_value_borrowed_label)]
|
2022-08-30 20:01:28 +03:00
|
|
|
pub conflicts_ref: Vec<Span>,
|
2023-02-27 17:43:39 +00:00
|
|
|
pub name: Symbol,
|
2022-08-30 20:01:28 +03:00
|
|
|
pub ty: Ty<'tcx>,
|
|
|
|
#[suggestion(code = "ref ", applicability = "machine-applicable")]
|
|
|
|
pub suggest_borrowing: Option<Span>,
|
|
|
|
}
|
2022-08-30 20:38:10 +03:00
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_multiple_mut_borrows)]
|
2022-08-30 20:38:10 +03:00
|
|
|
pub struct MultipleMutBorrows {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-12-17 19:20:44 +01:00
|
|
|
#[subdiagnostic]
|
2023-04-10 22:02:52 +02:00
|
|
|
pub occurrences: Vec<Conflict>,
|
2023-01-17 13:48:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_already_borrowed)]
|
|
|
|
pub struct AlreadyBorrowed {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
2023-04-10 22:02:52 +02:00
|
|
|
pub occurrences: Vec<Conflict>,
|
2023-01-17 13:48:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_already_mut_borrowed)]
|
|
|
|
pub struct AlreadyMutBorrowed {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
2023-04-10 22:02:52 +02:00
|
|
|
pub occurrences: Vec<Conflict>,
|
2023-01-17 13:48:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_moved_while_borrowed)]
|
|
|
|
pub struct MovedWhileBorrowed {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
2023-04-10 22:02:52 +02:00
|
|
|
pub occurrences: Vec<Conflict>,
|
2022-08-30 20:38:10 +03:00
|
|
|
}
|
|
|
|
|
2022-11-26 21:22:49 +01:00
|
|
|
#[derive(Subdiagnostic)]
|
2023-01-17 13:48:43 +01:00
|
|
|
pub enum Conflict {
|
|
|
|
#[label(mir_build_mutable_borrow)]
|
|
|
|
Mut {
|
2022-08-30 20:38:10 +03:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
2023-02-27 17:43:39 +00:00
|
|
|
name: Symbol,
|
2022-08-30 20:38:10 +03:00
|
|
|
},
|
2023-01-17 13:48:43 +01:00
|
|
|
#[label(mir_build_borrow)]
|
|
|
|
Ref {
|
2022-08-30 20:38:10 +03:00
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
2023-02-27 17:43:39 +00:00
|
|
|
name: Symbol,
|
2022-08-30 20:38:10 +03:00
|
|
|
},
|
2023-01-17 13:48:43 +01:00
|
|
|
#[label(mir_build_moved)]
|
2022-08-30 20:38:10 +03:00
|
|
|
Moved {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
2023-02-27 17:43:39 +00:00
|
|
|
name: Symbol,
|
2022-08-30 20:38:10 +03:00
|
|
|
},
|
|
|
|
}
|
2022-12-20 00:28:33 +01:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_union_pattern)]
|
|
|
|
pub struct UnionPattern {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_type_not_structural)]
|
2023-03-27 10:14:08 -04:00
|
|
|
#[note(mir_build_type_not_structural_tip)]
|
|
|
|
#[note(mir_build_type_not_structural_more_info)]
|
2022-12-20 00:28:33 +01:00
|
|
|
pub struct TypeNotStructural<'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub non_sm_ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
2024-02-08 20:08:19 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_non_partial_eq_match)]
|
|
|
|
pub struct TypeNotPartialEq<'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub non_peq_ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
2022-12-20 00:28:33 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_invalid_pattern)]
|
|
|
|
pub struct InvalidPattern<'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub non_sm_ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_unsized_pattern)]
|
|
|
|
pub struct UnsizedPattern<'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub non_sm_ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
2023-09-30 08:15:34 +02:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_nan_pattern)]
|
|
|
|
#[note]
|
|
|
|
#[help]
|
|
|
|
pub struct NaNPattern {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-12-20 00:28:33 +01:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
|
|
|
#[diag(mir_build_pointer_pattern)]
|
|
|
|
pub struct PointerPattern;
|
|
|
|
|
2024-01-05 17:21:09 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(mir_build_non_empty_never_pattern)]
|
|
|
|
#[note]
|
|
|
|
pub struct NonEmptyNeverPattern<'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
pub ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
2022-12-20 00:28:33 +01:00
|
|
|
#[derive(LintDiagnostic)]
|
|
|
|
#[diag(mir_build_indirect_structural_match)]
|
2023-03-27 10:14:08 -04:00
|
|
|
#[note(mir_build_type_not_structural_tip)]
|
|
|
|
#[note(mir_build_type_not_structural_more_info)]
|
2022-12-20 00:28:33 +01:00
|
|
|
pub struct IndirectStructuralMatch<'tcx> {
|
|
|
|
pub non_sm_ty: Ty<'tcx>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
|
|
|
#[diag(mir_build_nontrivial_structural_match)]
|
2023-03-27 10:14:08 -04:00
|
|
|
#[note(mir_build_type_not_structural_tip)]
|
|
|
|
#[note(mir_build_type_not_structural_more_info)]
|
2022-12-20 00:28:33 +01:00
|
|
|
pub struct NontrivialStructuralMatch<'tcx> {
|
|
|
|
pub non_sm_ty: Ty<'tcx>,
|
2023-09-16 14:15:48 +02:00
|
|
|
}
|
|
|
|
|
2022-12-23 21:02:23 +01: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-14 10:57:07 +11:00
|
|
|
#[diag(mir_build_pattern_not_covered, code = E0005)]
|
2022-12-23 21:02:23 +01:00
|
|
|
pub(crate) struct PatternNotCovered<'s, 'tcx> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub origin: &'s str,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub uncovered: Uncovered<'tcx>,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub inform: Option<Inform>,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub interpreted_as_const: Option<InterpretedAsConst>,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub adt_defined_here: Option<AdtDefinedHere<'tcx>>,
|
2023-04-09 08:09:43 +00:00
|
|
|
#[note(mir_build_privately_uninhabited)]
|
|
|
|
pub witness_1_is_privately_uninhabited: Option<()>,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(mir_build_pattern_ty)]
|
2022-12-23 21:02:23 +01:00
|
|
|
pub _p: (),
|
|
|
|
pub pattern_ty: Ty<'tcx>,
|
|
|
|
#[subdiagnostic]
|
2022-12-23 22:23:37 +01:00
|
|
|
pub let_suggestion: Option<SuggestLet>,
|
2022-12-23 21:02:23 +01:00
|
|
|
#[subdiagnostic]
|
2023-01-13 14:14:26 +13:00
|
|
|
pub misc_suggestion: Option<MiscPatternSuggestion>,
|
2022-12-23 21:02:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[note(mir_build_inform_irrefutable)]
|
|
|
|
#[note(mir_build_more_information)]
|
|
|
|
pub struct Inform;
|
|
|
|
|
|
|
|
pub struct AdtDefinedHere<'tcx> {
|
|
|
|
pub adt_def_span: Span,
|
|
|
|
pub ty: Ty<'tcx>,
|
|
|
|
pub variants: Vec<Variant>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Variant {
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2024-03-06 14:00:16 +11: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 16:44:30 +11:00
|
|
|
self,
|
2024-02-23 10:20:45 +11:00
|
|
|
diag: &mut Diag<'_, 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 16:44:30 +11:00
|
|
|
_f: F,
|
|
|
|
) {
|
2023-12-24 09:08:41 +11:00
|
|
|
diag.arg("ty", self.ty);
|
2022-12-23 21:02:23 +01:00
|
|
|
let mut spans = MultiSpan::from(self.adt_def_span);
|
|
|
|
|
|
|
|
for Variant { span } in self.variants {
|
2022-10-13 10:13:02 +01:00
|
|
|
spans.push_span_label(span, fluent::mir_build_variant_defined_here);
|
2022-12-23 21:02:23 +01:00
|
|
|
}
|
|
|
|
|
2022-10-13 10:13:02 +01:00
|
|
|
diag.span_note(spans, fluent::mir_build_adt_defined_here);
|
2022-12-23 21:02:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[suggestion(
|
|
|
|
mir_build_interpreted_as_const,
|
|
|
|
code = "{variable}_var",
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
)]
|
|
|
|
#[label(mir_build_confused)]
|
|
|
|
pub struct InterpretedAsConst {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub variable: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-12-23 22:23:37 +01:00
|
|
|
pub enum SuggestLet {
|
2022-12-23 21:02:23 +01:00
|
|
|
#[multipart_suggestion(mir_build_suggest_if_let, applicability = "has-placeholders")]
|
2022-12-23 22:23:37 +01:00
|
|
|
If {
|
2022-12-23 21:02:23 +01:00
|
|
|
#[suggestion_part(code = "if ")]
|
|
|
|
start_span: Span,
|
|
|
|
#[suggestion_part(code = " {{ todo!() }}")]
|
|
|
|
semi_span: Span,
|
|
|
|
count: usize,
|
|
|
|
},
|
2022-12-23 22:23:37 +01:00
|
|
|
#[suggestion(
|
|
|
|
mir_build_suggest_let_else,
|
|
|
|
code = " else {{ todo!() }}",
|
|
|
|
applicability = "has-placeholders"
|
|
|
|
)]
|
|
|
|
Else {
|
|
|
|
#[primary_span]
|
2022-12-23 21:02:23 +01:00
|
|
|
end_span: Span,
|
|
|
|
count: usize,
|
|
|
|
},
|
|
|
|
}
|
2023-01-13 14:14:26 +13:00
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub enum MiscPatternSuggestion {
|
|
|
|
#[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)]
|
|
|
|
pub struct RustcBoxAttributeError {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub reason: RustcBoxAttrReason,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub enum RustcBoxAttrReason {
|
|
|
|
#[note(mir_build_attributes)]
|
|
|
|
Attributes,
|
|
|
|
#[note(mir_build_not_box)]
|
|
|
|
NotBoxNew,
|
|
|
|
#[note(mir_build_missing_box)]
|
|
|
|
MissingBox,
|
|
|
|
}
|