Remove thiserror dependency from cranelift_codegen
This commit is contained in:
@@ -26,7 +26,6 @@ use alloc::boxed::Box;
|
||||
use alloc::string::{String, ToString};
|
||||
use core::fmt;
|
||||
use core::str;
|
||||
use thiserror::Error;
|
||||
|
||||
/// A string-based configurator for settings groups.
|
||||
///
|
||||
@@ -261,21 +260,34 @@ impl Configurable for Builder {
|
||||
}
|
||||
|
||||
/// An error produced when changing a setting.
|
||||
#[derive(Error, Debug, PartialEq, Eq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum SetError {
|
||||
/// No setting by this name exists.
|
||||
#[error("No existing setting named '{0}'")]
|
||||
BadName(String),
|
||||
|
||||
/// Type mismatch for setting (e.g., setting an enum setting as a bool).
|
||||
#[error("Trying to set a setting with the wrong type")]
|
||||
BadType,
|
||||
|
||||
/// This is not a valid value for this setting.
|
||||
#[error("Unexpected value for a setting, expected {0}")]
|
||||
BadValue(String),
|
||||
}
|
||||
|
||||
impl std::error::Error for SetError {}
|
||||
|
||||
impl fmt::Display for SetError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
SetError::BadName(name) => write!(f, "No existing setting named '{}'", name),
|
||||
SetError::BadType => {
|
||||
write!(f, "Trying to set a setting with the wrong type")
|
||||
}
|
||||
SetError::BadValue(value) => {
|
||||
write!(f, "Unexpected value for a setting, expected {}", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A result returned when changing a setting.
|
||||
pub type SetResult<T> = Result<T, SetError>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user