diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-03-03 14:10:36 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-03-03 14:10:36 -0800 |
| commit | 2a241ece3a8fdaa536946b29eeab4524da164903 (patch) | |
| tree | 89a0406929dbb323b67d64611e6f96887cc48915 /src/comp | |
| parent | 5dba7a77d2c7396989262da3de5ea055bed151bc (diff) | |
| download | rust-2a241ece3a8fdaa536946b29eeab4524da164903.tar.gz rust-2a241ece3a8fdaa536946b29eeab4524da164903.zip | |
rustc: Disallow calling type_of() on dynamically-sized types
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 9587b008dc6..65f5b135e68 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -417,7 +417,17 @@ fn T_opaque_obj_ptr(type_names tn) -> TypeRef { } +// This function now fails if called on a type with dynamic size (as its +// return value was always meaningless in that case anyhow). Beware! +// +// TODO: Enforce via a predicate. fn type_of(@crate_ctxt cx, @ty.t t) -> TypeRef { + if (ty.type_has_dynamic_size(t)) { + log "type_of() called on a type with dynamic size: " + + ty.ty_to_str(t); + fail; + } + ret type_of_inner(cx, t); } |
