Convert to inline diagnostics in rustc_codegen_ssa

This commit is contained in:
Jonathan Brouwer
2026-02-04 17:23:35 +01:00
parent 930ecbcdf8
commit d445a2aabb
8 changed files with 252 additions and 607 deletions
-1
View File
@@ -3673,7 +3673,6 @@ dependencies = [
"rustc_attr_parsing",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_fs_util",
"rustc_hashes",
"rustc_hir",
-1
View File
@@ -18,7 +18,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" }
-397
View File
@@ -1,397 +0,0 @@
codegen_ssa_L4Bender_exporting_symbols_unimplemented = exporting symbols not implemented yet for L4Bender
codegen_ssa_aarch64_softfloat_neon = enabling the `neon` target feature on the current target is unsound due to ABI issues
codegen_ssa_add_native_library = failed to add native library {$library_path}: {$error}
codegen_ssa_aix_strip_not_used = using host's `strip` binary to cross-compile to AIX which is not guaranteed to work
codegen_ssa_archive_build_failure = failed to build archive at `{$path}`: {$error}
codegen_ssa_binary_output_to_tty = option `-o` or `--emit` is used to write binary output type `{$shorthand}` to stdout, but stdout is a tty
codegen_ssa_bpf_staticlib_not_supported = linking static libraries is not supported for BPF
codegen_ssa_cgu_not_recorded =
CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded
codegen_ssa_check_installed_visual_studio = please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.
codegen_ssa_compiler_builtins_cannot_call =
`compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `{$caller}` to `{$callee}`
codegen_ssa_copy_path = could not copy {$from} to {$to}: {$error}
codegen_ssa_copy_path_buf = unable to copy {$source_file} to {$output_path}: {$error}
codegen_ssa_cpu_required = target requires explicitly specifying a cpu with `-C target-cpu`
codegen_ssa_create_temp_dir = couldn't create a temp dir: {$error}
codegen_ssa_dlltool_fail_import_library =
dlltool could not create import library with {$dlltool_path} {$dlltool_args}:
{$stdout}
{$stderr}
codegen_ssa_dynamic_linking_with_lto =
cannot prefer dynamic linking when performing LTO
.note = only 'staticlib', 'bin', and 'cdylib' outputs are supported with LTO
codegen_ssa_error_calling_dlltool =
error calling dlltool '{$dlltool_path}': {$error}
codegen_ssa_error_creating_import_library =
error creating import library for {$lib_name}: {$error}
codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$error}
codegen_ssa_error_writing_def_file =
error writing .DEF file: {$error}
codegen_ssa_extern_funcs_not_found = some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
codegen_ssa_extract_bundled_libs_archive_member = failed to get data from archive member '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_convert_name = failed to convert name '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_mmap_file = failed to mmap file '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_open_file = failed to open file '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_parse_archive = failed to parse archive '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_read_entry = failed to read entry '{$rlib}': {$error}
codegen_ssa_extract_bundled_libs_write_file = failed to write file '{$rlib}': {$error}
codegen_ssa_failed_to_get_layout = failed to get layout for {$ty}: {$err}
codegen_ssa_failed_to_write = failed to write {$path}: {$error}
codegen_ssa_feature_not_valid = the feature named `{$feature}` is not valid for this target
.label = `{$feature}` is not valid for this target
.help = consider removing the leading `+` in the feature name
codegen_ssa_field_associated_value_expected = associated value expected for `{$name}`
codegen_ssa_forbidden_ctarget_feature =
target feature `{$feature}` cannot be {$enabled} with `-Ctarget-feature`: {$reason}
.note = this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
codegen_ssa_forbidden_ctarget_feature_issue = for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
codegen_ssa_forbidden_target_feature_attr =
target feature `{$feature}` cannot be enabled with `#[target_feature]`: {$reason}
codegen_ssa_ignoring_emit_path = ignoring emit path because multiple .{$extension} files were produced
codegen_ssa_ignoring_output = ignoring -o because multiple .{$extension} files were produced
codegen_ssa_incorrect_cgu_reuse_type =
CGU-reuse for `{$cgu_user_name}` is `{$actual_reuse}` but should be {$at_least ->
[one] {"at least "}
*[other] {""}
}`{$expected_reuse}`
codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
codegen_ssa_invalid_monomorphization_basic_float_type = invalid monomorphization of `{$name}` intrinsic: expected basic float type, found `{$ty}`
codegen_ssa_invalid_monomorphization_basic_integer_or_ptr_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer or pointer type, found `{$ty}`
codegen_ssa_invalid_monomorphization_basic_integer_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
codegen_ssa_invalid_monomorphization_cannot_return = invalid monomorphization of `{$name}` intrinsic: cannot return `{$ret_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
codegen_ssa_invalid_monomorphization_cast_wide_pointer = invalid monomorphization of `{$name}` intrinsic: cannot cast wide pointer `{$ty}`
codegen_ssa_invalid_monomorphization_expected_element_type = invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of second argument `{$second_arg}` to be a pointer to the element type `{$in_elem}` of the first argument `{$in_ty}`, found `{$expected_element}` != `{$mutability} {$in_elem}`
codegen_ssa_invalid_monomorphization_expected_pointer = invalid monomorphization of `{$name}` intrinsic: expected pointer, got `{$ty}`
codegen_ssa_invalid_monomorphization_expected_return_type = invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_ty}`, found `{$ret_ty}`
codegen_ssa_invalid_monomorphization_expected_usize = invalid monomorphization of `{$name}` intrinsic: expected `usize`, got `{$ty}`
codegen_ssa_invalid_monomorphization_expected_vector_element_type = invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of vector type `{$vector_type}` to be a signed or unsigned integer type
codegen_ssa_invalid_monomorphization_float_to_int_unchecked = invalid monomorphization of `float_to_int_unchecked` intrinsic: expected basic float type, found `{$ty}`
codegen_ssa_invalid_monomorphization_floating_point_type = invalid monomorphization of `{$name}` intrinsic: `{$in_ty}` is not a floating-point type
codegen_ssa_invalid_monomorphization_floating_point_vector = invalid monomorphization of `{$name}` intrinsic: unsupported element type `{$f_ty}` of floating-point vector `{$in_ty}`
codegen_ssa_invalid_monomorphization_inserted_type = invalid monomorphization of `{$name}` intrinsic: expected inserted type `{$in_elem}` (element of input `{$in_ty}`), found `{$out_ty}`
codegen_ssa_invalid_monomorphization_invalid_bitmask = invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$mask_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
codegen_ssa_invalid_monomorphization_mask_wrong_element_type = invalid monomorphization of `{$name}` intrinsic: expected mask element type to be an integer, found `{$ty}`
codegen_ssa_invalid_monomorphization_mismatched_lengths = invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`
codegen_ssa_invalid_monomorphization_non_scalable_type = invalid monomorphization of `{$name}` intrinsic: expected non-scalable type, found scalable type `{$ty}`
codegen_ssa_invalid_monomorphization_return_element = invalid monomorphization of `{$name}` intrinsic: expected return element type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}` with element type `{$out_ty}`
codegen_ssa_invalid_monomorphization_return_integer_type = invalid monomorphization of `{$name}` intrinsic: expected return type with integer elements, found `{$ret_ty}` with non-integer `{$out_ty}`
codegen_ssa_invalid_monomorphization_return_length = invalid monomorphization of `{$name}` intrinsic: expected return type of length {$in_len}, found `{$ret_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_return_length_input_type = invalid monomorphization of `{$name}` intrinsic: expected return type with length {$in_len} (same as input type `{$in_ty}`), found `{$ret_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_return_type = invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}`
codegen_ssa_invalid_monomorphization_second_argument_length = invalid monomorphization of `{$name}` intrinsic: expected second argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_simd_argument = invalid monomorphization of `{$name}` intrinsic: expected SIMD argument type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_first = invalid monomorphization of `{$name}` intrinsic: expected SIMD first type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds = invalid monomorphization of `{$name}` intrinsic: SIMD index #{$arg_idx} is out of bounds (limit {$total_len})
codegen_ssa_invalid_monomorphization_simd_input = invalid monomorphization of `{$name}` intrinsic: expected SIMD input type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_return = invalid monomorphization of `{$name}` intrinsic: expected SIMD return type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_second = invalid monomorphization of `{$name}` intrinsic: expected SIMD second type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_shuffle = invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be a SIMD vector of `u32`, got `{$ty}`
codegen_ssa_invalid_monomorphization_simd_third = invalid monomorphization of `{$name}` intrinsic: expected SIMD third type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_third_argument_length = invalid monomorphization of `{$name}` intrinsic: expected third argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_unrecognized_intrinsic = invalid monomorphization of `{$name}` intrinsic: unrecognized intrinsic `{$name}`
codegen_ssa_invalid_monomorphization_unsupported_cast = invalid monomorphization of `{$name}` intrinsic: unsupported cast from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}` with element `{$out_elem}`
codegen_ssa_invalid_monomorphization_unsupported_operation = invalid monomorphization of `{$name}` intrinsic: unsupported operation on `{$in_ty}` with element `{$in_elem}`
codegen_ssa_invalid_monomorphization_unsupported_symbol = invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}`
codegen_ssa_invalid_monomorphization_unsupported_symbol_of_size = invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` of size `{$size}` to `{$ret_ty}`
codegen_ssa_ld64_unimplemented_modifier = `as-needed` modifier not implemented yet for ld64
codegen_ssa_lib_def_write_failure = failed to write lib.def file: {$error}
codegen_ssa_link_exe_status_stack_buffer_overrun = 0xc0000409 is `STATUS_STACK_BUFFER_OVERRUN`
.abort_note = this may have been caused by a program abort and not a stack buffer overrun
.event_log_note = consider checking the Application Event Log for Windows Error Reporting events to see the fail fast error code
codegen_ssa_link_exe_unexpected_error = `link.exe` returned an unexpected error
codegen_ssa_link_script_unavailable = can only use link script when linking with GNU-like linker
codegen_ssa_link_script_write_failure = failed to write link script to {$path}: {$error}
codegen_ssa_linker_file_stem = couldn't extract file stem from specified linker
codegen_ssa_linker_not_found = linker `{$linker_path}` not found
.note = {$error}
codegen_ssa_linker_output = {$inner}
codegen_ssa_linker_unsupported_modifier = `as-needed` modifier not supported for current linker
codegen_ssa_linking_failed = linking with `{$linker_path}` failed: {$exit_status}
codegen_ssa_lto_disallowed = lto can only be run for executables, cdylibs and static library outputs
codegen_ssa_lto_dylib = lto cannot be used for `dylib` crate type without `-Zdylib-lto`
codegen_ssa_lto_proc_macro = lto cannot be used for `proc-macro` crate type without `-Zdylib-lto`
codegen_ssa_malformed_cgu_name =
found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case).
codegen_ssa_missing_cpp_build_tool_component = or a necessary component may be missing from the "C++ build tools" workload
codegen_ssa_missing_features = add the missing features in a `target_feature` attribute
codegen_ssa_missing_query_depgraph =
found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
codegen_ssa_msvc_missing_linker = the msvc targets depend on the msvc linker but `link.exe` was not found
codegen_ssa_multiple_external_func_decl = multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions
codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple times
.help = did you use `#[no_mangle]` on `fn main`? Use `#![no_main]` to suppress the usual Rust-generated entry point
codegen_ssa_no_field = no field `{$name}`
codegen_ssa_no_module_named =
no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}
codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
codegen_ssa_no_saved_object_file = cached cgu {$cgu_name} should have an object file, but doesn't
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
.note = {$output}
codegen_ssa_read_file = failed to read file: {$message}
codegen_ssa_repair_vs_build_tools = the Visual Studio build tools may need to be repaired using the Visual Studio installer
codegen_ssa_requires_rust_abi = `#[track_caller]` requires Rust ABI
codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib at `{$path}`: {$error}
codegen_ssa_rlib_incompatible_dependency_formats = `{$ty1}` and `{$ty2}` do not have equivalent dependency formats (`{$list1}` vs `{$list2}`)
codegen_ssa_rlib_missing_format = could not find formats for rlibs
codegen_ssa_rlib_not_found = could not find rlib for: `{$crate_name}`
codegen_ssa_rlib_only_rmeta_found = could not find rlib for: `{$crate_name}`, found rmeta (metadata) file
codegen_ssa_select_cpp_build_tool_workload = in the Visual Studio installer, ensure the "C++ build tools" workload is selected
codegen_ssa_self_contained_linker_missing = the self-contained linker was requested, but it wasn't found in the target's sysroot, or in rustc's sysroot
codegen_ssa_shuffle_indices_evaluation = could not evaluate shuffle_indices at compile time
codegen_ssa_specify_libraries_to_link = use the `-l` flag to specify native libraries to link
codegen_ssa_static_library_native_artifacts = link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
codegen_ssa_static_library_native_artifacts_to_file = native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms.
codegen_ssa_stripping_debug_info_failed = stripping debug info with `{$util}` failed: {$status}
.note = {$output}
codegen_ssa_symbol_file_write_failure = failed to write symbols file: {$error}
codegen_ssa_target_feature_disable_or_enable =
the target features {$features} must all be either enabled or disabled together
codegen_ssa_target_feature_safe_trait = `#[target_feature(..)]` cannot be applied to safe trait method
.label = cannot be applied to safe trait method
.label_def = not an `unsafe` function
codegen_ssa_thorin_decompress_data = failed to decompress compressed section
codegen_ssa_thorin_duplicate_unit = duplicate split compilation unit ({$unit})
codegen_ssa_thorin_empty_unit = unit {$unit} in input DWARF object with no data
codegen_ssa_thorin_gimli_read = {$error}
codegen_ssa_thorin_gimli_write = {$error}
codegen_ssa_thorin_incompatible_index_version = incompatible `{$section}` index version: found version {$actual}, expected version {$format}
codegen_ssa_thorin_invalid_input_kind = input is not an archive or elf object
codegen_ssa_thorin_io = {$error}
codegen_ssa_thorin_missing_dwo_name = missing path attribute to DWARF object ({$id})
codegen_ssa_thorin_missing_referenced_unit = unit {$unit} referenced by executable was not found
codegen_ssa_thorin_missing_required_section = input object missing required section `{$section}`
codegen_ssa_thorin_mixed_input_encodings = input objects have mixed encodings
codegen_ssa_thorin_multiple_debug_info_section = multiple `.debug_info.dwo` sections
codegen_ssa_thorin_multiple_debug_types_section = multiple `.debug_types.dwo` sections in a package
codegen_ssa_thorin_multiple_relocations = multiple relocations for section `{$section}` at offset {$offset}
codegen_ssa_thorin_no_compilation_units = input object has no compilation units
codegen_ssa_thorin_no_die = no top-level debugging information entry in compilation/type unit
codegen_ssa_thorin_not_output_object_created = no output object was created from inputs
codegen_ssa_thorin_not_split_unit = regular compilation unit in object (missing dwo identifier)
codegen_ssa_thorin_object_read = {$error}
codegen_ssa_thorin_object_write = {$error}
codegen_ssa_thorin_offset_at_index = read offset at index {$index} of `.debug_str_offsets.dwo` section
codegen_ssa_thorin_parse_archive_member = failed to parse archive member
codegen_ssa_thorin_parse_index = failed to parse `{$section}` index section
codegen_ssa_thorin_parse_input_archive_file = failed to parse input archive file
codegen_ssa_thorin_parse_input_file_kind = failed to parse input file kind
codegen_ssa_thorin_parse_input_object_file = failed to parse input object file
codegen_ssa_thorin_parse_unit = failed to parse unit
codegen_ssa_thorin_parse_unit_abbreviations = failed to parse unit abbreviations
codegen_ssa_thorin_parse_unit_attribute = failed to parse unit attribute
codegen_ssa_thorin_parse_unit_header = failed to parse unit header
codegen_ssa_thorin_read_input_failure = failed to read input file
codegen_ssa_thorin_relocation_with_invalid_symbol = relocation with invalid symbol for section `{$section}` at offset {$offset}
codegen_ssa_thorin_row_not_in_index = row {$row} found in index's hash table not present in index
codegen_ssa_thorin_section_not_in_row = section not found in unit's row in index
codegen_ssa_thorin_section_without_name = section without name at offset {$offset}
codegen_ssa_thorin_str_at_offset = read string at offset {$offset} of `.debug_str.dwo` section
codegen_ssa_thorin_top_level_die_not_unit = top-level debugging information entry is not a compilation/type unit
codegen_ssa_thorin_unit_not_in_index = unit {$unit} from input package is not in its index
codegen_ssa_thorin_unsupported_relocation = unsupported relocation for section {$section} at offset {$offset}
codegen_ssa_unable_to_exe_linker = could not exec the linker `{$linker_path}`
.note = {$error}
.command_note = {$command_formatted}
codegen_ssa_unable_to_run = unable to run `{$util}`: {$error}
codegen_ssa_unable_to_run_dsymutil = unable to run `dsymutil`: {$error}
codegen_ssa_unable_to_write_debugger_visualizer = unable to write debugger visualizer file `{$path}`: {$error}
codegen_ssa_unknown_archive_kind =
don't know how to build archive of type: {$kind}
codegen_ssa_unknown_ctarget_feature =
unknown and unstable feature specified for `-Ctarget-feature`: `{$feature}`
.note = it is still passed through to the codegen backend, but use of this feature might be unsound and the behavior of this feature can change in the future
.possible_feature = you might have meant: `{$rust_feature}`
.consider_filing_feature_request = consider filing a feature request
codegen_ssa_unknown_ctarget_feature_prefix =
unknown feature specified for `-Ctarget-feature`: `{$feature}`
.note = features must begin with a `+` to enable or `-` to disable it
codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
codegen_ssa_unstable_ctarget_feature =
unstable feature specified for `-Ctarget-feature`: `{$feature}`
.note = this feature is not stably supported; its behavior can change in the future
codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target
codegen_ssa_use_cargo_directive = use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
codegen_ssa_version_script_write_failure = failed to write version script: {$error}
codegen_ssa_visual_studio_not_installed = you may need to install Visual Studio build tools with the "C++ build tools" workload
codegen_ssa_xcrun_about =
the SDK is needed by the linker to know where to find symbols in system libraries and for embedding the SDK version in the final object file
codegen_ssa_xcrun_command_line_tools_insufficient =
when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode
codegen_ssa_xcrun_failed_invoking = invoking `{$command_formatted}` to find {$sdk_name}.sdk failed: {$error}
codegen_ssa_xcrun_found_developer_dir = found active developer directory at "{$developer_dir}"
# `xcrun` already outputs a message about missing Xcode installation, so we only augment it with details about env vars.
codegen_ssa_xcrun_no_developer_dir =
pass the path of an Xcode installation via the DEVELOPER_DIR environment variable, or an SDK with the SDKROOT environment variable
codegen_ssa_xcrun_sdk_path_warning = output of `xcrun` while finding {$sdk_name}.sdk
.note = {$stderr}
codegen_ssa_xcrun_unsuccessful = failed running `{$command_formatted}` to find {$sdk_name}.sdk
.note = {$stdout}{$stderr}
+7 -5
View File
@@ -3,6 +3,7 @@
use std::process::Command;
use itertools::Itertools;
use rustc_errors::inline_fluent;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
use rustc_session::Session;
pub(super) use rustc_target::spec::apple::OSVersion;
@@ -10,7 +11,6 @@
use tracing::debug;
use crate::errors::{XcrunError, XcrunSdkPathWarning};
use crate::fluent_generated as fluent;
#[cfg(test)]
mod tests;
@@ -185,19 +185,21 @@ pub(super) fn get_sdk_root(sess: &Session) -> Option<PathBuf> {
// FIXME(madsmtm): Make this a lint, to allow deny warnings to work.
// (Or fix <https://github.com/rust-lang/rust/issues/21204>).
let mut diag = sess.dcx().create_warn(err);
diag.note(fluent::codegen_ssa_xcrun_about);
diag.note(inline_fluent!("the SDK is needed by the linker to know where to find symbols in system libraries and for embedding the SDK version in the final object file"));
// Recognize common error cases, and give more Rust-specific error messages for those.
if let Some(developer_dir) = xcode_select_developer_dir() {
diag.arg("developer_dir", &developer_dir);
diag.note(fluent::codegen_ssa_xcrun_found_developer_dir);
diag.note(inline_fluent!(
"found active developer directory at \"{$developer_dir}\""
));
if developer_dir.as_os_str().to_string_lossy().contains("CommandLineTools") {
if sdk_name != "MacOSX" {
diag.help(fluent::codegen_ssa_xcrun_command_line_tools_insufficient);
diag.help(inline_fluent!("when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode"));
}
}
} else {
diag.help(fluent::codegen_ssa_xcrun_no_developer_dir);
diag.help(inline_fluent!("pass the path of an Xcode installation via the DEVELOPER_DIR environment variable, or an SDK with the SDKROOT environment variable"));
}
diag.emit();
+1 -1
View File
@@ -662,7 +662,7 @@ fn read_input(&self, path: &Path) -> std::io::Result<&[u8]> {
}
#[derive(LintDiagnostic)]
#[diag(codegen_ssa_linker_output)]
#[diag("{$inner}")]
/// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
/// end up with inconsistent languages within the same diagnostic.
struct LinkerOutput {
+244 -199
View File
@@ -9,6 +9,7 @@
use rustc_errors::codes::*;
use rustc_errors::{
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
inline_fluent,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::layout::LayoutError;
@@ -17,10 +18,14 @@
use crate::assert_module_sources::CguReuse;
use crate::back::command::Command;
use crate::fluent_generated as fluent;
#[derive(Diagnostic)]
#[diag(codegen_ssa_incorrect_cgu_reuse_type)]
#[diag(
"CGU-reuse for `{$cgu_user_name}` is `{$actual_reuse}` but should be {$at_least ->
[one] {\"at least \"}
*[other] {\"\"}
}`{$expected_reuse}`"
)]
pub(crate) struct IncorrectCguReuseType<'a> {
#[primary_span]
pub span: Span,
@@ -31,14 +36,14 @@ pub(crate) struct IncorrectCguReuseType<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_cgu_not_recorded)]
#[diag("CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded")]
pub(crate) struct CguNotRecorded<'a> {
pub cgu_user_name: &'a str,
pub cgu_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_reuse_kind)]
#[diag("unknown cgu-reuse-kind `{$kind}` specified")]
pub(crate) struct UnknownReuseKind {
#[primary_span]
pub span: Span,
@@ -46,14 +51,16 @@ pub(crate) struct UnknownReuseKind {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_missing_query_depgraph)]
#[diag("found CGU-reuse attribute but `-Zquery-dep-graph` was not specified")]
pub(crate) struct MissingQueryDepGraph {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_malformed_cgu_name)]
#[diag(
"found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case)."
)]
pub(crate) struct MalformedCguName {
#[primary_span]
pub span: Span,
@@ -62,7 +69,7 @@ pub(crate) struct MalformedCguName {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_module_named)]
#[diag("no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}")]
pub(crate) struct NoModuleNamed<'a> {
#[primary_span]
pub span: Span,
@@ -72,7 +79,7 @@ pub(crate) struct NoModuleNamed<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_field_associated_value_expected)]
#[diag("associated value expected for `{$name}`")]
pub(crate) struct FieldAssociatedValueExpected {
#[primary_span]
pub span: Span,
@@ -80,7 +87,7 @@ pub(crate) struct FieldAssociatedValueExpected {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_field)]
#[diag("no field `{$name}`")]
pub(crate) struct NoField {
#[primary_span]
pub span: Span,
@@ -88,56 +95,56 @@ pub(crate) struct NoField {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_lib_def_write_failure)]
#[diag("failed to write lib.def file: {$error}")]
pub(crate) struct LibDefWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_version_script_write_failure)]
#[diag("failed to write version script: {$error}")]
pub(crate) struct VersionScriptWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_symbol_file_write_failure)]
#[diag("failed to write symbols file: {$error}")]
pub(crate) struct SymbolFileWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_ld64_unimplemented_modifier)]
#[diag("`as-needed` modifier not implemented yet for ld64")]
pub(crate) struct Ld64UnimplementedModifier;
#[derive(Diagnostic)]
#[diag(codegen_ssa_linker_unsupported_modifier)]
#[diag("`as-needed` modifier not supported for current linker")]
pub(crate) struct LinkerUnsupportedModifier;
#[derive(Diagnostic)]
#[diag(codegen_ssa_L4Bender_exporting_symbols_unimplemented)]
#[diag("exporting symbols not implemented yet for L4Bender")]
pub(crate) struct L4BenderExportingSymbolsUnimplemented;
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_natvis_directory)]
#[diag("error enumerating natvis directory: {$error}")]
pub(crate) struct NoNatvisDirectory {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_saved_object_file)]
#[diag("cached cgu {$cgu_name} should have an object file, but doesn't")]
pub(crate) struct NoSavedObjectFile<'a> {
pub cgu_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_requires_rust_abi, code = E0737)]
#[diag("`#[track_caller]` requires Rust ABI", code = E0737)]
pub(crate) struct RequiresRustAbi {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_copy_path_buf)]
#[diag("unable to copy {$source_file} to {$output_path}: {$error}")]
pub(crate) struct CopyPathBuf {
pub source_file: PathBuf,
pub output_path: PathBuf,
@@ -146,7 +153,7 @@ pub(crate) struct CopyPathBuf {
// Reports Paths using `Debug` implementation rather than Path's `Display` implementation.
#[derive(Diagnostic)]
#[diag(codegen_ssa_copy_path)]
#[diag("could not copy {$from} to {$to}: {$error}")]
pub struct CopyPath<'a> {
from: DebugArgPath<'a>,
to: DebugArgPath<'a>,
@@ -168,38 +175,42 @@ fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> rustc_errors::Diag
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_binary_output_to_tty)]
#[diag(
"option `-o` or `--emit` is used to write binary output type `{$shorthand}` to stdout, but stdout is a tty"
)]
pub struct BinaryOutputToTty {
pub shorthand: &'static str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_ignoring_emit_path)]
#[diag("ignoring emit path because multiple .{$extension} files were produced")]
pub struct IgnoringEmitPath {
pub extension: &'static str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_ignoring_output)]
#[diag("ignoring -o because multiple .{$extension} files were produced")]
pub struct IgnoringOutput {
pub extension: &'static str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_create_temp_dir)]
#[diag("couldn't create a temp dir: {$error}")]
pub(crate) struct CreateTempDir {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_add_native_library)]
#[diag("failed to add native library {$library_path}: {$error}")]
pub(crate) struct AddNativeLibrary {
pub library_path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_multiple_external_func_decl)]
#[diag(
"multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions"
)]
pub(crate) struct MultipleExternalFuncDecl<'a> {
#[primary_span]
pub span: Span,
@@ -209,16 +220,18 @@ pub(crate) struct MultipleExternalFuncDecl<'a> {
#[derive(Diagnostic)]
pub enum LinkRlibError {
#[diag(codegen_ssa_rlib_missing_format)]
#[diag("could not find formats for rlibs")]
MissingFormat,
#[diag(codegen_ssa_rlib_only_rmeta_found)]
#[diag("could not find rlib for: `{$crate_name}`, found rmeta (metadata) file")]
OnlyRmetaFound { crate_name: Symbol },
#[diag(codegen_ssa_rlib_not_found)]
#[diag("could not find rlib for: `{$crate_name}`")]
NotFound { crate_name: Symbol },
#[diag(codegen_ssa_rlib_incompatible_dependency_formats)]
#[diag(
"`{$ty1}` and `{$ty2}` do not have equivalent dependency formats (`{$list1}` vs `{$list2}`)"
)]
IncompatibleDependencyFormats { ty1: String, ty2: String, list1: String, list2: String },
}
@@ -228,122 +241,122 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let build = |msg| Diag::new(dcx, level, msg);
match self.0 {
thorin::Error::ReadInput(_) => build(fluent::codegen_ssa_thorin_read_input_failure),
thorin::Error::ReadInput(_) => build(inline_fluent!("failed to read input file")),
thorin::Error::ParseFileKind(_) => {
build(fluent::codegen_ssa_thorin_parse_input_file_kind)
build(inline_fluent!("failed to parse input file kind"))
}
thorin::Error::ParseObjectFile(_) => {
build(fluent::codegen_ssa_thorin_parse_input_object_file)
build(inline_fluent!("failed to parse input object file"))
}
thorin::Error::ParseArchiveFile(_) => {
build(fluent::codegen_ssa_thorin_parse_input_archive_file)
build(inline_fluent!("failed to parse input archive file"))
}
thorin::Error::ParseArchiveMember(_) => {
build(fluent::codegen_ssa_thorin_parse_archive_member)
build(inline_fluent!("failed to parse archive member"))
}
thorin::Error::InvalidInputKind => build(fluent::codegen_ssa_thorin_invalid_input_kind),
thorin::Error::DecompressData(_) => build(fluent::codegen_ssa_thorin_decompress_data),
thorin::Error::InvalidInputKind => build(inline_fluent!("input is not an archive or elf object")),
thorin::Error::DecompressData(_) => build(inline_fluent!("failed to decompress compressed section")),
thorin::Error::NamelessSection(_, offset) => {
build(fluent::codegen_ssa_thorin_section_without_name)
build(inline_fluent!("section without name at offset {$offset}"))
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::RelocationWithInvalidSymbol(section, offset) => {
build(fluent::codegen_ssa_thorin_relocation_with_invalid_symbol)
build(inline_fluent!("relocation with invalid symbol for section `{$section}` at offset {$offset}"))
.with_arg("section", section)
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::MultipleRelocations(section, offset) => {
build(fluent::codegen_ssa_thorin_multiple_relocations)
build(inline_fluent!("multiple relocations for section `{$section}` at offset {$offset}"))
.with_arg("section", section)
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::UnsupportedRelocation(section, offset) => {
build(fluent::codegen_ssa_thorin_unsupported_relocation)
build(inline_fluent!("unsupported relocation for section {$section} at offset {$offset}"))
.with_arg("section", section)
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::MissingDwoName(id) => build(fluent::codegen_ssa_thorin_missing_dwo_name)
thorin::Error::MissingDwoName(id) => build(inline_fluent!("missing path attribute to DWARF object ({$id})"))
.with_arg("id", format!("0x{id:08x}")),
thorin::Error::NoCompilationUnits => {
build(fluent::codegen_ssa_thorin_no_compilation_units)
build(inline_fluent!("input object has no compilation units"))
}
thorin::Error::NoDie => build(fluent::codegen_ssa_thorin_no_die),
thorin::Error::NoDie => build(inline_fluent!("no top-level debugging information entry in compilation/type unit")),
thorin::Error::TopLevelDieNotUnit => {
build(fluent::codegen_ssa_thorin_top_level_die_not_unit)
build(inline_fluent!("top-level debugging information entry is not a compilation/type unit"))
}
thorin::Error::MissingRequiredSection(section) => {
build(fluent::codegen_ssa_thorin_missing_required_section)
build(inline_fluent!("input object missing required section `{$section}`"))
.with_arg("section", section)
}
thorin::Error::ParseUnitAbbreviations(_) => {
build(fluent::codegen_ssa_thorin_parse_unit_abbreviations)
build(inline_fluent!("failed to parse unit abbreviations"))
}
thorin::Error::ParseUnitAttribute(_) => {
build(fluent::codegen_ssa_thorin_parse_unit_attribute)
build(inline_fluent!("failed to parse unit attribute"))
}
thorin::Error::ParseUnitHeader(_) => {
build(fluent::codegen_ssa_thorin_parse_unit_header)
build(inline_fluent!("failed to parse unit header"))
}
thorin::Error::ParseUnit(_) => build(fluent::codegen_ssa_thorin_parse_unit),
thorin::Error::ParseUnit(_) => build(inline_fluent!("failed to parse unit")),
thorin::Error::IncompatibleIndexVersion(section, format, actual) => {
build(fluent::codegen_ssa_thorin_incompatible_index_version)
build(inline_fluent!("incompatible `{$section}` index version: found version {$actual}, expected version {$format}"))
.with_arg("section", section)
.with_arg("actual", actual)
.with_arg("format", format)
}
thorin::Error::OffsetAtIndex(_, index) => {
build(fluent::codegen_ssa_thorin_offset_at_index).with_arg("index", index)
build(inline_fluent!("read offset at index {$index} of `.debug_str_offsets.dwo` section")).with_arg("index", index)
}
thorin::Error::StrAtOffset(_, offset) => {
build(fluent::codegen_ssa_thorin_str_at_offset)
build(inline_fluent!("read string at offset {$offset} of `.debug_str.dwo` section"))
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::ParseIndex(_, section) => {
build(fluent::codegen_ssa_thorin_parse_index).with_arg("section", section)
build(inline_fluent!("failed to parse `{$section}` index section")).with_arg("section", section)
}
thorin::Error::UnitNotInIndex(unit) => {
build(fluent::codegen_ssa_thorin_unit_not_in_index)
build(inline_fluent!("unit {$unit} from input package is not in its index"))
.with_arg("unit", format!("0x{unit:08x}"))
}
thorin::Error::RowNotInIndex(_, row) => {
build(fluent::codegen_ssa_thorin_row_not_in_index).with_arg("row", row)
build(inline_fluent!("row {$row} found in index's hash table not present in index")).with_arg("row", row)
}
thorin::Error::SectionNotInRow => build(fluent::codegen_ssa_thorin_section_not_in_row),
thorin::Error::EmptyUnit(unit) => build(fluent::codegen_ssa_thorin_empty_unit)
thorin::Error::SectionNotInRow => build(inline_fluent!("section not found in unit's row in index")),
thorin::Error::EmptyUnit(unit) => build(inline_fluent!("unit {$unit} in input DWARF object with no data"))
.with_arg("unit", format!("0x{unit:08x}")),
thorin::Error::MultipleDebugInfoSection => {
build(fluent::codegen_ssa_thorin_multiple_debug_info_section)
build(inline_fluent!("multiple `.debug_info.dwo` sections"))
}
thorin::Error::MultipleDebugTypesSection => {
build(fluent::codegen_ssa_thorin_multiple_debug_types_section)
build(inline_fluent!("multiple `.debug_types.dwo` sections in a package"))
}
thorin::Error::NotSplitUnit => build(fluent::codegen_ssa_thorin_not_split_unit),
thorin::Error::DuplicateUnit(unit) => build(fluent::codegen_ssa_thorin_duplicate_unit)
thorin::Error::NotSplitUnit => build(inline_fluent!("regular compilation unit in object (missing dwo identifier)")),
thorin::Error::DuplicateUnit(unit) => build(inline_fluent!("duplicate split compilation unit ({$unit})"))
.with_arg("unit", format!("0x{unit:08x}")),
thorin::Error::MissingReferencedUnit(unit) => {
build(fluent::codegen_ssa_thorin_missing_referenced_unit)
build(inline_fluent!("unit {$unit} referenced by executable was not found"))
.with_arg("unit", format!("0x{unit:08x}"))
}
thorin::Error::NoOutputObjectCreated => {
build(fluent::codegen_ssa_thorin_not_output_object_created)
build(inline_fluent!("no output object was created from inputs"))
}
thorin::Error::MixedInputEncodings => {
build(fluent::codegen_ssa_thorin_mixed_input_encodings)
build(inline_fluent!("input objects have mixed encodings"))
}
thorin::Error::Io(e) => {
build(fluent::codegen_ssa_thorin_io).with_arg("error", format!("{e}"))
build(inline_fluent!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::ObjectRead(e) => {
build(fluent::codegen_ssa_thorin_object_read).with_arg("error", format!("{e}"))
build(inline_fluent!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::ObjectWrite(e) => {
build(fluent::codegen_ssa_thorin_object_write).with_arg("error", format!("{e}"))
build(inline_fluent!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::GimliRead(e) => {
build(fluent::codegen_ssa_thorin_gimli_read).with_arg("error", format!("{e}"))
build(inline_fluent!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::GimliWrite(e) => {
build(fluent::codegen_ssa_thorin_gimli_write).with_arg("error", format!("{e}"))
build(inline_fluent!("{$error}")).with_arg("error", format!("{e}"))
}
_ => unimplemented!("Untranslated thorin error"),
}
@@ -361,7 +374,11 @@ pub(crate) struct LinkingFailed<'a> {
impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
fn into_diag(mut self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let mut diag = Diag::new(dcx, level, fluent::codegen_ssa_linking_failed);
let mut diag = Diag::new(
dcx,
level,
inline_fluent!("linking with `{$linker_path}` failed: {$exit_status}"),
);
diag.arg("linker_path", format!("{}", self.linker_path.display()));
diag.arg("exit_status", format!("{}", self.exit_status));
@@ -470,11 +487,11 @@ enum ArgGroup {
// Trying to match an error from OS linkers
// which by now we have no way to translate.
if contains_undefined_ref {
diag.note(fluent::codegen_ssa_extern_funcs_not_found)
.note(fluent::codegen_ssa_specify_libraries_to_link);
diag.note(inline_fluent!("some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified"))
.note(inline_fluent!("use the `-l` flag to specify native libraries to link"));
if rustc_session::utils::was_invoked_from_cargo() {
diag.note(fluent::codegen_ssa_use_cargo_directive);
diag.note(inline_fluent!("use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)"));
}
}
diag
@@ -482,7 +499,7 @@ enum ArgGroup {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_link_exe_unexpected_error)]
#[diag("`link.exe` returned an unexpected error")]
pub(crate) struct LinkExeUnexpectedError;
pub(crate) struct LinkExeStatusStackBufferOverrun;
@@ -490,41 +507,43 @@ enum ArgGroup {
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for LinkExeStatusStackBufferOverrun {
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let mut diag =
Diag::new(dcx, level, fluent::codegen_ssa_link_exe_status_stack_buffer_overrun);
diag.note(fluent::codegen_ssa_abort_note);
diag.note(fluent::codegen_ssa_event_log_note);
Diag::new(dcx, level, inline_fluent!("0xc0000409 is `STATUS_STACK_BUFFER_OVERRUN`"));
diag.note(inline_fluent!(
"this may have been caused by a program abort and not a stack buffer overrun"
));
diag.note(inline_fluent!("consider checking the Application Event Log for Windows Error Reporting events to see the fail fast error code"));
diag
}
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_repair_vs_build_tools)]
#[diag("the Visual Studio build tools may need to be repaired using the Visual Studio installer")]
pub(crate) struct RepairVSBuildTools;
#[derive(Diagnostic)]
#[diag(codegen_ssa_missing_cpp_build_tool_component)]
#[diag("or a necessary component may be missing from the \"C++ build tools\" workload")]
pub(crate) struct MissingCppBuildToolComponent;
#[derive(Diagnostic)]
#[diag(codegen_ssa_select_cpp_build_tool_workload)]
#[diag("in the Visual Studio installer, ensure the \"C++ build tools\" workload is selected")]
pub(crate) struct SelectCppBuildToolWorkload;
#[derive(Diagnostic)]
#[diag(codegen_ssa_visual_studio_not_installed)]
#[diag("you may need to install Visual Studio build tools with the \"C++ build tools\" workload")]
pub(crate) struct VisualStudioNotInstalled;
#[derive(Diagnostic)]
#[diag(codegen_ssa_linker_not_found)]
#[note]
#[diag("linker `{$linker_path}` not found")]
#[note("{$error}")]
pub(crate) struct LinkerNotFound {
pub linker_path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_exe_linker)]
#[note]
#[note(codegen_ssa_command_note)]
#[diag("could not exec the linker `{$linker_path}`")]
#[note("{$error}")]
#[note("{$command_formatted}")]
pub(crate) struct UnableToExeLinker {
pub linker_path: PathBuf,
pub error: Error,
@@ -532,42 +551,46 @@ pub(crate) struct UnableToExeLinker {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_msvc_missing_linker)]
#[diag("the msvc targets depend on the msvc linker but `link.exe` was not found")]
pub(crate) struct MsvcMissingLinker;
#[derive(Diagnostic)]
#[diag(codegen_ssa_self_contained_linker_missing)]
#[diag(
"the self-contained linker was requested, but it wasn't found in the target's sysroot, or in rustc's sysroot"
)]
pub(crate) struct SelfContainedLinkerMissing;
#[derive(Diagnostic)]
#[diag(codegen_ssa_check_installed_visual_studio)]
#[diag(
"please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option."
)]
pub(crate) struct CheckInstalledVisualStudio;
#[derive(Diagnostic)]
#[diag(codegen_ssa_insufficient_vs_code_product)]
#[diag("VS Code is a different product, and is not sufficient.")]
pub(crate) struct InsufficientVSCodeProduct;
#[derive(Diagnostic)]
#[diag(codegen_ssa_cpu_required)]
#[diag("target requires explicitly specifying a cpu with `-C target-cpu`")]
pub(crate) struct CpuRequired;
#[derive(Diagnostic)]
#[diag(codegen_ssa_processing_dymutil_failed)]
#[note]
#[diag("processing debug info with `dsymutil` failed: {$status}")]
#[note("{$output}")]
pub(crate) struct ProcessingDymutilFailed {
pub status: ExitStatus,
pub output: String,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_run_dsymutil)]
#[diag("unable to run `dsymutil`: {$error}")]
pub(crate) struct UnableToRunDsymutil {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_stripping_debug_info_failed)]
#[note]
#[diag("stripping debug info with `{$util}` failed: {$status}")]
#[note("{$output}")]
pub(crate) struct StrippingDebugInfoFailed<'a> {
pub util: &'a str,
pub status: ExitStatus,
@@ -575,53 +598,57 @@ pub(crate) struct StrippingDebugInfoFailed<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_run)]
#[diag("unable to run `{$util}`: {$error}")]
pub(crate) struct UnableToRun<'a> {
pub util: &'a str,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_linker_file_stem)]
#[diag("couldn't extract file stem from specified linker")]
pub(crate) struct LinkerFileStem;
#[derive(Diagnostic)]
#[diag(codegen_ssa_static_library_native_artifacts)]
#[diag(
"link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms."
)]
pub(crate) struct StaticLibraryNativeArtifacts;
#[derive(Diagnostic)]
#[diag(codegen_ssa_static_library_native_artifacts_to_file)]
#[diag(
"native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms."
)]
pub(crate) struct StaticLibraryNativeArtifactsToFile<'a> {
pub path: &'a Path,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_link_script_unavailable)]
#[diag("can only use link script when linking with GNU-like linker")]
pub(crate) struct LinkScriptUnavailable;
#[derive(Diagnostic)]
#[diag(codegen_ssa_link_script_write_failure)]
#[diag("failed to write link script to {$path}: {$error}")]
pub(crate) struct LinkScriptWriteFailure {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_failed_to_write)]
#[diag("failed to write {$path}: {$error}")]
pub(crate) struct FailedToWrite {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_write_debugger_visualizer)]
#[diag("unable to write debugger visualizer file `{$path}`: {$error}")]
pub(crate) struct UnableToWriteDebuggerVisualizer {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_rlib_archive_build_failure)]
#[diag("failed to build archive from rlib at `{$path}`: {$error}")]
pub(crate) struct RlibArchiveBuildFailure {
pub path: PathBuf,
pub error: Error,
@@ -630,68 +657,70 @@ pub(crate) struct RlibArchiveBuildFailure {
#[derive(Diagnostic)]
// Public for ArchiveBuilderBuilder::extract_bundled_libs
pub enum ExtractBundledLibsError<'a> {
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
#[diag("failed to open file '{$rlib}': {$error}")]
OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag(codegen_ssa_extract_bundled_libs_mmap_file)]
#[diag("failed to mmap file '{$rlib}': {$error}")]
MmapFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag(codegen_ssa_extract_bundled_libs_parse_archive)]
#[diag("failed to parse archive '{$rlib}': {$error}")]
ParseArchive { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag(codegen_ssa_extract_bundled_libs_read_entry)]
#[diag("failed to read entry '{$rlib}': {$error}")]
ReadEntry { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag(codegen_ssa_extract_bundled_libs_archive_member)]
#[diag("failed to get data from archive member '{$rlib}': {$error}")]
ArchiveMember { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag(codegen_ssa_extract_bundled_libs_convert_name)]
#[diag("failed to convert name '{$rlib}': {$error}")]
ConvertName { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag(codegen_ssa_extract_bundled_libs_write_file)]
#[diag("failed to write file '{$rlib}': {$error}")]
WriteFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag(codegen_ssa_extract_bundled_libs_write_file)]
#[diag("failed to write file '{$rlib}': {$error}")]
ExtractSection { rlib: &'a Path, error: Box<dyn std::error::Error> },
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_read_file)]
#[diag("failed to read file: {$message}")]
pub(crate) struct ReadFileError {
pub message: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unsupported_link_self_contained)]
#[diag("option `-C link-self-contained` is not supported on this target")]
pub(crate) struct UnsupportedLinkSelfContained;
#[derive(Diagnostic)]
#[diag(codegen_ssa_archive_build_failure)]
#[diag("failed to build archive at `{$path}`: {$error}")]
pub(crate) struct ArchiveBuildFailure {
pub path: PathBuf,
pub error: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_archive_kind)]
#[diag("don't know how to build archive of type: {$kind}")]
pub(crate) struct UnknownArchiveKind<'a> {
pub kind: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_bpf_staticlib_not_supported)]
#[diag("linking static libraries is not supported for BPF")]
pub(crate) struct BpfStaticlibNotSupported;
#[derive(Diagnostic)]
#[diag(codegen_ssa_multiple_main_functions)]
#[help]
#[diag("entry symbol `main` declared multiple times")]
#[help(
"did you use `#[no_mangle]` on `fn main`? Use `#![no_main]` to suppress the usual Rust-generated entry point"
)]
pub(crate) struct MultipleMainFunctions {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_shuffle_indices_evaluation)]
#[diag("could not evaluate shuffle_indices at compile time")]
pub(crate) struct ShuffleIndicesEvaluation {
#[primary_span]
pub span: Span,
@@ -699,7 +728,7 @@ pub(crate) struct ShuffleIndicesEvaluation {
#[derive(Diagnostic)]
pub enum InvalidMonomorphization<'tcx> {
#[diag(codegen_ssa_invalid_monomorphization_basic_integer_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`", code = E0511)]
BasicIntegerType {
#[primary_span]
span: Span,
@@ -707,7 +736,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_basic_integer_or_ptr_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected basic integer or pointer type, found `{$ty}`", code = E0511)]
BasicIntegerOrPtrType {
#[primary_span]
span: Span,
@@ -715,7 +744,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_basic_float_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected basic float type, found `{$ty}`", code = E0511)]
BasicFloatType {
#[primary_span]
span: Span,
@@ -723,14 +752,14 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_float_to_int_unchecked, code = E0511)]
#[diag("invalid monomorphization of `float_to_int_unchecked` intrinsic: expected basic float type, found `{$ty}`", code = E0511)]
FloatToIntUnchecked {
#[primary_span]
span: Span,
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_floating_point_vector, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported element type `{$f_ty}` of floating-point vector `{$in_ty}`", code = E0511)]
FloatingPointVector {
#[primary_span]
span: Span,
@@ -739,7 +768,7 @@ pub enum InvalidMonomorphization<'tcx> {
in_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_floating_point_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: `{$in_ty}` is not a floating-point type", code = E0511)]
FloatingPointType {
#[primary_span]
span: Span,
@@ -747,14 +776,14 @@ pub enum InvalidMonomorphization<'tcx> {
in_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_unrecognized_intrinsic, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: unrecognized intrinsic `{$name}`", code = E0511)]
UnrecognizedIntrinsic {
#[primary_span]
span: Span,
name: Symbol,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_argument, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD argument type, found non-SIMD `{$ty}`", code = E0511)]
SimdArgument {
#[primary_span]
span: Span,
@@ -762,7 +791,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_input, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD input type, found non-SIMD `{$ty}`", code = E0511)]
SimdInput {
#[primary_span]
span: Span,
@@ -770,7 +799,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_first, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD first type, found non-SIMD `{$ty}`", code = E0511)]
SimdFirst {
#[primary_span]
span: Span,
@@ -778,7 +807,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_second, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD second type, found non-SIMD `{$ty}`", code = E0511)]
SimdSecond {
#[primary_span]
span: Span,
@@ -786,7 +815,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_third, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD third type, found non-SIMD `{$ty}`", code = E0511)]
SimdThird {
#[primary_span]
span: Span,
@@ -794,7 +823,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_return, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD return type, found non-SIMD `{$ty}`", code = E0511)]
SimdReturn {
#[primary_span]
span: Span,
@@ -802,7 +831,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_invalid_bitmask, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$mask_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`", code = E0511)]
InvalidBitmask {
#[primary_span]
span: Span,
@@ -812,7 +841,7 @@ pub enum InvalidMonomorphization<'tcx> {
expected_bytes: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_return_length_input_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type with length {$in_len} (same as input type `{$in_ty}`), found `{$ret_ty}` with length {$out_len}", code = E0511)]
ReturnLengthInputType {
#[primary_span]
span: Span,
@@ -823,7 +852,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_len: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_second_argument_length, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected second argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}", code = E0511)]
SecondArgumentLength {
#[primary_span]
span: Span,
@@ -834,7 +863,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_len: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_third_argument_length, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected third argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}", code = E0511)]
ThirdArgumentLength {
#[primary_span]
span: Span,
@@ -845,7 +874,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_len: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_return_integer_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type with integer elements, found `{$ret_ty}` with non-integer `{$out_ty}`", code = E0511)]
ReturnIntegerType {
#[primary_span]
span: Span,
@@ -854,7 +883,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_shuffle, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be a SIMD vector of `u32`, got `{$ty}`", code = E0511)]
SimdShuffle {
#[primary_span]
span: Span,
@@ -862,7 +891,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_return_length, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type of length {$in_len}, found `{$ret_ty}` with length {$out_len}", code = E0511)]
ReturnLength {
#[primary_span]
span: Span,
@@ -872,7 +901,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_len: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_return_element, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return element type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}` with element type `{$out_ty}`", code = E0511)]
ReturnElement {
#[primary_span]
span: Span,
@@ -883,7 +912,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: SIMD index #{$arg_idx} is out of bounds (limit {$total_len})", code = E0511)]
SimdIndexOutOfBounds {
#[primary_span]
span: Span,
@@ -892,7 +921,7 @@ pub enum InvalidMonomorphization<'tcx> {
total_len: u128,
},
#[diag(codegen_ssa_invalid_monomorphization_inserted_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected inserted type `{$in_elem}` (element of input `{$in_ty}`), found `{$out_ty}`", code = E0511)]
InsertedType {
#[primary_span]
span: Span,
@@ -902,7 +931,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_return_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}`", code = E0511)]
ReturnType {
#[primary_span]
span: Span,
@@ -912,7 +941,7 @@ pub enum InvalidMonomorphization<'tcx> {
ret_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_expected_return_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_ty}`, found `{$ret_ty}`", code = E0511)]
ExpectedReturnType {
#[primary_span]
span: Span,
@@ -921,7 +950,7 @@ pub enum InvalidMonomorphization<'tcx> {
ret_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_mismatched_lengths, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`", code = E0511)]
MismatchedLengths {
#[primary_span]
span: Span,
@@ -930,7 +959,7 @@ pub enum InvalidMonomorphization<'tcx> {
v_len: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_mask_wrong_element_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected mask element type to be an integer, found `{$ty}`", code = E0511)]
MaskWrongElementType {
#[primary_span]
span: Span,
@@ -938,7 +967,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_cannot_return, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: cannot return `{$ret_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`", code = E0511)]
CannotReturn {
#[primary_span]
span: Span,
@@ -948,7 +977,7 @@ pub enum InvalidMonomorphization<'tcx> {
expected_bytes: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_expected_element_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of second argument `{$second_arg}` to be a pointer to the element type `{$in_elem}` of the first argument `{$in_ty}`, found `{$expected_element}` != `{$mutability} {$in_elem}`", code = E0511)]
ExpectedElementType {
#[primary_span]
span: Span,
@@ -960,7 +989,7 @@ pub enum InvalidMonomorphization<'tcx> {
mutability: ExpectedPointerMutability,
},
#[diag(codegen_ssa_invalid_monomorphization_unsupported_symbol_of_size, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` of size `{$size}` to `{$ret_ty}`", code = E0511)]
UnsupportedSymbolOfSize {
#[primary_span]
span: Span,
@@ -972,7 +1001,7 @@ pub enum InvalidMonomorphization<'tcx> {
ret_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_unsupported_symbol, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}`", code = E0511)]
UnsupportedSymbol {
#[primary_span]
span: Span,
@@ -983,7 +1012,7 @@ pub enum InvalidMonomorphization<'tcx> {
ret_ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_cast_wide_pointer, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: cannot cast wide pointer `{$ty}`", code = E0511)]
CastWidePointer {
#[primary_span]
span: Span,
@@ -991,7 +1020,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_expected_pointer, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected pointer, got `{$ty}`", code = E0511)]
ExpectedPointer {
#[primary_span]
span: Span,
@@ -999,7 +1028,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_expected_usize, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected `usize`, got `{$ty}`", code = E0511)]
ExpectedUsize {
#[primary_span]
span: Span,
@@ -1007,7 +1036,7 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_unsupported_cast, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported cast from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}` with element `{$out_elem}`", code = E0511)]
UnsupportedCast {
#[primary_span]
span: Span,
@@ -1018,7 +1047,7 @@ pub enum InvalidMonomorphization<'tcx> {
out_elem: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_unsupported_operation, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported operation on `{$in_ty}` with element `{$in_elem}`", code = E0511)]
UnsupportedOperation {
#[primary_span]
span: Span,
@@ -1027,7 +1056,7 @@ pub enum InvalidMonomorphization<'tcx> {
in_elem: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_expected_vector_element_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of vector type `{$vector_type}` to be a signed or unsigned integer type", code = E0511)]
ExpectedVectorElementType {
#[primary_span]
span: Span,
@@ -1036,7 +1065,7 @@ pub enum InvalidMonomorphization<'tcx> {
vector_type: Ty<'tcx>,
},
#[diag(codegen_ssa_invalid_monomorphization_non_scalable_type, code = E0511)]
#[diag("invalid monomorphization of `{$name}` intrinsic: expected non-scalable type, found scalable type `{$ty}`", code = E0511)]
NonScalableType {
#[primary_span]
span: Span,
@@ -1060,17 +1089,17 @@ fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_target_feature_safe_trait)]
#[diag("`#[target_feature(..)]` cannot be applied to safe trait method")]
pub(crate) struct TargetFeatureSafeTrait {
#[primary_span]
#[label]
#[label("cannot be applied to safe trait method")]
pub span: Span,
#[label(codegen_ssa_label_def)]
#[label("not an `unsafe` function")]
pub def: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_forbidden_target_feature_attr)]
#[diag("target feature `{$feature}` cannot be enabled with `#[target_feature]`: {$reason}")]
pub struct ForbiddenTargetFeatureAttr<'a> {
#[primary_span]
pub span: Span,
@@ -1079,7 +1108,7 @@ pub struct ForbiddenTargetFeatureAttr<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_failed_to_get_layout)]
#[diag("failed to get layout for {$ty}: {$err}")]
pub struct FailedToGetLayout<'tcx> {
#[primary_span]
pub span: Span,
@@ -1088,7 +1117,11 @@ pub struct FailedToGetLayout<'tcx> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_dlltool_fail_import_library)]
#[diag(
"dlltool could not create import library with {$dlltool_path} {$dlltool_args}:
{$stdout}
{$stderr}"
)]
pub(crate) struct DlltoolFailImportLibrary<'a> {
pub dlltool_path: Cow<'a, str>,
pub dlltool_args: String,
@@ -1097,26 +1130,28 @@ pub(crate) struct DlltoolFailImportLibrary<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_error_writing_def_file)]
#[diag("error writing .DEF file: {$error}")]
pub(crate) struct ErrorWritingDEFFile {
pub error: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_error_calling_dlltool)]
#[diag("error calling dlltool '{$dlltool_path}': {$error}")]
pub(crate) struct ErrorCallingDllTool<'a> {
pub dlltool_path: Cow<'a, str>,
pub error: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_error_creating_remark_dir)]
#[diag("failed to create remark directory: {$error}")]
pub(crate) struct ErrorCreatingRemarkDir {
pub error: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_compiler_builtins_cannot_call)]
#[diag(
"`compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `{$caller}` to `{$callee}`"
)]
pub struct CompilerBuiltinsCannotCall {
pub caller: String,
pub callee: String,
@@ -1125,23 +1160,23 @@ pub struct CompilerBuiltinsCannotCall {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_error_creating_import_library)]
#[diag("error creating import library for {$lib_name}: {$error}")]
pub(crate) struct ErrorCreatingImportLibrary<'a> {
pub lib_name: &'a str,
pub error: String,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_aix_strip_not_used)]
#[diag("using host's `strip` binary to cross-compile to AIX which is not guaranteed to work")]
pub(crate) struct AixStripNotUsed;
#[derive(Diagnostic, Debug)]
pub(crate) enum XcrunError {
#[diag(codegen_ssa_xcrun_failed_invoking)]
#[diag("invoking `{$command_formatted}` to find {$sdk_name}.sdk failed: {$error}")]
FailedInvoking { sdk_name: &'static str, command_formatted: String, error: std::io::Error },
#[diag(codegen_ssa_xcrun_unsuccessful)]
#[note]
#[diag("failed running `{$command_formatted}` to find {$sdk_name}.sdk")]
#[note("{$stdout}{$stderr}")]
Unsuccessful {
sdk_name: &'static str,
command_formatted: String,
@@ -1151,35 +1186,37 @@ pub(crate) enum XcrunError {
}
#[derive(Diagnostic, Debug)]
#[diag(codegen_ssa_xcrun_sdk_path_warning)]
#[note]
#[diag("output of `xcrun` while finding {$sdk_name}.sdk")]
#[note("{$stderr}")]
pub(crate) struct XcrunSdkPathWarning {
pub sdk_name: &'static str,
pub stderr: String,
}
#[derive(LintDiagnostic)]
#[diag(codegen_ssa_aarch64_softfloat_neon)]
#[diag("enabling the `neon` target feature on the current target is unsound due to ABI issues")]
pub(crate) struct Aarch64SoftfloatNeon;
#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_ctarget_feature_prefix)]
#[note]
#[diag("unknown feature specified for `-Ctarget-feature`: `{$feature}`")]
#[note("features must begin with a `+` to enable or `-` to disable it")]
pub(crate) struct UnknownCTargetFeaturePrefix<'a> {
pub feature: &'a str,
}
#[derive(Subdiagnostic)]
pub(crate) enum PossibleFeature<'a> {
#[help(codegen_ssa_possible_feature)]
#[help("you might have meant: `{$rust_feature}`")]
Some { rust_feature: &'a str },
#[help(codegen_ssa_consider_filing_feature_request)]
#[help("consider filing a feature request")]
None,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_ctarget_feature)]
#[note]
#[diag("unknown and unstable feature specified for `-Ctarget-feature`: `{$feature}`")]
#[note(
"it is still passed through to the codegen backend, but use of this feature might be unsound and the behavior of this feature can change in the future"
)]
pub(crate) struct UnknownCTargetFeature<'a> {
pub feature: &'a str,
#[subdiagnostic]
@@ -1187,16 +1224,18 @@ pub(crate) struct UnknownCTargetFeature<'a> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unstable_ctarget_feature)]
#[note]
#[diag("unstable feature specified for `-Ctarget-feature`: `{$feature}`")]
#[note("this feature is not stably supported; its behavior can change in the future")]
pub(crate) struct UnstableCTargetFeature<'a> {
pub feature: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_forbidden_ctarget_feature)]
#[note]
#[note(codegen_ssa_forbidden_ctarget_feature_issue)]
#[diag("target feature `{$feature}` cannot be {$enabled} with `-Ctarget-feature`: {$reason}")]
#[note(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
#[note("for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>")]
pub(crate) struct ForbiddenCTargetFeature<'a> {
pub feature: &'a str,
pub enabled: &'a str,
@@ -1210,12 +1249,18 @@ pub struct TargetFeatureDisableOrEnable<'a> {
}
#[derive(Subdiagnostic)]
#[help(codegen_ssa_missing_features)]
#[help("add the missing features in a `target_feature` attribute")]
pub struct MissingFeatures;
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let mut diag = Diag::new(dcx, level, fluent::codegen_ssa_target_feature_disable_or_enable);
let mut diag = Diag::new(
dcx,
level,
inline_fluent!(
"the target features {$features} must all be either enabled or disabled together"
),
);
if let Some(span) = self.span {
diag.span(span);
};
@@ -1228,29 +1273,29 @@ fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_feature_not_valid)]
#[diag("the feature named `{$feature}` is not valid for this target")]
pub(crate) struct FeatureNotValid<'a> {
pub feature: &'a str,
#[primary_span]
#[label]
#[label("`{$feature}` is not valid for this target")]
pub span: Span,
#[help]
#[help("consider removing the leading `+` in the feature name")]
pub plus_hint: bool,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_lto_disallowed)]
#[diag("lto can only be run for executables, cdylibs and static library outputs")]
pub(crate) struct LtoDisallowed;
#[derive(Diagnostic)]
#[diag(codegen_ssa_lto_dylib)]
#[diag("lto cannot be used for `dylib` crate type without `-Zdylib-lto`")]
pub(crate) struct LtoDylib;
#[derive(Diagnostic)]
#[diag(codegen_ssa_lto_proc_macro)]
#[diag("lto cannot be used for `proc-macro` crate type without `-Zdylib-lto`")]
pub(crate) struct LtoProcMacro;
#[derive(Diagnostic)]
#[diag(codegen_ssa_dynamic_linking_with_lto)]
#[note]
#[diag("cannot prefer dynamic linking when performing LTO")]
#[note("only 'staticlib', 'bin', and 'cdylib' outputs are supported with LTO")]
pub(crate) struct DynamicLinkingWithLTO;
-2
View File
@@ -55,8 +55,6 @@
pub mod target_features;
pub mod traits;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub struct ModuleCodegen<M> {
/// The name of the module. When the crate may be saved between
/// compilations, incremental compilation requires that name be
-1
View File
@@ -118,7 +118,6 @@ pub fn default_translator() -> Translator {
rustc_ast_passes::DEFAULT_LOCALE_RESOURCE,
rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
rustc_codegen_ssa::DEFAULT_LOCALE_RESOURCE,
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
rustc_errors::DEFAULT_LOCALE_RESOURCE,
rustc_expand::DEFAULT_LOCALE_RESOURCE,