mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-24 07:40:19 +00:00
Inline vector element check
These will need to diverge shortly; in particular we'd like to support Rust vectors containing Rust strings and C++ vectors containing C++ strings.
This commit is contained in:
parent
c0faaf6cda
commit
6bd63de58e
@ -97,9 +97,10 @@ fn check_type_rust_vec(cx: &mut Check, ty: &Ty1) {
|
||||
}
|
||||
|
||||
match Atom::from(ident) {
|
||||
Some(atom) if is_valid_vector_element(atom) => return,
|
||||
None => return,
|
||||
_ => {}
|
||||
None | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8)
|
||||
| Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) | Some(F64) => return,
|
||||
Some(Bool) | Some(RustString) => { /* todo */ }
|
||||
Some(CxxString) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,9 +134,10 @@ fn check_type_cxx_vector(cx: &mut Check, ptr: &Ty1) {
|
||||
}
|
||||
|
||||
match Atom::from(ident) {
|
||||
Some(atom) if is_valid_vector_element(atom) => return,
|
||||
None => return,
|
||||
_ => {}
|
||||
None | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8)
|
||||
| Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) | Some(F64) => return,
|
||||
Some(CxxString) => { /* todo */ }
|
||||
Some(Bool) | Some(RustString) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,13 +304,6 @@ fn is_unsized(cx: &mut Check, ty: &Type) -> bool {
|
||||
ident == CxxString || cx.types.cxx.contains(ident) || cx.types.rust.contains(ident)
|
||||
}
|
||||
|
||||
fn is_valid_vector_element(atom: Atom) -> bool {
|
||||
match atom {
|
||||
U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 | Isize | F32 | F64 => true,
|
||||
Bool | CxxString | RustString => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn span_for_struct_error(strct: &Struct) -> TokenStream {
|
||||
let struct_token = strct.struct_token;
|
||||
let mut brace_token = Group::new(Delimiter::Brace, TokenStream::new());
|
||||
|
Loading…
Reference in New Issue
Block a user