Remove thiserror dependency from cranelift_codegen
This commit is contained in:
@@ -69,7 +69,6 @@ use core::fmt;
|
||||
use core::fmt::{Debug, Formatter};
|
||||
use core::hash::Hasher;
|
||||
use target_lexicon::{triple, Architecture, OperatingSystem, PointerWidth, Triple};
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(feature = "riscv")]
|
||||
mod riscv;
|
||||
@@ -178,17 +177,28 @@ pub fn lookup_by_name(name: &str) -> Result<Builder, LookupError> {
|
||||
}
|
||||
|
||||
/// Describes reason for target lookup failure
|
||||
#[derive(Error, PartialEq, Eq, Copy, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||
pub enum LookupError {
|
||||
/// Support for this target was disabled in the current build.
|
||||
#[error("Support for this target is disabled")]
|
||||
SupportDisabled,
|
||||
|
||||
/// Support for this target has not yet been implemented.
|
||||
#[error("Support for this target has not been implemented yet")]
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
impl std::error::Error for LookupError {}
|
||||
|
||||
impl fmt::Display for LookupError {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
match self {
|
||||
LookupError::SupportDisabled => write!(f, "Support for this target is disabled"),
|
||||
LookupError::Unsupported => {
|
||||
write!(f, "Support for this target has not been implemented yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Builder for a `TargetIsa`.
|
||||
/// Modify the ISA-specific settings before creating the `TargetIsa` trait object with `finish`.
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -6,7 +6,6 @@ use crate::isa::unwind::UnwindInst;
|
||||
use crate::result::{CodegenError, CodegenResult};
|
||||
use alloc::vec::Vec;
|
||||
use gimli::write::{Address, FrameDescriptionEntry};
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -15,16 +14,30 @@ type Register = u16;
|
||||
|
||||
/// Enumerate the errors possible in mapping Cranelift registers to their DWARF equivalent.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug, PartialEq, Eq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum RegisterMappingError {
|
||||
#[error("unable to find bank for register info")]
|
||||
MissingBank,
|
||||
#[error("register mapping is currently only implemented for x86_64")]
|
||||
UnsupportedArchitecture,
|
||||
#[error("unsupported register bank: {0}")]
|
||||
UnsupportedRegisterBank(&'static str),
|
||||
}
|
||||
|
||||
impl std::error::Error for RegisterMappingError {}
|
||||
|
||||
impl std::fmt::Display for RegisterMappingError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
RegisterMappingError::MissingBank => write!(f, "unable to find bank for register info"),
|
||||
RegisterMappingError::UnsupportedArchitecture => write!(
|
||||
f,
|
||||
"register mapping is currently only implemented for x86_64"
|
||||
),
|
||||
RegisterMappingError::UnsupportedRegisterBank(bank) => {
|
||||
write!(f, "unsupported register bank: {}", bank)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This mirrors gimli's CallFrameInstruction, but is serializable
|
||||
// This excludes CfaExpression, Expression, ValExpression due to
|
||||
// https://github.com/gimli-rs/gimli/issues/513.
|
||||
|
||||
Reference in New Issue
Block a user