2022-08-17 23:51:01 +09:00
|
|
|
//! Errors emitted by ast_passes.
|
|
|
|
|
|
2023-02-25 13:53:42 +00:00
|
|
|
use rustc_ast::ParamKindOrd;
|
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
|
|
|
use rustc_errors::codes::*;
|
2024-03-06 14:00:16 +11:00
|
|
|
use rustc_errors::{Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
|
2022-09-18 11:45:41 -04:00
|
|
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
2023-02-25 13:53:42 +00:00
|
|
|
use rustc_span::symbol::Ident;
|
|
|
|
|
use rustc_span::{Span, Symbol};
|
2022-08-17 23:51:01 +09:00
|
|
|
|
2023-02-25 13:53:42 +00:00
|
|
|
use crate::fluent_generated as fluent;
|
2022-08-17 23:51:01 +09:00
|
|
|
|
2022-09-18 11:45:41 -04: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(ast_passes_visibility_not_permitted, code = E0449)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct VisibilityNotPermitted {
|
2022-08-18 04:36:57 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[subdiagnostic]
|
2023-04-03 21:09:06 -05:00
|
|
|
pub note: VisibilityNotPermittedNote,
|
2024-04-12 12:40:11 +09:00
|
|
|
#[suggestion(
|
|
|
|
|
ast_passes_remove_qualifier_sugg,
|
|
|
|
|
code = "",
|
|
|
|
|
applicability = "machine-applicable"
|
|
|
|
|
)]
|
|
|
|
|
pub remove_qualifier_sugg: Span,
|
2022-08-18 04:36:57 +09:00
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:47:31 -04:00
|
|
|
#[derive(Subdiagnostic)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) enum VisibilityNotPermittedNote {
|
2023-04-03 21:09:06 -05:00
|
|
|
#[note(ast_passes_enum_variant)]
|
|
|
|
|
EnumVariant,
|
|
|
|
|
#[note(ast_passes_trait_impl)]
|
|
|
|
|
TraitImpl,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(ast_passes_individual_impl_items)]
|
2022-08-18 04:36:57 +09:00
|
|
|
IndividualImplItems,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(ast_passes_individual_foreign_items)]
|
2022-08-18 04:36:57 +09:00
|
|
|
IndividualForeignItems,
|
|
|
|
|
}
|
2022-08-18 16:49:52 +09:00
|
|
|
|
2022-09-18 11:45:41 -04: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(ast_passes_trait_fn_const, code = E0379)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct TraitFnConst {
|
2022-08-18 16:57:25 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
2024-01-02 00:26:50 +01:00
|
|
|
pub in_impl: bool,
|
2024-01-02 00:57:30 +01:00
|
|
|
#[label(ast_passes_const_context_label)]
|
|
|
|
|
pub const_context_label: Option<Span>,
|
|
|
|
|
#[suggestion(ast_passes_remove_const_sugg, code = "")]
|
|
|
|
|
pub remove_const_sugg: (Span, Applicability),
|
|
|
|
|
pub requires_multiple_changes: bool,
|
|
|
|
|
#[suggestion(
|
|
|
|
|
ast_passes_make_impl_const_sugg,
|
|
|
|
|
code = "const ",
|
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
|
)]
|
|
|
|
|
pub make_impl_const_sugg: Option<Span>,
|
|
|
|
|
#[suggestion(
|
|
|
|
|
ast_passes_make_trait_const_sugg,
|
|
|
|
|
code = "#[const_trait]\n",
|
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
|
)]
|
|
|
|
|
pub make_trait_const_sugg: Option<Span>,
|
2022-08-18 16:57:25 +09:00
|
|
|
}
|
2022-08-18 17:38:11 +09:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2023-12-20 15:06:36 +08:00
|
|
|
#[diag(ast_passes_forbidden_bound)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ForbiddenBound {
|
2022-08-18 17:38:11 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub spans: Vec<Span>,
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-20 17:58:05 -04:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_forbidden_const_param)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ForbiddenConstParam {
|
2024-07-20 17:58:05 -04:00
|
|
|
#[primary_span]
|
|
|
|
|
pub const_param_spans: Vec<Span>,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_fn_param_too_many)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnParamTooMany {
|
2022-08-18 17:38:11 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub max_num_args: usize,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_fn_param_c_var_args_not_last)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnParamCVarArgsNotLast {
|
2022-08-18 17:38:11 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
2022-08-18 17:46:01 +09:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_fn_param_doc_comment)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnParamDocComment {
|
2022-08-18 17:46:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_fn_param_forbidden_attr)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnParamForbiddenAttr {
|
2022-08-18 17:46:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
2022-08-18 18:20:14 +09:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_fn_param_forbidden_self)]
|
2022-08-18 18:20:14 +09:00
|
|
|
#[note]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnParamForbiddenSelf {
|
2022-08-18 18:20:14 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
2022-08-19 02:43:01 +09:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_forbidden_default)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ForbiddenDefault {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub def_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_assoc_const_without_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AssocConstWithoutBody {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
|
|
|
|
pub replace_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_assoc_fn_without_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AssocFnWithoutBody {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
|
|
|
|
pub replace_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_assoc_type_without_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AssocTypeWithoutBody {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
|
|
|
|
pub replace_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_const_without_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ConstWithoutBody {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
|
|
|
|
pub replace_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_static_without_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct StaticWithoutBody {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
|
|
|
|
pub replace_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_ty_alias_without_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct TyAliasWithoutBody {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
|
|
|
|
pub replace_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(ast_passes_fn_without_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnWithoutBody {
|
2022-08-19 02:43:01 +09:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
|
|
|
|
pub replace_span: Span,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub extern_block_suggestion: Option<ExternBlockSuggestion>,
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-19 13:52:15 +01:00
|
|
|
#[derive(Subdiagnostic)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) enum ExternBlockSuggestion {
|
2023-01-19 13:52:15 +01:00
|
|
|
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
|
|
|
|
|
Implicit {
|
|
|
|
|
#[suggestion_part(code = "extern {{")]
|
|
|
|
|
start_span: Span,
|
|
|
|
|
#[suggestion_part(code = " }}")]
|
|
|
|
|
end_span: Span,
|
|
|
|
|
},
|
|
|
|
|
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
|
|
|
|
|
Explicit {
|
|
|
|
|
#[suggestion_part(code = "extern \"{abi}\" {{")]
|
|
|
|
|
start_span: Span,
|
|
|
|
|
#[suggestion_part(code = " }}")]
|
|
|
|
|
end_span: Span,
|
|
|
|
|
abi: Symbol,
|
|
|
|
|
},
|
2022-08-19 02:43:01 +09:00
|
|
|
}
|
2023-02-25 13:53:42 +00:00
|
|
|
|
2024-05-27 15:35:34 -03:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_extern_invalid_safety)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct InvalidSafetyOnExtern {
|
2024-05-27 15:35:34 -03:00
|
|
|
#[primary_span]
|
|
|
|
|
pub item_span: Span,
|
2024-06-26 08:44:59 +08:00
|
|
|
#[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
|
2024-06-28 23:14:09 -03:00
|
|
|
pub block: Option<Span>,
|
2024-05-27 15:35:34 -03:00
|
|
|
}
|
|
|
|
|
|
2024-06-20 16:19:43 -03:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_item_invalid_safety)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct InvalidSafetyOnItem {
|
2024-06-20 16:19:43 -03:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_bare_fn_invalid_safety)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct InvalidSafetyOnBareFn {
|
2024-06-20 16:19:43 -03:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-18 18:02:09 -04:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_unsafe_static)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct UnsafeStatic {
|
2024-07-18 18:02:09 -04:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 13:53:42 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_bound_in_context)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct BoundInContext<'a> {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub ctx: &'a str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_extern_types_cannot)]
|
|
|
|
|
#[note(ast_passes_extern_keyword_link)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ExternTypesCannotHave<'a> {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub descr: &'a str,
|
|
|
|
|
pub remove_descr: &'a str,
|
|
|
|
|
#[label]
|
|
|
|
|
pub block_span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_body_in_extern)]
|
|
|
|
|
#[note(ast_passes_extern_keyword_link)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct BodyInExtern<'a> {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label(ast_passes_cannot_have)]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label(ast_passes_invalid)]
|
|
|
|
|
pub body: Span,
|
|
|
|
|
#[label(ast_passes_existing)]
|
|
|
|
|
pub block: Span,
|
|
|
|
|
pub kind: &'a str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_fn_body_extern)]
|
|
|
|
|
#[help]
|
|
|
|
|
#[note(ast_passes_extern_keyword_link)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnBodyInExtern {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label(ast_passes_cannot_have)]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = ";", applicability = "maybe-incorrect")]
|
|
|
|
|
pub body: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub block: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_extern_fn_qualifiers)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FnQualifierInExtern {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
2024-04-03 02:43:54 +02:00
|
|
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
2023-02-25 13:53:42 +00:00
|
|
|
pub span: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub block: Span,
|
2024-10-11 11:30:03 -04:00
|
|
|
pub kw: &'static str,
|
2023-02-25 13:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_extern_item_ascii)]
|
|
|
|
|
#[note]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ExternItemAscii {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub block: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_bad_c_variadic)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct BadCVariadic {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
2023-10-29 17:04:52 -04:00
|
|
|
pub span: Vec<Span>,
|
2023-02-25 13:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_item_underscore)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ItemUnderscore<'a> {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub kind: &'a str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_nomangle_ascii, code = E0754)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct NoMangleAscii {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_module_nonascii, code = E0754)]
|
2023-02-25 13:53:42 +00:00
|
|
|
#[help]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ModuleNonAscii {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub name: Symbol,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_auto_generic, code = E0567)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AutoTraitGeneric {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub ident: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_auto_super_lifetime, code = E0568)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AutoTraitBounds {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub ident: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_auto_items, code = E0380)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AutoTraitItems {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub spans: Vec<Span>,
|
|
|
|
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
|
|
|
|
pub total: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub ident: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_generic_before_constraints)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ArgsBeforeConstraint {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub arg_spans: Vec<Span>,
|
|
|
|
|
#[label(ast_passes_constraints)]
|
|
|
|
|
pub constraints: Span,
|
|
|
|
|
#[label(ast_passes_args)]
|
|
|
|
|
pub args: Span,
|
|
|
|
|
#[suggestion(code = "{suggestion}", applicability = "machine-applicable", style = "verbose")]
|
|
|
|
|
pub data: Span,
|
|
|
|
|
pub suggestion: String,
|
|
|
|
|
pub constraint_len: usize,
|
|
|
|
|
pub args_len: usize,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub constraint_spans: EmptyLabelManySpans,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub arg_spans2: EmptyLabelManySpans,
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct EmptyLabelManySpans(pub Vec<Span>);
|
2023-02-25 13:53:42 +00:00
|
|
|
|
|
|
|
|
// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
|
2024-03-06 14:00:16 +11:00
|
|
|
impl Subdiagnostic for EmptyLabelManySpans {
|
|
|
|
|
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>,
|
2024-04-18 19:18:35 +00:00
|
|
|
_: &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 16:44:30 +11:00
|
|
|
) {
|
2023-02-25 13:53:42 +00:00
|
|
|
diag.span_labels(self.0, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_pattern_in_fn_pointer, code = E0561)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct PatternFnPointer {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_trait_object_single_bound, code = E0226)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct TraitObjectBound {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_impl_trait_path, code = E0667)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ImplTraitPath {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_nested_impl_trait, code = E0666)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct NestedImplTrait {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label(ast_passes_outer)]
|
|
|
|
|
pub outer: Span,
|
|
|
|
|
#[label(ast_passes_inner)]
|
|
|
|
|
pub inner: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_at_least_one_trait)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AtLeastOneTrait {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_out_of_order_params)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct OutOfOrderParams<'a> {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub spans: Vec<Span>,
|
|
|
|
|
#[suggestion(code = "{ordered_params}", applicability = "machine-applicable")]
|
|
|
|
|
pub sugg_span: Span,
|
|
|
|
|
pub param_ord: &'a ParamKindOrd,
|
|
|
|
|
pub max_param: &'a ParamKindOrd,
|
|
|
|
|
pub ordered_params: &'a str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_obsolete_auto)]
|
|
|
|
|
#[help]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ObsoleteAuto {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_unsafe_negative_impl, code = E0198)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct UnsafeNegativeImpl {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label(ast_passes_negative)]
|
|
|
|
|
pub negative: Span,
|
|
|
|
|
#[label(ast_passes_unsafe)]
|
|
|
|
|
pub r#unsafe: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_inherent_cannot_be)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct InherentImplCannot<'a> {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label(ast_passes_because)]
|
|
|
|
|
pub annotation_span: Span,
|
|
|
|
|
pub annotation: &'a str,
|
|
|
|
|
#[label(ast_passes_type)]
|
|
|
|
|
pub self_ty: Span,
|
|
|
|
|
#[note(ast_passes_only_trait)]
|
2024-08-21 00:57:58 -04:00
|
|
|
pub only_trait: bool,
|
2023-02-25 13:53:42 +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-14 10:57:07 +11:00
|
|
|
#[diag(ast_passes_inherent_cannot_be, code = E0197)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct InherentImplCannotUnsafe<'a> {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[label(ast_passes_because)]
|
|
|
|
|
pub annotation_span: Span,
|
|
|
|
|
pub annotation: &'a str,
|
|
|
|
|
#[label(ast_passes_type)]
|
|
|
|
|
pub self_ty: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_unsafe_item)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct UnsafeItem {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub kind: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-03 22:27:57 -03:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_missing_unsafe_on_extern)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct MissingUnsafeOnExtern {
|
2024-06-03 22:27:57 -03:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 13:53:42 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_fieldless_union)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FieldlessUnion {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2023-08-09 16:44:06 +02:00
|
|
|
#[diag(ast_passes_where_clause_after_type_alias)]
|
2023-02-25 13:53:42 +00:00
|
|
|
#[note]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct WhereClauseAfterTypeAlias {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
2023-08-09 16:44:06 +02:00
|
|
|
#[help]
|
2024-08-21 00:57:58 -04:00
|
|
|
pub help: bool,
|
2023-08-09 16:44:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_where_clause_before_type_alias)]
|
|
|
|
|
#[note]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct WhereClauseBeforeTypeAlias {
|
2023-08-09 16:44:06 +02:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub sugg: WhereClauseBeforeTypeAliasSugg,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2024-02-20 04:41:01 +01:00
|
|
|
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) enum WhereClauseBeforeTypeAliasSugg {
|
2024-02-20 04:41:01 +01:00
|
|
|
#[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
|
|
|
|
|
Remove {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
span: Span,
|
|
|
|
|
},
|
|
|
|
|
#[multipart_suggestion(
|
|
|
|
|
ast_passes_move_suggestion,
|
|
|
|
|
applicability = "machine-applicable",
|
|
|
|
|
style = "verbose"
|
|
|
|
|
)]
|
|
|
|
|
Move {
|
|
|
|
|
#[suggestion_part(code = "")]
|
|
|
|
|
left: Span,
|
|
|
|
|
snippet: String,
|
|
|
|
|
#[suggestion_part(code = "{snippet}")]
|
|
|
|
|
right: Span,
|
|
|
|
|
},
|
2023-02-25 13:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_generic_default_trailing)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct GenericDefaultTrailing {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_nested_lifetimes, code = E0316)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct NestedLifetimes {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_optional_trait_supertrait)]
|
|
|
|
|
#[note]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct OptionalTraitSupertrait {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub path_str: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_optional_trait_object)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct OptionalTraitObject {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-18 17:55:55 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_const_bound_trait_object)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ConstBoundTraitObject {
|
2023-12-18 17:55:55 +01:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 16:37:25 +01:00
|
|
|
// FIXME(effects): Consider making the note/reason the message of the diagnostic.
|
|
|
|
|
// FIXME(effects): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
|
2023-02-25 13:53:42 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_tilde_const_disallowed)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct TildeConstDisallowed {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub reason: TildeConstReason,
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-09 09:54:19 +00:00
|
|
|
#[derive(Subdiagnostic, Copy, Clone)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) enum TildeConstReason {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[note(ast_passes_closure)]
|
|
|
|
|
Closure,
|
|
|
|
|
#[note(ast_passes_function)]
|
|
|
|
|
Function {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
ident: Span,
|
|
|
|
|
},
|
2023-11-11 15:01:58 +01:00
|
|
|
#[note(ast_passes_trait)]
|
|
|
|
|
Trait {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
span: Span,
|
|
|
|
|
},
|
2023-12-18 01:10:16 +01:00
|
|
|
#[note(ast_passes_trait_impl)]
|
|
|
|
|
TraitImpl {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
span: Span,
|
|
|
|
|
},
|
2023-11-11 15:01:58 +01:00
|
|
|
#[note(ast_passes_impl)]
|
|
|
|
|
Impl {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
span: Span,
|
|
|
|
|
},
|
2024-01-12 16:37:25 +01:00
|
|
|
#[note(ast_passes_trait_assoc_ty)]
|
|
|
|
|
TraitAssocTy {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
span: Span,
|
|
|
|
|
},
|
|
|
|
|
#[note(ast_passes_trait_impl_assoc_ty)]
|
|
|
|
|
TraitImplAssocTy {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
span: Span,
|
|
|
|
|
},
|
|
|
|
|
#[note(ast_passes_inherent_assoc_ty)]
|
|
|
|
|
InherentAssocTy {
|
|
|
|
|
#[primary_span]
|
|
|
|
|
span: Span,
|
|
|
|
|
},
|
2023-11-11 15:01:58 +01:00
|
|
|
#[note(ast_passes_object)]
|
|
|
|
|
TraitObject,
|
|
|
|
|
#[note(ast_passes_item)]
|
|
|
|
|
Item,
|
2023-02-25 13:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2024-09-11 18:22:37 -04:00
|
|
|
#[diag(ast_passes_const_and_coroutine)]
|
|
|
|
|
pub(crate) struct ConstAndCoroutine {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub spans: Vec<Span>,
|
|
|
|
|
#[label(ast_passes_const)]
|
2024-09-11 18:22:37 -04:00
|
|
|
pub const_span: Span,
|
|
|
|
|
#[label(ast_passes_coroutine)]
|
|
|
|
|
pub coroutine_span: Span,
|
2023-02-25 13:53:42 +00:00
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
2024-09-11 18:22:37 -04:00
|
|
|
pub coroutine_kind: &'static str,
|
2023-02-25 13:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
2023-10-29 17:28:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_const_and_c_variadic)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ConstAndCVariadic {
|
2023-10-29 17:28:56 -04:00
|
|
|
#[primary_span]
|
|
|
|
|
pub spans: Vec<Span>,
|
|
|
|
|
#[label(ast_passes_const)]
|
|
|
|
|
pub const_span: Span,
|
|
|
|
|
#[label(ast_passes_variadic)]
|
|
|
|
|
pub variadic_spans: Vec<Span>,
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 13:53:42 +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-14 10:57:07 +11:00
|
|
|
#[diag(ast_passes_pattern_in_foreign, code = E0130)]
|
2024-04-14 17:59:54 +00:00
|
|
|
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct PatternInForeign {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_pattern_in_bodiless, code = E0642)]
|
2024-04-14 17:59:54 +00:00
|
|
|
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct PatternInBodiless {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_equality_in_where)]
|
|
|
|
|
#[note]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct EqualityInWhere {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
#[label]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub assoc: Option<AssociatedSuggestion>,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub assoc2: Option<AssociatedSuggestion2>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
|
#[suggestion(
|
|
|
|
|
ast_passes_suggestion,
|
|
|
|
|
code = "{param}: {path}",
|
|
|
|
|
style = "verbose",
|
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
|
)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AssociatedSuggestion {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub ident: Ident,
|
|
|
|
|
pub param: Ident,
|
|
|
|
|
pub path: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
|
#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct AssociatedSuggestion2 {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[suggestion_part(code = "{args}")]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub args: String,
|
|
|
|
|
#[suggestion_part(code = "")]
|
|
|
|
|
pub predicate: Span,
|
|
|
|
|
pub trait_segment: Ident,
|
|
|
|
|
pub potential_assoc: Ident,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_stability_outside_std, code = E0734)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct StabilityOutsideStd {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[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(ast_passes_feature_on_non_nightly, code = E0554)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct FeatureOnNonNightly {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub channel: &'static str,
|
|
|
|
|
#[subdiagnostic]
|
|
|
|
|
pub stable_features: Vec<StableFeature>,
|
|
|
|
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
|
|
|
|
pub sugg: Option<Span>,
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct StableFeature {
|
2023-02-25 13:53:42 +00:00
|
|
|
pub name: Symbol,
|
|
|
|
|
pub since: Symbol,
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-06 14:00:16 +11:00
|
|
|
impl Subdiagnostic for StableFeature {
|
|
|
|
|
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>,
|
2024-04-18 19:18:35 +00:00
|
|
|
_: &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 16:44:30 +11:00
|
|
|
) {
|
2023-12-24 09:08:41 +11:00
|
|
|
diag.arg("name", self.name);
|
|
|
|
|
diag.arg("since", self.since);
|
2023-02-25 13:53:42 +00:00
|
|
|
diag.help(fluent::ast_passes_stable_since);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2023-04-09 17:35:02 -04:00
|
|
|
#[diag(ast_passes_incompatible_features)]
|
2023-02-25 13:53:42 +00:00
|
|
|
#[help]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct IncompatibleFeatures {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub spans: Vec<Span>,
|
|
|
|
|
pub f1: Symbol,
|
|
|
|
|
pub f2: Symbol,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_show_span)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ShowSpan {
|
2023-02-25 13:53:42 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub msg: &'static str,
|
|
|
|
|
}
|
2023-04-25 05:15:50 +00:00
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_negative_bound_not_supported)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct NegativeBoundUnsupported {
|
2023-04-25 05:15:50 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
2023-04-25 05:47:05 +00:00
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_constraint_on_negative_bound)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct ConstraintOnNegativeBound {
|
2023-04-25 05:47:05 +00:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
2023-08-23 20:53:47 +08:00
|
|
|
|
2023-12-27 17:57:19 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct NegativeBoundWithParentheticalNotation {
|
2023-12-27 17:57:19 +01:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 13:33:39 +01:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_match_arm_with_no_body)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct MatchArmWithNoBody {
|
2023-12-12 13:33:39 +01:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
|
|
|
|
|
pub suggestion: Span,
|
|
|
|
|
}
|
2024-06-05 16:18:52 -04:00
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_precise_capturing_not_allowed_here)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct PreciseCapturingNotAllowedHere {
|
2024-06-05 16:18:52 -04:00
|
|
|
#[primary_span]
|
|
|
|
|
pub span: Span,
|
|
|
|
|
pub loc: &'static str,
|
|
|
|
|
}
|
2024-06-05 16:43:25 -04:00
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
|
#[diag(ast_passes_precise_capturing_duplicated)]
|
2024-07-06 21:19:05 +10:00
|
|
|
pub(crate) struct DuplicatePreciseCapturing {
|
2024-06-05 16:43:25 -04:00
|
|
|
#[primary_span]
|
|
|
|
|
pub bound1: Span,
|
|
|
|
|
#[label]
|
|
|
|
|
pub bound2: Span,
|
|
|
|
|
}
|