pub fn is_ffi_safe(tcx: ty::ctxt, def_id: ast::DefId) -> bool {
    match ty::get(ty::lookup_item_type(tcx, def_id).ty).sty {
        ty::ty_enum(def_id, _) => {
            let variants = ty::enum_variants(tcx, def_id);
            // Univariant => like struct/tuple.
            if variants.len() <= 1 {
                return true;
            }
            let hint = ty::lookup_repr_hint(tcx, def_id);
            // Appropriate representation explicitly selected?
            if hint.is_ffi_safe() {
                return true;
            }
            // Option<~T> and similar are used in FFI.  Rather than try to resolve type parameters
            // and recognize this case exactly, this overapproximates -- assuming that if a
            // non-C-like enum is being used in FFI then the user knows what they're doing.
            if variants.iter().any(|vi| !vi.args.is_empty()) {
                return true;
            }
            false
        }
        // struct, tuple, etc.
        // (is this right in the present of typedefs?)
        _ => true
    }
}
/// Determine, without doing translation, whether an ADT must be FFI-safe.
/// For use in lint or similar, where being sound but slightly incomplete is acceptable.
Determine, without doing translation, whether an ADT must be FFI-safe.
For use in lint or similar, where being sound but slightly incomplete is acceptable.
Determine without doing translation whether an ADT must be FFI - safe . For use in lint or similar where being sound but slightly incomplete is acceptable .
pub fn is_ffi_safe(tcx: ty::ctxt, def_id: ast::DefId) -> bool {
    match ty::get(ty::lookup_item_type(tcx, def_id).ty).sty {
        ty::ty_enum(def_id, _) => {
            let variants = ty::enum_variants(tcx, def_id);
            // Univariant => like struct/tuple.
            if variants.len() <= 1 {
                return true;
            }
            let hint = ty::lookup_repr_hint(tcx, def_id);
            // Appropriate representation explicitly selected?
            if hint.is_ffi_safe() {
                return true;
            }
            // Option<~T> and similar are used in FFI.  Rather than try to resolve type parameters
            // and recognize this case exactly, this overapproximates -- assuming that if a
            // non-C-like enum is being used in FFI then the user knows what they're doing.
            if variants.iter().any(|vi| !vi.args.is_empty()) {
                return true;
            }
            false
        }
        // struct, tuple, etc.
        // (is this right in the present of typedefs?)
        _ => true
    }
}
pub fn is_ffi_safe ( tcx : ty :: ctxt , def_id : ast :: DefId ) -> bool { match ty :: get ( ty :: lookup_item_type ( tcx , def_id ) . ty ) . sty { ty :: ty_enum ( def_id , _ ) => { let variants = ty :: enum_variants ( tcx , def_id ) ; // Univariant => like struct/tuple. if variants . len ( ) <= 1 { return true ; } let hint = ty :: lookup_repr_hint ( tcx , def_id ) ; // Appropriate representation explicitly selected? if hint . is_ffi_safe ( ) { return true ; } // Option<~T> and similar are used in FFI.  Rather than try to resolve type parameters // and recognize this case exactly, this overapproximates -- assuming that if a // non-C-like enum is being used in FFI then the user knows what they're doing. if variants . iter ( ) . any ( | vi | ! vi . args . is_empty ( ) ) { return true ; } false } // struct, tuple, etc. // (is this right in the present of typedefs?) _ => true } }
Determine, without doing translation, whether an ADT must be FFI-safe.
Determine without doing translation whether an ADT must be FFI - safe .
tcx
ty::ctxt
def_id
ast::DefId
tcx
ty::ctxt
def_id
ast::DefId