* Added initial Rust codegen-meta implementation. * Replace 'Cretonne' in comments. * Prevent iterator overflow. * 1.25.0 compatibility changes. * Implemented debug traits for type variants. * Added consistent comments. * Cleaned up a loop via clippy fix. * Added new license to codegen-meta Cargo.toml * Edited lane type iterator `next` method. * Removed functions that are not needed in Rust, and edited desc. * Debug trait derived for valuetype. * Added comments for iterator types in the base types submodule. * Numbering is now handled in the cdsl/types.rs file. * Moved type number logic into cdsl/types. * Repeating the lane change cleanup. * Removed codegen-meta crate from codegen deps. * Typo fix. * Addressing a patch note. * Addressing patch note. * Lowercase in vector names. * Fixing a comment bug. * Added a copy of the license file. * Formatting changes. * Cleaned up the vector type numbering. * 1.25 compatibility. * Fixed pattern match arms.
48 lines
1.0 KiB
Rust
48 lines
1.0 KiB
Rust
use std::fmt;
|
|
use std::io;
|
|
|
|
/// An error that occurred when the cranelift_codegen_meta crate was generating
|
|
/// source files for the cranelift_codegen crate.
|
|
#[derive(Debug)]
|
|
pub struct Error {
|
|
inner: Box<ErrorInner>,
|
|
}
|
|
|
|
impl Error {
|
|
/// Create a new error object with the given message.
|
|
pub fn with_msg<S: Into<String>>(msg: S) -> Error {
|
|
Error {
|
|
inner: Box::new(ErrorInner::Msg(msg.into())),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for Error {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
write!(f, "{}", self.inner)
|
|
}
|
|
}
|
|
|
|
impl From<io::Error> for Error {
|
|
fn from(e: io::Error) -> Self {
|
|
Error {
|
|
inner: Box::new(ErrorInner::IoError(e)),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
enum ErrorInner {
|
|
Msg(String),
|
|
IoError(io::Error),
|
|
}
|
|
|
|
impl fmt::Display for ErrorInner {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match *self {
|
|
ErrorInner::Msg(ref s) => write!(f, "{}", s),
|
|
ErrorInner::IoError(ref e) => write!(f, "{}", e),
|
|
}
|
|
}
|
|
}
|