Skip to content

Commit c465829

Browse files
committed
Fix array element supported condition
This disallows previously wrongly allowed array element types in PR 459 (such as [CxxString; N]) and allows previously disallowed but unproblematic array element types (such as [&str; N]).
1 parent 9075baf commit c465829

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

syntax/check.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,13 @@ fn check_type_slice(cx: &mut Check, ty: &Slice) {
186186
}
187187

188188
fn check_type_array(cx: &mut Check, ty: &Array) {
189-
match &ty.inner {
190-
Type::Ident(ident) => {
191-
if cx.types.rust.contains(&ident.rust) || cx.types.cxx.contains(&ident.rust) {
192-
cx.error(ty, "Only shared structs are supported in array yet");
193-
}
194-
}
195-
Type::RustBox(_) | Type::RustVec(_) | Type::CxxVector(_) | Type::UniquePtr(_) => {}
196-
_ => cx.error(ty, "unsupported array target type"),
189+
let supported = match &ty.inner {
190+
Type::Fn(_) => false,
191+
element => !is_unsized(cx, element),
192+
};
193+
194+
if !supported {
195+
cx.error(ty, "unsupported array element type");
197196
}
198197
}
199198

0 commit comments

Comments
 (0)