Convert to inline diagnostics in rustc_session
This commit is contained in:
parent
930ecbcdf8
commit
0f9b0d3841
7 changed files with 106 additions and 239 deletions
|
|
@ -4641,7 +4641,6 @@ dependencies = [
|
|||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_feature",
|
||||
"rustc_fluent_macro",
|
||||
"rustc_fs_util",
|
||||
"rustc_hashes",
|
||||
"rustc_hir",
|
||||
|
|
|
|||
|
|
@ -135,7 +135,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
|
|||
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_session::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_ty_utils::DEFAULT_LOCALE_RESOURCE,
|
||||
// tidy-alphabetical-end
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
|
|||
cfgs.into_iter()
|
||||
.map(|s| {
|
||||
let psess = ParseSess::emitter_with_note(
|
||||
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE, rustc_session::DEFAULT_LOCALE_RESOURCE],
|
||||
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
||||
format!("this occurred on the command line: `--cfg={s}`"),
|
||||
);
|
||||
let filename = FileName::cfg_spec_source_code(&s);
|
||||
|
|
@ -127,7 +127,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
|
|||
|
||||
for s in specs {
|
||||
let psess = ParseSess::emitter_with_note(
|
||||
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE, rustc_session::DEFAULT_LOCALE_RESOURCE],
|
||||
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
||||
format!("this occurred on the command line: `--check-cfg={s}`"),
|
||||
);
|
||||
let filename = FileName::cfg_spec_source_code(&s);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ rustc_ast = { path = "../rustc_ast" }
|
|||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_feature = { path = "../rustc_feature" }
|
||||
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
|
||||
rustc_fs_util = { path = "../rustc_fs_util" }
|
||||
rustc_hashes = { path = "../rustc_hashes" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
|
|
|
|||
|
|
@ -1,149 +0,0 @@
|
|||
session_apple_deployment_target_invalid =
|
||||
failed to parse deployment target specified in {$env_var}: {$error}
|
||||
|
||||
session_apple_deployment_target_too_low =
|
||||
deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}
|
||||
|
||||
session_binary_float_literal_not_supported = binary float literal is not supported
|
||||
session_branch_protection_requires_aarch64 = `-Zbranch-protection` is only supported on aarch64
|
||||
|
||||
session_cannot_enable_crt_static_linux = sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`
|
||||
|
||||
session_cannot_mix_and_match_sanitizers = `-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`
|
||||
|
||||
session_cli_feature_diagnostic_help =
|
||||
add `-Zcrate-attr="feature({$feature})"` to the command-line options to enable
|
||||
|
||||
session_crate_name_empty = crate name must not be empty
|
||||
|
||||
session_embed_source_insufficient_dwarf_version = `-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}
|
||||
|
||||
session_embed_source_requires_debug_info = `-Zembed-source=y` requires debug information to be enabled
|
||||
|
||||
session_expr_parentheses_needed = parentheses are required to parse this as an expression
|
||||
|
||||
session_failed_to_create_profiler = failed to create profiler: {$err}
|
||||
|
||||
session_feature_diagnostic_for_issue =
|
||||
see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information
|
||||
|
||||
session_feature_diagnostic_help =
|
||||
add `#![feature({$feature})]` to the crate attributes to enable
|
||||
|
||||
session_feature_diagnostic_suggestion =
|
||||
add `#![feature({$feature})]` to the crate attributes to enable
|
||||
|
||||
session_feature_suggest_upgrade_compiler =
|
||||
this compiler was built on {$date}; consider upgrading it if it is out of date
|
||||
|
||||
session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions
|
||||
|
||||
session_file_write_fail = failed to write `{$path}` due to error `{$err}`
|
||||
|
||||
session_function_return_requires_x86_or_x86_64 = `-Zfunction-return` (except `keep`) is only supported on x86 and x86_64
|
||||
|
||||
session_function_return_thunk_extern_requires_non_large_code_model = `-Zfunction-return=thunk-extern` is only supported on non-large code models
|
||||
|
||||
session_hexadecimal_float_literal_not_supported = hexadecimal float literal is not supported
|
||||
|
||||
session_incompatible_linker_flavor = linker flavor `{$flavor}` is incompatible with the current target
|
||||
.note = compatible flavors are: {$compatible_list}
|
||||
|
||||
session_indirect_branch_cs_prefix_requires_x86_or_x86_64 = `-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64
|
||||
|
||||
session_instrumentation_not_supported = {$us} instrumentation is not supported for this target
|
||||
|
||||
session_int_literal_too_large = integer literal is too large
|
||||
.note = value exceeds limit of `{$limit}`
|
||||
|
||||
session_invalid_character_in_crate_name = invalid character {$character} in crate name: `{$crate_name}`
|
||||
|
||||
session_invalid_float_literal_suffix = invalid suffix `{$suffix}` for float literal
|
||||
.label = invalid suffix `{$suffix}`
|
||||
.help = valid suffixes are `f32` and `f64`
|
||||
|
||||
session_invalid_float_literal_width = invalid width `{$width}` for float literal
|
||||
.help = valid widths are 32 and 64
|
||||
|
||||
session_invalid_int_literal_width = invalid width `{$width}` for integer literal
|
||||
.help = valid widths are 8, 16, 32, 64 and 128
|
||||
|
||||
session_invalid_literal_suffix = suffixes on {$kind} literals are invalid
|
||||
.label = invalid suffix `{$suffix}`
|
||||
|
||||
session_invalid_num_literal_base_prefix = invalid base prefix for number literal
|
||||
.note = base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
.suggestion = try making the prefix lowercase
|
||||
|
||||
session_invalid_num_literal_suffix = invalid suffix `{$suffix}` for number literal
|
||||
.label = invalid suffix `{$suffix}`
|
||||
.help = the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
|
||||
|
||||
session_linker_plugin_lto_windows_not_supported = linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets
|
||||
|
||||
session_must_be_name_of_associated_function = must be a name of an associated function
|
||||
|
||||
session_not_circumvent_feature = `-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine
|
||||
|
||||
session_not_supported = not supported
|
||||
|
||||
session_octal_float_literal_not_supported = octal float literal is not supported
|
||||
|
||||
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist
|
||||
|
||||
session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist
|
||||
|
||||
session_sanitizer_cfi_canonical_jump_tables_requires_cfi = `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`
|
||||
|
||||
session_sanitizer_cfi_generalize_pointers_requires_cfi = `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`
|
||||
|
||||
session_sanitizer_cfi_normalize_integers_requires_cfi = `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`
|
||||
|
||||
session_sanitizer_cfi_requires_lto = `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`
|
||||
|
||||
session_sanitizer_cfi_requires_single_codegen_unit = `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`
|
||||
|
||||
session_sanitizer_kcfi_arity_requires_kcfi = `-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`
|
||||
|
||||
session_sanitizer_kcfi_requires_panic_abort = `-Z sanitizer=kcfi` requires `-C panic=abort`
|
||||
|
||||
session_sanitizer_not_supported = {$us} sanitizer is not supported for this target
|
||||
|
||||
session_sanitizers_not_supported = {$us} sanitizers are not supported for this target
|
||||
|
||||
session_skipping_const_checks = skipping const checks
|
||||
|
||||
session_soft_float_deprecated =
|
||||
`-Csoft-float` is unsound and deprecated; use a corresponding *eabi target instead
|
||||
.note = it will be removed or ignored in a future version of Rust
|
||||
session_soft_float_deprecated_issue = see issue #129893 <https://github.com/rust-lang/rust/issues/129893> for more information
|
||||
|
||||
session_soft_float_ignored =
|
||||
`-Csoft-float` is ignored on this target; it only has an effect on *eabihf targets
|
||||
.note = this may become a hard error in a future version of Rust
|
||||
|
||||
session_split_debuginfo_unstable_platform = `-Csplit-debuginfo={$debuginfo}` is unstable on this platform
|
||||
|
||||
session_split_lto_unit_requires_lto = `-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`
|
||||
|
||||
session_target_requires_unwind_tables = target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`
|
||||
|
||||
session_target_small_data_threshold_not_supported = `-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored
|
||||
|
||||
session_target_stack_protector_not_supported = `-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored
|
||||
|
||||
session_unexpected_builtin_cfg = unexpected `--cfg {$cfg}` flag
|
||||
.controlled_by = config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`
|
||||
.incoherent = manually setting a built-in cfg can and does create incoherent behaviors
|
||||
|
||||
session_unleashed_feature_help_named = skipping check for `{$gate}` feature
|
||||
session_unleashed_feature_help_unnamed = skipping check that does not even have a feature gate
|
||||
|
||||
session_unstable_virtual_function_elimination = `-Zvirtual-function-elimination` requires `-Clto`
|
||||
|
||||
session_unsupported_dwarf_version = requested DWARF version {$dwarf_version} is not supported
|
||||
session_unsupported_dwarf_version_help = supported DWARF versions are 2, 3, 4 and 5
|
||||
|
||||
session_unsupported_reg_struct_return_arch = `-Zreg-struct-return` is only supported on x86
|
||||
session_unsupported_regparm = `-Zregparm={$regparm}` is unsupported (valid values 0-3)
|
||||
session_unsupported_regparm_arch = `-Zregparm=N` is only supported on x86
|
||||
|
|
@ -15,9 +15,11 @@ use crate::parse::ParseSess;
|
|||
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum AppleDeploymentTarget {
|
||||
#[diag(session_apple_deployment_target_invalid)]
|
||||
#[diag("failed to parse deployment target specified in {$env_var}: {$error}")]
|
||||
Invalid { env_var: &'static str, error: ParseIntError },
|
||||
#[diag(session_apple_deployment_target_too_low)]
|
||||
#[diag(
|
||||
"deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}"
|
||||
)]
|
||||
TooLow { env_var: &'static str, version: String, os_min: String },
|
||||
}
|
||||
|
||||
|
|
@ -34,13 +36,13 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for FeatureGateError {
|
|||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note(session_feature_diagnostic_for_issue)]
|
||||
#[note("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")]
|
||||
pub(crate) struct FeatureDiagnosticForIssue {
|
||||
pub(crate) n: NonZero<u32>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note(session_feature_suggest_upgrade_compiler)]
|
||||
#[note("this compiler was built on {$date}; consider upgrading it if it is out of date")]
|
||||
pub(crate) struct SuggestUpgradeCompiler {
|
||||
date: &'static str,
|
||||
}
|
||||
|
|
@ -58,14 +60,14 @@ impl SuggestUpgradeCompiler {
|
|||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[help(session_feature_diagnostic_help)]
|
||||
#[help("add `#![feature({$feature})]` to the crate attributes to enable")]
|
||||
pub(crate) struct FeatureDiagnosticHelp {
|
||||
pub(crate) feature: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[suggestion(
|
||||
session_feature_diagnostic_suggestion,
|
||||
"add `#![feature({$feature})]` to the crate attributes to enable",
|
||||
applicability = "maybe-incorrect",
|
||||
code = "#![feature({feature})]\n"
|
||||
)]
|
||||
|
|
@ -76,169 +78,181 @@ pub struct FeatureDiagnosticSuggestion {
|
|||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[help(session_cli_feature_diagnostic_help)]
|
||||
#[help("add `-Zcrate-attr=\"feature({$feature})\"` to the command-line options to enable")]
|
||||
pub(crate) struct CliFeatureDiagnosticHelp {
|
||||
pub(crate) feature: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_must_be_name_of_associated_function)]
|
||||
#[diag("must be a name of an associated function")]
|
||||
pub struct MustBeNameOfAssociatedFunction {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_not_circumvent_feature)]
|
||||
#[diag(
|
||||
"`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine"
|
||||
)]
|
||||
pub(crate) struct NotCircumventFeature;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_linker_plugin_lto_windows_not_supported)]
|
||||
#[diag(
|
||||
"linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets"
|
||||
)]
|
||||
pub(crate) struct LinkerPluginToWindowsNotSupported;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_profile_use_file_does_not_exist)]
|
||||
#[diag("file `{$path}` passed to `-C profile-use` does not exist")]
|
||||
pub(crate) struct ProfileUseFileDoesNotExist<'a> {
|
||||
pub(crate) path: &'a std::path::Path,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_profile_sample_use_file_does_not_exist)]
|
||||
#[diag("file `{$path}` passed to `-C profile-sample-use` does not exist")]
|
||||
pub(crate) struct ProfileSampleUseFileDoesNotExist<'a> {
|
||||
pub(crate) path: &'a std::path::Path,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_target_requires_unwind_tables)]
|
||||
#[diag("target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`")]
|
||||
pub(crate) struct TargetRequiresUnwindTables;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_instrumentation_not_supported)]
|
||||
#[diag("{$us} instrumentation is not supported for this target")]
|
||||
pub(crate) struct InstrumentationNotSupported {
|
||||
pub(crate) us: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_not_supported)]
|
||||
#[diag("{$us} sanitizer is not supported for this target")]
|
||||
pub(crate) struct SanitizerNotSupported {
|
||||
pub(crate) us: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizers_not_supported)]
|
||||
#[diag("{$us} sanitizers are not supported for this target")]
|
||||
pub(crate) struct SanitizersNotSupported {
|
||||
pub(crate) us: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_cannot_mix_and_match_sanitizers)]
|
||||
#[diag("`-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`")]
|
||||
pub(crate) struct CannotMixAndMatchSanitizers {
|
||||
pub(crate) first: String,
|
||||
pub(crate) second: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_cannot_enable_crt_static_linux)]
|
||||
#[diag(
|
||||
"sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`"
|
||||
)]
|
||||
pub(crate) struct CannotEnableCrtStaticLinux;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_cfi_requires_lto)]
|
||||
#[diag("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")]
|
||||
pub(crate) struct SanitizerCfiRequiresLto;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_cfi_requires_single_codegen_unit)]
|
||||
#[diag("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")]
|
||||
pub(crate) struct SanitizerCfiRequiresSingleCodegenUnit;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_cfi_canonical_jump_tables_requires_cfi)]
|
||||
#[diag("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")]
|
||||
pub(crate) struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_cfi_generalize_pointers_requires_cfi)]
|
||||
#[diag("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
|
||||
pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_cfi_normalize_integers_requires_cfi)]
|
||||
#[diag("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
|
||||
pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_kcfi_arity_requires_kcfi)]
|
||||
#[diag("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")]
|
||||
pub(crate) struct SanitizerKcfiArityRequiresKcfi;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_kcfi_requires_panic_abort)]
|
||||
#[diag("`-Z sanitizer=kcfi` requires `-C panic=abort`")]
|
||||
pub(crate) struct SanitizerKcfiRequiresPanicAbort;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_split_lto_unit_requires_lto)]
|
||||
#[diag("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")]
|
||||
pub(crate) struct SplitLtoUnitRequiresLto;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_unstable_virtual_function_elimination)]
|
||||
#[diag("`-Zvirtual-function-elimination` requires `-Clto`")]
|
||||
pub(crate) struct UnstableVirtualFunctionElimination;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_unsupported_dwarf_version)]
|
||||
#[help(session_unsupported_dwarf_version_help)]
|
||||
#[diag("requested DWARF version {$dwarf_version} is not supported")]
|
||||
#[help("supported DWARF versions are 2, 3, 4 and 5")]
|
||||
pub(crate) struct UnsupportedDwarfVersion {
|
||||
pub(crate) dwarf_version: u32,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_embed_source_insufficient_dwarf_version)]
|
||||
#[diag(
|
||||
"`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}"
|
||||
)]
|
||||
pub(crate) struct EmbedSourceInsufficientDwarfVersion {
|
||||
pub(crate) dwarf_version: u32,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_embed_source_requires_debug_info)]
|
||||
#[diag("`-Zembed-source=y` requires debug information to be enabled")]
|
||||
pub(crate) struct EmbedSourceRequiresDebugInfo;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_target_stack_protector_not_supported)]
|
||||
#[diag(
|
||||
"`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored"
|
||||
)]
|
||||
pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
|
||||
pub(crate) stack_protector: StackProtector,
|
||||
pub(crate) target_triple: &'a TargetTuple,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_target_small_data_threshold_not_supported)]
|
||||
#[diag(
|
||||
"`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored"
|
||||
)]
|
||||
pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
|
||||
pub(crate) target_triple: &'a TargetTuple,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_branch_protection_requires_aarch64)]
|
||||
#[diag("`-Zbranch-protection` is only supported on aarch64")]
|
||||
pub(crate) struct BranchProtectionRequiresAArch64;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_split_debuginfo_unstable_platform)]
|
||||
#[diag("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")]
|
||||
pub(crate) struct SplitDebugInfoUnstablePlatform {
|
||||
pub(crate) debuginfo: SplitDebuginfo,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_file_is_not_writeable)]
|
||||
#[diag("output file {$file} is not writeable -- check its permissions")]
|
||||
pub(crate) struct FileIsNotWriteable<'a> {
|
||||
pub(crate) file: &'a std::path::Path,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_file_write_fail)]
|
||||
#[diag("failed to write `{$path}` due to error `{$err}`")]
|
||||
pub(crate) struct FileWriteFail<'a> {
|
||||
pub(crate) path: &'a std::path::Path,
|
||||
pub(crate) err: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_crate_name_empty)]
|
||||
#[diag("crate name must not be empty")]
|
||||
pub(crate) struct CrateNameEmpty {
|
||||
#[primary_span]
|
||||
pub(crate) span: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_invalid_character_in_crate_name)]
|
||||
#[diag("invalid character {$character} in crate name: `{$crate_name}`")]
|
||||
pub(crate) struct InvalidCharacterInCrateName {
|
||||
#[primary_span]
|
||||
pub(crate) span: Option<Span>,
|
||||
|
|
@ -247,7 +261,10 @@ pub(crate) struct InvalidCharacterInCrateName {
|
|||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(session_expr_parentheses_needed, applicability = "machine-applicable")]
|
||||
#[multipart_suggestion(
|
||||
"parentheses are required to parse this as an expression",
|
||||
applicability = "machine-applicable"
|
||||
)]
|
||||
pub struct ExprParenthesesNeeded {
|
||||
#[suggestion_part(code = "(")]
|
||||
left: Span,
|
||||
|
|
@ -262,7 +279,7 @@ impl ExprParenthesesNeeded {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_skipping_const_checks)]
|
||||
#[diag("skipping const checks")]
|
||||
pub(crate) struct SkippingConstChecks {
|
||||
#[subdiagnostic]
|
||||
pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
|
||||
|
|
@ -270,13 +287,13 @@ pub(crate) struct SkippingConstChecks {
|
|||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum UnleashedFeatureHelp {
|
||||
#[help(session_unleashed_feature_help_named)]
|
||||
#[help("skipping check for `{$gate}` feature")]
|
||||
Named {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
gate: Symbol,
|
||||
},
|
||||
#[help(session_unleashed_feature_help_unnamed)]
|
||||
#[help("skipping check that does not even have a feature gate")]
|
||||
Unnamed {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
|
|
@ -284,10 +301,10 @@ pub(crate) enum UnleashedFeatureHelp {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_invalid_literal_suffix)]
|
||||
#[diag("suffixes on {$kind} literals are invalid")]
|
||||
struct InvalidLiteralSuffix<'a> {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
#[label("invalid suffix `{$suffix}`")]
|
||||
span: Span,
|
||||
// FIXME(#100717)
|
||||
kind: &'a str,
|
||||
|
|
@ -295,8 +312,8 @@ struct InvalidLiteralSuffix<'a> {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_invalid_int_literal_width)]
|
||||
#[help]
|
||||
#[diag("invalid width `{$width}` for integer literal")]
|
||||
#[help("valid widths are 8, 16, 32, 64 and 128")]
|
||||
struct InvalidIntLiteralWidth {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
|
|
@ -304,28 +321,32 @@ struct InvalidIntLiteralWidth {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_invalid_num_literal_base_prefix)]
|
||||
#[note]
|
||||
#[diag("invalid base prefix for number literal")]
|
||||
#[note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")]
|
||||
struct InvalidNumLiteralBasePrefix {
|
||||
#[primary_span]
|
||||
#[suggestion(applicability = "maybe-incorrect", code = "{fixed}")]
|
||||
#[suggestion(
|
||||
"try making the prefix lowercase",
|
||||
applicability = "maybe-incorrect",
|
||||
code = "{fixed}"
|
||||
)]
|
||||
span: Span,
|
||||
fixed: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_invalid_num_literal_suffix)]
|
||||
#[help]
|
||||
#[diag("invalid suffix `{$suffix}` for number literal")]
|
||||
#[help("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")]
|
||||
struct InvalidNumLiteralSuffix {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
#[label("invalid suffix `{$suffix}`")]
|
||||
span: Span,
|
||||
suffix: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_invalid_float_literal_width)]
|
||||
#[help]
|
||||
#[diag("invalid width `{$width}` for float literal")]
|
||||
#[help("valid widths are 32 and 64")]
|
||||
struct InvalidFloatLiteralWidth {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
|
|
@ -333,18 +354,18 @@ struct InvalidFloatLiteralWidth {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_invalid_float_literal_suffix)]
|
||||
#[help]
|
||||
#[diag("invalid suffix `{$suffix}` for float literal")]
|
||||
#[help("valid suffixes are `f32` and `f64`")]
|
||||
struct InvalidFloatLiteralSuffix {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
#[label("invalid suffix `{$suffix}`")]
|
||||
span: Span,
|
||||
suffix: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_int_literal_too_large)]
|
||||
#[note]
|
||||
#[diag("integer literal is too large")]
|
||||
#[note("value exceeds limit of `{$limit}`")]
|
||||
struct IntLiteralTooLarge {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
|
|
@ -352,26 +373,26 @@ struct IntLiteralTooLarge {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_hexadecimal_float_literal_not_supported)]
|
||||
#[diag("hexadecimal float literal is not supported")]
|
||||
struct HexadecimalFloatLiteralNotSupported {
|
||||
#[primary_span]
|
||||
#[label(session_not_supported)]
|
||||
#[label("not supported")]
|
||||
span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_octal_float_literal_not_supported)]
|
||||
#[diag("octal float literal is not supported")]
|
||||
struct OctalFloatLiteralNotSupported {
|
||||
#[primary_span]
|
||||
#[label(session_not_supported)]
|
||||
#[label("not supported")]
|
||||
span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_binary_float_literal_not_supported)]
|
||||
#[diag("binary float literal is not supported")]
|
||||
struct BinaryFloatLiteralNotSupported {
|
||||
#[primary_span]
|
||||
#[label(session_not_supported)]
|
||||
#[label("not supported")]
|
||||
span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -457,60 +478,60 @@ pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span:
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_incompatible_linker_flavor)]
|
||||
#[note]
|
||||
#[diag("linker flavor `{$flavor}` is incompatible with the current target")]
|
||||
#[note("compatible flavors are: {$compatible_list}")]
|
||||
pub(crate) struct IncompatibleLinkerFlavor {
|
||||
pub(crate) flavor: &'static str,
|
||||
pub(crate) compatible_list: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_function_return_requires_x86_or_x86_64)]
|
||||
#[diag("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")]
|
||||
pub(crate) struct FunctionReturnRequiresX86OrX8664;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_function_return_thunk_extern_requires_non_large_code_model)]
|
||||
#[diag("`-Zfunction-return=thunk-extern` is only supported on non-large code models")]
|
||||
pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_indirect_branch_cs_prefix_requires_x86_or_x86_64)]
|
||||
#[diag("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")]
|
||||
pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_unsupported_regparm)]
|
||||
#[diag("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")]
|
||||
pub(crate) struct UnsupportedRegparm {
|
||||
pub(crate) regparm: u32,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_unsupported_regparm_arch)]
|
||||
#[diag("`-Zregparm=N` is only supported on x86")]
|
||||
pub(crate) struct UnsupportedRegparmArch;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_unsupported_reg_struct_return_arch)]
|
||||
#[diag("`-Zreg-struct-return` is only supported on x86")]
|
||||
pub(crate) struct UnsupportedRegStructReturnArch;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_failed_to_create_profiler)]
|
||||
#[diag("failed to create profiler: {$err}")]
|
||||
pub(crate) struct FailedToCreateProfiler {
|
||||
pub(crate) err: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_soft_float_ignored)]
|
||||
#[note]
|
||||
#[diag("`-Csoft-float` is ignored on this target; it only has an effect on *eabihf targets")]
|
||||
#[note("this may become a hard error in a future version of Rust")]
|
||||
pub(crate) struct SoftFloatIgnored;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_soft_float_deprecated)]
|
||||
#[note]
|
||||
#[note(session_soft_float_deprecated_issue)]
|
||||
#[diag("`-Csoft-float` is unsound and deprecated; use a corresponding *eabi target instead")]
|
||||
#[note("it will be removed or ignored in a future version of Rust")]
|
||||
#[note("see issue #129893 <https://github.com/rust-lang/rust/issues/129893> for more information")]
|
||||
pub(crate) struct SoftFloatDeprecated;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(session_unexpected_builtin_cfg)]
|
||||
#[note(session_controlled_by)]
|
||||
#[note(session_incoherent)]
|
||||
#[diag("unexpected `--cfg {$cfg}` flag")]
|
||||
#[note("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")]
|
||||
#[note("manually setting a built-in cfg can and does create incoherent behaviors")]
|
||||
pub(crate) struct UnexpectedBuiltinCfg {
|
||||
pub(crate) cfg: String,
|
||||
pub(crate) cfg_name: Symbol,
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ pub mod output;
|
|||
|
||||
pub use getopts;
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
||||
/// Requirements for a `StableHashingContext` to be used in this crate.
|
||||
/// This is a hack to allow using the `HashStable_Generic` derive macro
|
||||
/// instead of implementing everything in `rustc_middle`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue