diff options
author | Justin Smith <justsmth@amazon.com> | 2022-10-06 13:30:17 -0400 |
---|---|---|
committer | Justin Smith <justsmth@amazon.com> | 2022-10-06 13:30:17 -0400 |
commit | c1d8cfb5528e3e7d061ae7574195664bc71b5004 (patch) | |
tree | f26aa7dbe22fe9ed3b884fb3d4620b44b5138be0 /bindgen/codegen/error.rs | |
parent | 5209ebdbdfbe0663824d2abb688ac30c2c602726 (diff) | |
parent | 576fd8d424c8248726542b0951c594a9734cd02a (diff) |
Merge branch 'master' into generated_name_override
Diffstat (limited to 'bindgen/codegen/error.rs')
-rw-r--r-- | bindgen/codegen/error.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bindgen/codegen/error.rs b/bindgen/codegen/error.rs new file mode 100644 index 00000000..c1bcf4e1 --- /dev/null +++ b/bindgen/codegen/error.rs @@ -0,0 +1,33 @@ +use std::error; +use std::fmt; + +/// Errors that can occur during code generation. +#[derive(Clone, Debug, PartialEq, Eq)] +pub 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, +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(match *self { + Error::NoLayoutForOpaqueBlob => { + "Tried to generate an opaque blob, but had no layout" + } + Error::InstantiationOfOpaqueType => { + "Instantiation of opaque template type or partial template \ + specialization" + } + }) + } +} + +impl error::Error for Error {} + +/// A `Result` of `T` or an error of `bindgen::codegen::error::Error`. +pub type Result<T> = ::std::result::Result<T, Error>; |