Skip to content

Commit daac7a8

Browse files
committed
rustc: Add a type_has_dynamic_size predicate
1 parent 3f3a121 commit daac7a8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/comp/middle/ty.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,27 @@ fn type_is_scalar(@t ty) -> bool {
379379
fail;
380380
}
381381

382+
fn type_has_dynamic_size(@t ty) -> bool {
383+
alt (ty.struct) {
384+
case (ty_tup(?ts)) {
385+
auto i = 0u;
386+
while (i < _vec.len[@t](ts)) {
387+
if (type_has_dynamic_size(ts.(i))) { ret true; }
388+
i += 1u;
389+
}
390+
}
391+
case (ty_rec(?fields)) {
392+
auto i = 0u;
393+
while (i < _vec.len[field](fields)) {
394+
if (type_has_dynamic_size(fields.(i).ty)) { ret true; }
395+
i += 1u;
396+
}
397+
}
398+
case (ty_param(_)) { ret true; }
399+
case (_) { /* fall through */ }
400+
}
401+
ret false;
402+
}
382403

383404
fn type_is_integral(@t ty) -> bool {
384405
alt (ty.struct) {

0 commit comments

Comments
 (0)