Allow passing slice of extern Rust type across FFI

This commit is contained in:
David Tolnay 2020-12-27 02:21:45 -08:00
parent 5ce110e807
commit 3adf3c81b6
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -210,6 +210,7 @@ fn check_type_ref(cx: &mut Check, ty: &Ref) {
fn check_type_slice_ref(cx: &mut Check, ty: &SliceRef) {
let supported = match &ty.inner {
Type::Str(_) | Type::SliceRef(_) => false,
Type::Ident(ident) => !is_opaque_cxx(cx, &ident.rust),
element => !is_unsized(cx, element),
};
@ -217,9 +218,7 @@ fn check_type_slice_ref(cx: &mut Check, ty: &SliceRef) {
let mutable = if ty.mutable { "mut " } else { "" };
let mut msg = format!("unsupported &{}[T] element type", mutable);
if let Type::Ident(ident) = &ty.inner {
if cx.types.rust.contains(&ident.rust) {
msg += ": opaque Rust type is not supported yet";
} else if is_opaque_cxx(cx, &ident.rust) {
if is_opaque_cxx(cx, &ident.rust) {
msg += ": opaque C++ type is not supported yet";
}
}