mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
ADD - implement IntoDiagnostic for thorin::Error wrapper
This commit is contained in:
parent
a25f939170
commit
13d4f27c82
@ -662,8 +662,7 @@ fn link_dwarf_object<'a>(
|
||||
}) {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
let thorin_error = errors::ThorinErrorWrapper(e);
|
||||
sess.emit_err(errors::ThorinDwarfLinking { thorin_error });
|
||||
sess.emit_err(errors::ThorinErrorWrapper(e));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
|
@ -129,18 +129,200 @@ pub enum LinkRlibError {
|
||||
NotFound { crate_name: Symbol },
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa::thorin_dwarf_linking)]
|
||||
#[note]
|
||||
pub struct ThorinDwarfLinking {
|
||||
pub thorin_error: ThorinErrorWrapper,
|
||||
}
|
||||
pub struct ThorinErrorWrapper(pub thorin::Error);
|
||||
|
||||
// FIXME: How should we support translations for external crate errors?
|
||||
impl IntoDiagnosticArg for ThorinErrorWrapper {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
|
||||
impl IntoDiagnostic<'_> for ThorinErrorWrapper {
|
||||
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut diag;
|
||||
match self.0 {
|
||||
thorin::Error::ReadInput(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_read_input_failure);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseFileKind(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_input_file_kind);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseObjectFile(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_input_object_file);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseArchiveFile(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_input_archive_file);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseArchiveMember(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_archive_member);
|
||||
diag
|
||||
}
|
||||
thorin::Error::InvalidInputKind => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_invalid_input_kind);
|
||||
diag
|
||||
}
|
||||
thorin::Error::DecompressData(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_decompress_data);
|
||||
diag
|
||||
}
|
||||
thorin::Error::NamelessSection(_, offset) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_section_without_name);
|
||||
diag.set_arg("offset", format!("0x{:08x}", offset));
|
||||
diag
|
||||
}
|
||||
thorin::Error::RelocationWithInvalidSymbol(section, offset) => {
|
||||
diag =
|
||||
handler.struct_err(fluent::codegen_ssa::thorin_relocation_with_invalid_symbol);
|
||||
diag.set_arg("section", section);
|
||||
diag.set_arg("offset", format!("0x{:08x}", offset));
|
||||
diag
|
||||
}
|
||||
thorin::Error::MultipleRelocations(section, offset) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_multiple_relocations);
|
||||
diag.set_arg("section", section);
|
||||
diag.set_arg("offset", format!("0x{:08x}", offset));
|
||||
diag
|
||||
}
|
||||
thorin::Error::UnsupportedRelocation(section, offset) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_unsupported_relocation);
|
||||
diag.set_arg("section", section);
|
||||
diag.set_arg("offset", format!("0x{:08x}", offset));
|
||||
diag
|
||||
}
|
||||
thorin::Error::MissingDwoName(id) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_missing_dwo_name);
|
||||
diag.set_arg("id", format!("0x{:08x}", id));
|
||||
diag
|
||||
}
|
||||
thorin::Error::NoCompilationUnits => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_no_compilation_units);
|
||||
diag
|
||||
}
|
||||
thorin::Error::NoDie => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_no_die);
|
||||
diag
|
||||
}
|
||||
thorin::Error::TopLevelDieNotUnit => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_top_level_die_not_unit);
|
||||
diag
|
||||
}
|
||||
thorin::Error::MissingRequiredSection(section) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_missing_required_section);
|
||||
diag.set_arg("section", section);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseUnitAbbreviations(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_unit_abbreviations);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseUnitAttribute(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_unit_attribute);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseUnitHeader(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_unit_header);
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseUnit(_) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_unit);
|
||||
diag
|
||||
}
|
||||
thorin::Error::IncompatibleIndexVersion(section, format, actual) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_incompatible_index_version);
|
||||
diag.set_arg("section", section);
|
||||
diag.set_arg("actual", actual);
|
||||
diag.set_arg("format", format);
|
||||
diag
|
||||
}
|
||||
thorin::Error::OffsetAtIndex(_, index) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_offset_at_index);
|
||||
diag.set_arg("index", index);
|
||||
diag
|
||||
}
|
||||
thorin::Error::StrAtOffset(_, offset) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_str_at_offset);
|
||||
diag.set_arg("offset", format!("0x{:08x}", offset));
|
||||
diag
|
||||
}
|
||||
thorin::Error::ParseIndex(_, section) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_parse_index);
|
||||
diag.set_arg("section", section);
|
||||
diag
|
||||
}
|
||||
thorin::Error::UnitNotInIndex(unit) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_unit_not_in_index);
|
||||
diag.set_arg("unit", format!("0x{:08x}", unit));
|
||||
diag
|
||||
}
|
||||
thorin::Error::RowNotInIndex(_, row) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_row_not_in_index);
|
||||
diag.set_arg("row", row);
|
||||
diag
|
||||
}
|
||||
thorin::Error::SectionNotInRow => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_section_not_in_row);
|
||||
diag
|
||||
}
|
||||
thorin::Error::EmptyUnit(unit) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_empty_unit);
|
||||
diag.set_arg("unit", format!("0x{:08x}", unit));
|
||||
diag
|
||||
}
|
||||
thorin::Error::MultipleDebugInfoSection => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_multiple_debug_info_section);
|
||||
diag
|
||||
}
|
||||
thorin::Error::MultipleDebugTypesSection => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_multiple_debug_types_section);
|
||||
diag
|
||||
}
|
||||
thorin::Error::NotSplitUnit => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_not_split_unit);
|
||||
diag
|
||||
}
|
||||
thorin::Error::DuplicateUnit(unit) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_duplicate_unit);
|
||||
diag.set_arg("unit", format!("0x{:08x}", unit));
|
||||
diag
|
||||
}
|
||||
thorin::Error::MissingReferencedUnit(unit) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_missing_referenced_unit);
|
||||
diag.set_arg("unit", format!("0x{:08x}", unit));
|
||||
diag
|
||||
}
|
||||
thorin::Error::NoOutputObjectCreated => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_not_output_object_created);
|
||||
diag
|
||||
}
|
||||
thorin::Error::MixedInputEncodings => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_mixed_input_encodings);
|
||||
diag
|
||||
}
|
||||
thorin::Error::Io(e) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_io);
|
||||
diag.set_arg("error", format!("{e}"));
|
||||
diag
|
||||
}
|
||||
thorin::Error::ObjectRead(e) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_object_read);
|
||||
diag.set_arg("error", format!("{e}"));
|
||||
diag
|
||||
}
|
||||
thorin::Error::ObjectWrite(e) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_object_write);
|
||||
diag.set_arg("error", format!("{e}"));
|
||||
diag
|
||||
}
|
||||
thorin::Error::GimliRead(e) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_gimli_read);
|
||||
diag.set_arg("error", format!("{e}"));
|
||||
diag
|
||||
}
|
||||
thorin::Error::GimliWrite(e) => {
|
||||
diag = handler.struct_err(fluent::codegen_ssa::thorin_gimli_write);
|
||||
diag.set_arg("error", format!("{e}"));
|
||||
diag
|
||||
}
|
||||
_ => unimplemented!("Untranslated thorin error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,6 @@ codegen_ssa_rlib_only_rmeta_found = could not find rlib for: `{$crate_name}`, fo
|
||||
|
||||
codegen_ssa_rlib_not_found = could not find rlib for: `{$crate_name}`
|
||||
|
||||
codegen_ssa_thorin_dwarf_linking = linking dwarf objects with thorin failed
|
||||
.note = {$thorin_error}
|
||||
|
||||
codegen_ssa_linking_failed = linking with `{$linker_path}` failed: {$exit_status}
|
||||
|
||||
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
|
||||
@ -44,3 +41,79 @@ codegen_ssa_extern_funcs_not_found = some `extern` functions couldn't be found;
|
||||
codegen_ssa_specify_libraries_to_link = use the `-l` flag to specify native libraries to link
|
||||
|
||||
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#cargorustc-link-libkindname)
|
||||
|
||||
codegen_ssa_thorin_read_input_failure = failed to read input 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_input_archive_file = failed to parse input archive file
|
||||
|
||||
codegen_ssa_thorin_parse_archive_member = failed to parse archive member
|
||||
|
||||
codegen_ssa_thorin_invalid_input_kind = input is not an archive or elf object
|
||||
|
||||
codegen_ssa_thorin_decompress_data = failed to decompress compressed section
|
||||
|
||||
codegen_ssa_thorin_section_without_name = section without name at offset {$offset}
|
||||
|
||||
codegen_ssa_thorin_relocation_with_invalid_symbol = relocation with invalid symbol for section `{$section}` at offset {$offset}
|
||||
|
||||
codegen_ssa_thorin_multiple_relocations = multiple relocations for section `{$section}` at offset {$offset}
|
||||
|
||||
codegen_ssa_thorin_unsupported_relocation = unsupported relocation for section {$section} at offset {$offset}
|
||||
|
||||
codegen_ssa_thorin_missing_dwo_name = missing path attribute to DWARF object ({$id})
|
||||
|
||||
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_top_level_die_not_unit = top-level debugging information entry is not a compilation/type unit
|
||||
|
||||
codegen_ssa_thorin_missing_required_section = input object missing required section `{$section}`
|
||||
|
||||
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_parse_unit = failed to parse unit
|
||||
|
||||
codegen_ssa_thorin_incompatible_index_version = incompatible `{$section}` index version: found version {$actual}, expected version {$format}
|
||||
|
||||
codegen_ssa_thorin_offset_at_index = read offset at index {$index} of `.debug_str_offsets.dwo` section
|
||||
|
||||
codegen_ssa_thorin_str_at_offset = read string at offset {$offset} of `.debug_str.dwo` section
|
||||
|
||||
codegen_ssa_thorin_parse_index = failed to parse `{$section}` index section
|
||||
|
||||
codegen_ssa_thorin_unit_not_in_index = unit {$unit} from input package is not in its index
|
||||
|
||||
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_empty_unit = unit {$unit} in input DWARF object with no data
|
||||
|
||||
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_not_split_unit = regular compilation unit in object (missing dwo identifier)
|
||||
|
||||
codegen_ssa_thorin_duplicate_unit = duplicate split compilation unit ({$unit})
|
||||
|
||||
codegen_ssa_thorin_missing_referenced_unit = unit {$unit} referenced by executable was not found
|
||||
|
||||
codegen_ssa_thorin_not_output_object_created = no output object was created from inputs
|
||||
|
||||
codegen_ssa_thorin_mixed_input_encodings = input objects haved mixed encodings
|
||||
|
||||
codegen_ssa_thorin_io = {$error}
|
||||
codegen_ssa_thorin_object_read = {$error}
|
||||
codegen_ssa_thorin_object_write = {$error}
|
||||
codegen_ssa_thorin_gimli_read = {$error}
|
||||
codegen_ssa_thorin_gimli_write = {$error}
|
||||
|
Loading…
Reference in New Issue
Block a user