Lint non-FFI-safe enums.

This commit is contained in:
Jed Davis
2013-06-02 13:03:35 -07:00
parent 01740acd5a
commit 25f953437d
3 changed files with 80 additions and 17 deletions

View File

@@ -442,6 +442,16 @@ pub enum ReprAttr {
ReprExtern
}
impl ReprAttr {
pub fn is_ffi_safe(&self) -> bool {
match *self {
ReprAny => false,
ReprInt(_sp, ity) => ity.is_ffi_safe(),
ReprExtern => true
}
}
}
#[deriving(Eq)]
pub enum IntType {
SignedInt(ast::int_ty),
@@ -456,4 +466,13 @@ impl IntType {
UnsignedInt(*) => false
}
}
fn is_ffi_safe(self) -> bool {
match self {
SignedInt(ast::ty_i8) | UnsignedInt(ast::ty_u8) |
SignedInt(ast::ty_i16) | UnsignedInt(ast::ty_u16) |
SignedInt(ast::ty_i32) | UnsignedInt(ast::ty_u32) |
SignedInt(ast::ty_i64) | UnsignedInt(ast::ty_u64) => true,
_ => false
}
}
}