diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-03-23 10:22:23 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-03-23 10:49:47 +0100 |
| commit | cdb93d70a1dc7d966b21b683a24a9c9e9dc521f0 (patch) | |
| tree | 0b51d668112dd28f88bb2f38f234eafac7e408af /src/rustc | |
| parent | 16ca6e8d7f79bb778b8ac3ab5867abf399a2408d (diff) | |
| download | rust-cdb93d70a1dc7d966b21b683a24a9c9e9dc521f0.tar.gz rust-cdb93d70a1dc7d966b21b683a24a9c9e9dc521f0.zip | |
Fix bug in function-instance reuse
You can't safely reuse functions that pass a T by move, since they might zero it out, which will not end well when it doesn't know its precise size.
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/middle/trans/type_use.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 73e6d2662bb..24b6f9cf572 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -179,12 +179,22 @@ fn mark_for_expr(cx: ctx, e: @expr) { expr_new(_, _, v) { node_type_needs(cx, use_repr, v.id); } + expr_call(f, _, _) { + vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id))) {|a| + alt a.mode { + expl(by_move) | expl(by_copy) | expl(by_val) { + type_needs(cx, use_repr, a.ty); + } + _ {} + } + } + } expr_for(_, _, _) | expr_do_while(_, _) | expr_alt(_, _, _) | expr_block(_) | expr_if(_, _, _) | expr_while(_, _) | expr_fail(_) | expr_break | expr_cont | expr_unary(_, _) | expr_lit(_) | expr_assert(_) | expr_check(_, _) | expr_if_check(_, _, _) | expr_mac(_) | expr_addr_of(_, _) | - expr_ret(_) | expr_loop(_) | expr_call(_, _, _) | expr_bind(_, _) {} + expr_ret(_) | expr_loop(_) | expr_bind(_, _) {} } } |
