Sha256: 0c3d198f4866ccbbcd8b1136fc5cfd2507a9eca5ab85934af29a7e2a7d8d8c2a

Contents?: true

Size: 1.75 KB

Versions: 18

Compression:

Stored size: 1.75 KB

Contents

use std::error;
use std::fmt;

/// Errors that can occur during code generation.
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) enum Error {
    /// Tried to generate an opaque blob for a type that did not have a layout.
    NoLayoutForOpaqueBlob,

    /// Tried to instantiate an opaque template definition, or a template
    /// definition that is too difficult for us to understand (like a partial
    /// template specialization).
    InstantiationOfOpaqueType,

    /// Function ABI is not supported.
    UnsupportedAbi(&'static str),

    /// The pointer type size does not match the target's pointer size.
    InvalidPointerSize {
        ty_name: String,
        ty_size: usize,
        ptr_size: usize,
    },
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Error::NoLayoutForOpaqueBlob => {
                "Tried to generate an opaque blob, but had no layout.".fmt(f)
            }
            Error::InstantiationOfOpaqueType => {
                "Instantiation of opaque template type or partial template specialization."
                    .fmt(f)
            }
            Error::UnsupportedAbi(abi) => {
                 write!(
                    f,
                    "{} ABI is not supported by the configured Rust target.",
                    abi
                )
            }
            Error::InvalidPointerSize { ty_name, ty_size, ptr_size } => {
                write!(f, "The {} pointer type has size {} but the current target's pointer size is {}.", ty_name, ty_size, ptr_size)
            }
        }
    }
}

impl error::Error for Error {}

/// A `Result` of `T` or an error of `bindgen::codegen::error::Error`.
pub(crate) type Result<T> = ::std::result::Result<T, Error>;

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
wasmtime-28.0.0 ./ext/cargo-vendor/bindgen-0.69.5/codegen/error.rs
wasmtime-27.0.0 ./ext/cargo-vendor/bindgen-0.69.5/codegen/error.rs
wasmtime-26.0.0 ./ext/cargo-vendor/bindgen-0.69.5/codegen/error.rs
wasmtime-25.0.2 ./ext/cargo-vendor/bindgen-0.69.4/codegen/error.rs
wasmtime-25.0.1 ./ext/cargo-vendor/bindgen-0.69.4/codegen/error.rs
wasmtime-25.0.0 ./ext/cargo-vendor/bindgen-0.69.4/codegen/error.rs
wasmtime-24.0.0 ./ext/cargo-vendor/bindgen-0.69.4/codegen/error.rs
wasmtime-23.0.2 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-22.0.0 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-21.0.1 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-20.0.2 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-20.0.0 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-18.0.3 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-17.0.1 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-17.0.0 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-16.0.0 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-15.0.1 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs
wasmtime-15.0.0 ./ext/cargo-vendor/bindgen-0.69.1/codegen/error.rs