2022-08-26 20:39:59 +00:00
|
|
|
use std::io::Error;
|
|
|
|
use std::path::{Path, PathBuf};
|
2022-08-24 18:14:41 +00:00
|
|
|
|
2024-06-18 10:35:56 +00:00
|
|
|
use rustc_errors::codes::*;
|
|
|
|
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
|
2024-04-28 22:53:45 +00:00
|
|
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
2022-08-24 18:14:41 +00:00
|
|
|
use rustc_span::{sym, Span, Symbol};
|
2022-08-26 20:39:59 +00:00
|
|
|
use rustc_target::spec::{PanicStrategy, TargetTriple};
|
|
|
|
|
2022-10-13 09:13:02 +00:00
|
|
|
use crate::fluent_generated as fluent;
|
2022-08-26 20:39:59 +00:00
|
|
|
use crate::locator::CrateFlavor;
|
2022-08-23 19:25:03 +00:00
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_rlib_required)]
|
2022-08-23 19:25:03 +00:00
|
|
|
pub struct RlibRequired {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-23 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_lib_required)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct LibRequired<'a> {
|
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub kind: &'a str,
|
2022-08-23 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-12-13 11:30:58 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(metadata_rustc_lib_required)]
|
|
|
|
#[help]
|
|
|
|
pub struct RustcLibRequired<'a> {
|
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub kind: &'a str,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_crate_dep_multiple)]
|
2022-08-23 19:25:03 +00:00
|
|
|
#[help]
|
|
|
|
pub struct CrateDepMultiple {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2024-03-11 16:02:12 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub non_static_deps: Vec<NonStaticCrateDep>,
|
2024-03-22 10:42:53 +00:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub rustc_driver_help: Option<RustcDriverHelp>,
|
2024-03-11 16:02:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[note(metadata_crate_dep_not_static)]
|
|
|
|
pub struct NonStaticCrateDep {
|
|
|
|
pub crate_name: Symbol,
|
2022-08-23 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2024-03-22 10:42:53 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[help(metadata_crate_dep_rustc_driver)]
|
|
|
|
pub struct RustcDriverHelp;
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_two_panic_runtimes)]
|
2022-08-23 19:25:03 +00:00
|
|
|
pub struct TwoPanicRuntimes {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub prev_name: Symbol,
|
|
|
|
pub cur_name: Symbol,
|
2022-08-23 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_bad_panic_strategy)]
|
2022-08-23 19:25:03 +00:00
|
|
|
pub struct BadPanicStrategy {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub runtime: Symbol,
|
|
|
|
pub strategy: PanicStrategy,
|
2022-08-23 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_required_panic_strategy)]
|
2022-08-23 19:25:03 +00:00
|
|
|
pub struct RequiredPanicStrategy {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub found_strategy: PanicStrategy,
|
|
|
|
pub desired_strategy: PanicStrategy,
|
2022-08-23 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_incompatible_panic_in_drop_strategy)]
|
2022-08-23 19:25:03 +00:00
|
|
|
pub struct IncompatiblePanicInDropStrategy {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub found_strategy: PanicStrategy,
|
|
|
|
pub desired_strategy: PanicStrategy,
|
2022-08-23 19:25:03 +00:00
|
|
|
}
|
2022-08-23 22:33:28 +00:00
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_names_in_link)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct MultipleNamesInLink {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_kinds_in_link)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct MultipleKindsInLink {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_link_name_form)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkNameForm {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_link_kind_form)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkKindForm {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_link_modifiers_form)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkModifiersForm {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_link_cfg_form)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkCfgForm {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_wasm_import_form)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct WasmImportForm {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_empty_link_name, code = E0454)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct EmptyLinkName {
|
|
|
|
#[primary_span]
|
2022-08-24 18:14:41 +00:00
|
|
|
#[label]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_link_framework_apple, code = E0455)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkFrameworkApple {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2024-05-22 13:54:02 +00:00
|
|
|
#[diag(metadata_raw_dylib_only_windows, code = E0455)]
|
|
|
|
pub struct RawDylibOnlyWindows {
|
2022-08-23 22:33:28 +00:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_unknown_link_kind, code = E0458)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct UnknownLinkKind<'a> {
|
2022-08-23 22:33:28 +00:00
|
|
|
#[primary_span]
|
2022-08-24 18:14:41 +00:00
|
|
|
#[label]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub kind: &'a str,
|
2022-08-23 22:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_link_modifiers)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct MultipleLinkModifiers {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_cfgs)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct MultipleCfgs {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_link_cfg_single_predicate)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkCfgSinglePredicate {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_wasm_import)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct MultipleWasmImport {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_unexpected_link_arg)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct UnexpectedLinkArg {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_invalid_link_modifier)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct InvalidLinkModifier {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_modifiers)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct MultipleModifiers<'a> {
|
2022-08-23 22:33:28 +00:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub modifier: &'a str,
|
2022-08-23 22:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_bundle_needs_static)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct BundleNeedsStatic {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_whole_archive_needs_static)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct WholeArchiveNeedsStatic {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_as_needed_compatibility)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct AsNeededCompatibility {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_unknown_link_modifier)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct UnknownLinkModifier<'a> {
|
2022-08-23 22:33:28 +00:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub modifier: &'a str,
|
2022-08-23 22:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_incompatible_wasm_link)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct IncompatibleWasmLink {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_link_requires_name, code = E0459)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkRequiresName {
|
|
|
|
#[primary_span]
|
2022-08-24 18:14:41 +00:00
|
|
|
#[label]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_raw_dylib_no_nul)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct RawDylibNoNul {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_link_ordinal_raw_dylib)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LinkOrdinalRawDylib {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_lib_framework_apple)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct LibFrameworkApple;
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_empty_renaming_target)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct EmptyRenamingTarget<'a> {
|
|
|
|
pub lib_name: &'a str,
|
2022-08-23 22:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_renaming_no_link)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct RenamingNoLink<'a> {
|
|
|
|
pub lib_name: &'a str,
|
2022-08-23 22:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_renamings)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct MultipleRenamings<'a> {
|
|
|
|
pub lib_name: &'a str,
|
2022-08-23 22:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_no_link_mod_override)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct NoLinkModOverride {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Option<Span>,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_unsupported_abi_i686)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct UnsupportedAbiI686 {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_unsupported_abi)]
|
2022-08-23 22:33:28 +00:00
|
|
|
pub struct UnsupportedAbi {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-08-23 22:40:43 +00:00
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_fail_create_file_encoder)]
|
2022-08-23 22:40:43 +00:00
|
|
|
pub struct FailCreateFileEncoder {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub err: Error,
|
2022-08-23 22:40:43 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_fail_write_file)]
|
2023-10-28 01:26:43 +00:00
|
|
|
pub struct FailWriteFile<'a> {
|
|
|
|
pub path: &'a Path,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub err: Error,
|
2022-08-23 22:40:43 +00:00
|
|
|
}
|
2022-08-23 23:03:49 +00:00
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_crate_not_panic_runtime)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub struct CrateNotPanicRuntime {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-23 23:03:49 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_no_panic_strategy)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub struct NoPanicStrategy {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub strategy: PanicStrategy,
|
2022-08-23 23:03:49 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_profiler_builtins_needs_core)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub struct ProfilerBuiltinsNeedsCore;
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_not_profiler_runtime)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub struct NotProfilerRuntime {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-23 23:03:49 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_no_multiple_global_alloc)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub struct NoMultipleGlobalAlloc {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span2: Span,
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(metadata_prev_global_alloc)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub span1: Span,
|
|
|
|
}
|
|
|
|
|
2023-04-24 22:08:35 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(metadata_no_multiple_alloc_error_handler)]
|
|
|
|
pub struct NoMultipleAllocErrorHandler {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span2: Span,
|
|
|
|
#[label(metadata_prev_alloc_error_handler)]
|
|
|
|
pub span1: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_conflicting_global_alloc)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub struct ConflictingGlobalAlloc {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub other_crate_name: Symbol,
|
2022-08-23 23:03:49 +00:00
|
|
|
}
|
|
|
|
|
2023-04-24 22:08:35 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(metadata_conflicting_alloc_error_handler)]
|
|
|
|
pub struct ConflictingAllocErrorHandler {
|
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub other_crate_name: Symbol,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_global_alloc_required)]
|
2022-08-23 23:03:49 +00:00
|
|
|
pub struct GlobalAllocRequired;
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_no_transitive_needs_dep)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct NoTransitiveNeedsDep<'a> {
|
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub needs_crate_name: &'a str,
|
|
|
|
pub deps_crate_name: Symbol,
|
2022-08-23 23:03:49 +00:00
|
|
|
}
|
2022-08-23 23:16:04 +00:00
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_failed_write_error)]
|
2022-08-23 23:16:04 +00:00
|
|
|
pub struct FailedWriteError {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub filename: PathBuf,
|
|
|
|
pub err: Error,
|
2022-08-23 23:16:04 +00:00
|
|
|
}
|
|
|
|
|
2023-02-26 20:27:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(metadata_failed_copy_to_stdout)]
|
|
|
|
pub struct FailedCopyToStdout {
|
|
|
|
pub filename: PathBuf,
|
|
|
|
pub err: Error,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(metadata_binary_output_to_tty)]
|
|
|
|
pub struct BinaryOutputToTty;
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_missing_native_library)]
|
2022-08-24 10:10:40 +00:00
|
|
|
pub struct MissingNativeLibrary<'a> {
|
2022-10-13 02:52:31 +00:00
|
|
|
libname: &'a str,
|
|
|
|
#[subdiagnostic]
|
|
|
|
suggest_name: Option<SuggestLibraryName<'a>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> MissingNativeLibrary<'a> {
|
|
|
|
pub fn new(libname: &'a str, verbatim: bool) -> Self {
|
|
|
|
// if it looks like the user has provided a complete filename rather just the bare lib name,
|
|
|
|
// then provide a note that they might want to try trimming the name
|
|
|
|
let suggested_name = if !verbatim {
|
|
|
|
if let Some(libname) = libname.strip_prefix("lib")
|
|
|
|
&& let Some(libname) = libname.strip_suffix(".a")
|
|
|
|
{
|
|
|
|
// this is a unix style filename so trim prefix & suffix
|
|
|
|
Some(libname)
|
|
|
|
} else if let Some(libname) = libname.strip_suffix(".lib") {
|
|
|
|
// this is a Windows style filename so just trim the suffix
|
|
|
|
Some(libname)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
|
|
|
|
Self {
|
|
|
|
libname,
|
|
|
|
suggest_name: suggested_name
|
|
|
|
.map(|suggested_name| SuggestLibraryName { suggested_name }),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[help(metadata_only_provide_library_name)]
|
2022-10-13 02:52:31 +00:00
|
|
|
pub struct SuggestLibraryName<'a> {
|
|
|
|
suggested_name: &'a str,
|
2022-08-24 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_failed_create_tempdir)]
|
2022-08-23 23:16:04 +00:00
|
|
|
pub struct FailedCreateTempdir {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub err: Error,
|
2022-08-23 23:16:04 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_failed_create_file)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct FailedCreateFile<'a> {
|
|
|
|
pub filename: &'a Path,
|
|
|
|
pub err: Error,
|
2022-08-23 23:16:04 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_failed_create_encoded_metadata)]
|
2022-08-23 23:16:04 +00:00
|
|
|
pub struct FailedCreateEncodedMetadata {
|
2022-08-26 20:39:59 +00:00
|
|
|
pub err: Error,
|
2022-08-23 23:16:04 +00:00
|
|
|
}
|
2022-08-24 18:14:41 +00:00
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_non_ascii_name)]
|
2022-08-24 18:14:41 +00:00
|
|
|
pub struct NonAsciiName {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_extern_location_not_exist)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct ExternLocationNotExist<'a> {
|
2022-08-24 18:14:41 +00:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub location: &'a Path,
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_extern_location_not_file)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct ExternLocationNotFile<'a> {
|
2022-08-24 18:14:41 +00:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub location: &'a Path,
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
|
2022-08-26 20:39:59 +00:00
|
|
|
pub(crate) struct MultipleCandidates {
|
2022-08-24 18:14:41 +00:00
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub flavor: CrateFlavor,
|
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub candidates: Vec<PathBuf>,
|
|
|
|
}
|
|
|
|
|
2024-03-06 00:02:56 +00:00
|
|
|
impl<G: EmissionGuarantee> Diagnostic<'_, G> for MultipleCandidates {
|
2024-06-18 10:35:56 +00:00
|
|
|
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
|
2024-02-22 23:20:45 +00:00
|
|
|
let mut diag = Diag::new(dcx, level, fluent::metadata_multiple_candidates);
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.arg("crate_name", self.crate_name);
|
|
|
|
diag.arg("flavor", self.flavor);
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
diag.code(E0464);
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.span(self.span);
|
2022-08-24 18:14:41 +00:00
|
|
|
for (i, candidate) in self.candidates.iter().enumerate() {
|
Reduce capabilities of `Diagnostic`.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)
`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.
The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)
All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.
There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.
There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-06 05:44:30 +00:00
|
|
|
// FIXME: make this translatable
|
|
|
|
#[allow(rustc::untranslatable_diagnostic)]
|
Restrict `From<S>` for `{D,Subd}iagnosticMessage`.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.
This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.
As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-04-20 03:26:58 +00:00
|
|
|
diag.note(format!("candidate #{}: {}", i + 1, candidate.display()));
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_symbol_conflicts_current, code = E0519)]
|
2022-08-24 18:14:41 +00:00
|
|
|
pub struct SymbolConflictsCurrent {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_stable_crate_id_collision)]
|
2022-08-24 18:14:41 +00:00
|
|
|
pub struct StableCrateIdCollision {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name0: Symbol,
|
|
|
|
pub crate_name1: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_dl_error)]
|
2022-08-24 18:14:41 +00:00
|
|
|
pub struct DlError {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2024-02-21 11:17:07 +00:00
|
|
|
pub path: String,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub err: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_newer_crate_version, code = E0460)]
|
2022-08-24 18:14:41 +00:00
|
|
|
#[note]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[note(metadata_found_crate_versions)]
|
2022-08-24 18:14:41 +00:00
|
|
|
pub struct NewerCrateVersion {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub add_info: String,
|
|
|
|
pub found_crates: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_no_crate_with_triple, code = E0461)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[note(metadata_found_crate_versions)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct NoCrateWithTriple<'a> {
|
2022-08-24 18:14:41 +00:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
|
|
|
pub locator_triple: &'a str,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub add_info: String,
|
|
|
|
pub found_crates: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_found_staticlib, code = E0462)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[note(metadata_found_crate_versions)]
|
2022-08-24 18:14:41 +00:00
|
|
|
#[help]
|
|
|
|
pub struct FoundStaticlib {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub add_info: String,
|
|
|
|
pub found_crates: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(metadata_incompatible_rustc, code = E0514)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[note(metadata_found_crate_versions)]
|
2022-08-24 18:14:41 +00:00
|
|
|
#[help]
|
|
|
|
pub struct IncompatibleRustc {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub add_info: String,
|
|
|
|
pub found_crates: String,
|
|
|
|
pub rustc_version: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct InvalidMetadataFiles {
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub add_info: String,
|
|
|
|
pub crate_rejections: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2024-03-06 00:02:56 +00:00
|
|
|
impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidMetadataFiles {
|
2022-10-31 15:14:29 +00:00
|
|
|
#[track_caller]
|
2024-06-18 10:35:56 +00:00
|
|
|
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
|
2024-02-22 23:20:45 +00:00
|
|
|
let mut diag = Diag::new(dcx, level, fluent::metadata_invalid_meta_files);
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.arg("crate_name", self.crate_name);
|
|
|
|
diag.arg("add_info", self.add_info);
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
diag.code(E0786);
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.span(self.span);
|
2022-08-24 18:14:41 +00:00
|
|
|
for crate_rejection in self.crate_rejections {
|
Reduce capabilities of `Diagnostic`.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)
`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.
The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)
All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.
There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.
There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-06 05:44:30 +00:00
|
|
|
// FIXME: make this translatable
|
|
|
|
#[allow(rustc::untranslatable_diagnostic)]
|
2022-08-24 18:14:41 +00:00
|
|
|
diag.note(crate_rejection);
|
|
|
|
}
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct CannotFindCrate {
|
|
|
|
pub span: Span,
|
2022-08-26 20:39:59 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-24 18:14:41 +00:00
|
|
|
pub add_info: String,
|
|
|
|
pub missing_core: bool,
|
|
|
|
pub current_crate: String,
|
|
|
|
pub is_nightly_build: bool,
|
|
|
|
pub profiler_runtime: Symbol,
|
|
|
|
pub locator_triple: TargetTriple,
|
2023-07-04 01:37:40 +00:00
|
|
|
pub is_ui_testing: bool,
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
|
2024-03-06 00:02:56 +00:00
|
|
|
impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
|
2022-10-31 15:14:29 +00:00
|
|
|
#[track_caller]
|
2024-06-18 10:35:56 +00:00
|
|
|
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
|
2024-02-22 23:20:45 +00:00
|
|
|
let mut diag = Diag::new(dcx, level, fluent::metadata_cannot_find_crate);
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.arg("crate_name", self.crate_name);
|
|
|
|
diag.arg("current_crate", self.current_crate);
|
|
|
|
diag.arg("add_info", self.add_info);
|
|
|
|
diag.arg("locator_triple", self.locator_triple.triple());
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
diag.code(E0463);
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.span(self.span);
|
2024-05-01 15:11:49 +00:00
|
|
|
if self.crate_name == sym::std || self.crate_name == sym::core {
|
2022-08-24 18:14:41 +00:00
|
|
|
if self.missing_core {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.note(fluent::metadata_target_not_installed);
|
2022-08-24 18:14:41 +00:00
|
|
|
} else {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.note(fluent::metadata_target_no_std_support);
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
2023-07-04 01:37:40 +00:00
|
|
|
|
2022-08-24 18:14:41 +00:00
|
|
|
if self.missing_core {
|
2023-07-04 01:37:40 +00:00
|
|
|
if env!("CFG_RELEASE_CHANNEL") == "dev" && !self.is_ui_testing {
|
|
|
|
// Note: Emits the nicer suggestion only for the dev channel.
|
|
|
|
diag.help(fluent::metadata_consider_adding_std);
|
|
|
|
} else {
|
|
|
|
// NOTE: this suggests using rustup, even though the user may not have it installed.
|
|
|
|
// That's because they could choose to install it; or this may give them a hint which
|
|
|
|
// target they need to install from their distro.
|
|
|
|
diag.help(fluent::metadata_consider_downloading_target);
|
|
|
|
}
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
2023-07-04 01:37:40 +00:00
|
|
|
|
2022-08-24 18:14:41 +00:00
|
|
|
// Suggest using #![no_std]. #[no_core] is unstable and not really supported anyway.
|
|
|
|
// NOTE: this is a dummy span if `extern crate std` was injected by the compiler.
|
|
|
|
// If it's not a dummy, that means someone added `extern crate std` explicitly and
|
|
|
|
// `#![no_std]` won't help.
|
|
|
|
if !self.missing_core && self.span.is_dummy() {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.note(fluent::metadata_std_required);
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
|
|
|
if self.is_nightly_build {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.help(fluent::metadata_consider_building_std);
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
2022-08-26 20:39:59 +00:00
|
|
|
} else if self.crate_name == self.profiler_runtime {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.note(fluent::metadata_compiler_missing_profiler);
|
2022-08-26 20:39:59 +00:00
|
|
|
} else if self.crate_name.as_str().starts_with("rustc_") {
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.help(fluent::metadata_install_missing_components);
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
2022-10-13 09:13:02 +00:00
|
|
|
diag.span_label(self.span, fluent::metadata_cant_find_crate);
|
2022-08-24 18:14:41 +00:00
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_crate_location_unknown_type)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct CrateLocationUnknownType<'a> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub path: &'a Path,
|
2022-11-19 11:37:56 +00:00
|
|
|
pub crate_name: Symbol,
|
2022-08-26 20:39:59 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_lib_filename_form)]
|
2022-08-26 20:39:59 +00:00
|
|
|
pub struct LibFilenameForm<'a> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub dll_prefix: &'a str,
|
|
|
|
pub dll_suffix: &'a str,
|
2022-08-24 18:14:41 +00:00
|
|
|
}
|
2022-08-27 23:50:11 +00:00
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_multiple_import_name_type)]
|
2022-08-27 23:50:11 +00:00
|
|
|
pub struct MultipleImportNameType {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_import_name_type_form)]
|
2022-08-27 23:50:11 +00:00
|
|
|
pub struct ImportNameTypeForm {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_import_name_type_x86)]
|
2022-08-27 23:50:11 +00:00
|
|
|
pub struct ImportNameTypeX86 {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_unknown_import_name_type)]
|
2022-08-27 23:50:11 +00:00
|
|
|
pub struct UnknownImportNameType<'a> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub import_name_type: &'a str,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(metadata_import_name_type_raw)]
|
2022-08-27 23:50:11 +00:00
|
|
|
pub struct ImportNameTypeRaw {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|