diff options
| author | Jed Davis <jld@panix.com> | 2013-06-02 13:03:35 -0700 |
|---|---|---|
| committer | Jed Davis <jld@panix.com> | 2013-10-29 09:09:20 -0700 |
| commit | 25f953437d2bc3983b03c0d17cf56de40acec45b (patch) | |
| tree | c3b78ef0075e8ca72343fa3e7b90baa47d683ff0 /src/libsyntax | |
| parent | 01740acd5ab243e7b8c0e1e076ed56edcb9bf4d0 (diff) | |
| download | rust-25f953437d2bc3983b03c0d17cf56de40acec45b.tar.gz rust-25f953437d2bc3983b03c0d17cf56de40acec45b.zip | |
Lint non-FFI-safe enums.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index e538e09c056..222ca61a791 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -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 + } + } } |
