Skip to content

Commit 2a241ec

Browse files
committed
rustc: Disallow calling type_of() on dynamically-sized types
1 parent 5dba7a7 commit 2a241ec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/comp/middle/trans.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,17 @@ fn T_opaque_obj_ptr(type_names tn) -> TypeRef {
417417
}
418418

419419

420+
// This function now fails if called on a type with dynamic size (as its
421+
// return value was always meaningless in that case anyhow). Beware!
422+
//
423+
// TODO: Enforce via a predicate.
420424
fn type_of(@crate_ctxt cx, @ty.t t) -> TypeRef {
425+
if (ty.type_has_dynamic_size(t)) {
426+
log "type_of() called on a type with dynamic size: " +
427+
ty.ty_to_str(t);
428+
fail;
429+
}
430+
421431
ret type_of_inner(cx, t);
422432
}
423433

0 commit comments

Comments
 (0)