diff --git a/src/cxx.cc b/src/cxx.cc index 9983fbaab..0dba805d6 100644 --- a/src/cxx.cc +++ b/src/cxx.cc @@ -602,7 +602,8 @@ static_assert(sizeof(std::string) <= kMaxExpectedWordsInString * sizeof(void *), FOR_EACH_NUMERIC(MACRO) \ MACRO(bool, bool) \ MACRO(char, char) \ - MACRO(string, rust::String) + MACRO(string, rust::String) \ + MACRO(str, rust::Str) #define FOR_EACH_SHARED_PTR(MACRO) \ FOR_EACH_NUMERIC(MACRO) \ diff --git a/src/symbols/rust_vec.rs b/src/symbols/rust_vec.rs index 60b9cfa54..bda1209f2 100644 --- a/src/symbols/rust_vec.rs +++ b/src/symbols/rust_vec.rs @@ -77,3 +77,4 @@ rust_vec_shims_for_primitive!(f64); rust_vec_shims!("char", c_char); rust_vec_shims!("string", RustString); +rust_vec_shims!("str", &str); diff --git a/syntax/check.rs b/syntax/check.rs index b9f6660ec..2098a1bf6 100644 --- a/syntax/check.rs +++ b/syntax/check.rs @@ -93,23 +93,27 @@ fn check_type_box(cx: &mut Check, ptr: &Ty1) { } fn check_type_rust_vec(cx: &mut Check, ty: &Ty1) { - if let Type::Ident(ident) = &ty.inner { - if cx.types.cxx.contains(&ident.rust) - && !cx.types.aliases.contains_key(&ident.rust) - && !cx.types.structs.contains_key(&ident.rust) - && !cx.types.enums.contains_key(&ident.rust) - { - cx.error(ty, "Rust Vec containing C++ type is not supported yet"); - return; - } + match &ty.inner { + Type::Ident(ident) => { + if cx.types.cxx.contains(&ident.rust) + && !cx.types.aliases.contains_key(&ident.rust) + && !cx.types.structs.contains_key(&ident.rust) + && !cx.types.enums.contains_key(&ident.rust) + { + cx.error(ty, "Rust Vec containing C++ type is not supported yet"); + return; + } - match Atom::from(&ident.rust) { - None | Some(Char) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) - | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) - | Some(F64) | Some(RustString) => return, - Some(Bool) => { /* todo */ } - Some(CxxString) => {} + match Atom::from(&ident.rust) { + None | Some(Char) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) + | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) + | Some(F64) | Some(RustString) => return, + Some(Bool) => { /* todo */ } + Some(CxxString) => {} + } } + Type::Str(_) => return, + _ => {} } cx.error(ty, "unsupported element type of Vec");