Skip to content

Commit 2e04053

Browse files
authored
Merge pull request #651 from dtolnay/slices
Enable slices and arrays containing str/slice
2 parents 10852ed + bf9d6e8 commit 2e04053

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

syntax/check.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ fn check_type_ref(cx: &mut Check, ty: &Ref) {
234234
}
235235

236236
fn check_type_slice_ref(cx: &mut Check, ty: &SliceRef) {
237-
let supported = match &ty.inner {
238-
Type::Str(_) | Type::SliceRef(_) => false,
239-
Type::Ident(ident) => !is_unsized(cx, &ty.inner) || cx.types.rust.contains(&ident.rust),
240-
element => !is_unsized(cx, element),
241-
};
237+
let supported = !is_unsized(cx, &ty.inner)
238+
|| match &ty.inner {
239+
Type::Ident(ident) => cx.types.rust.contains(&ident.rust),
240+
_ => false,
241+
};
242242

243243
if !supported {
244244
let mutable = if ty.mutable { "mut " } else { "" };
@@ -253,10 +253,7 @@ fn check_type_slice_ref(cx: &mut Check, ty: &SliceRef) {
253253
}
254254

255255
fn check_type_array(cx: &mut Check, ty: &Array) {
256-
let supported = match &ty.inner {
257-
Type::Str(_) | Type::SliceRef(_) => false,
258-
element => !is_unsized(cx, element),
259-
};
256+
let supported = !is_unsized(cx, &ty.inner);
260257

261258
if !supported {
262259
cx.error(ty, "unsupported array element type");

0 commit comments

Comments
 (0)