Skip to content

Commit 133dd50

Browse files
committed
---
yaml --- r: 1198 b: refs/heads/master c: f3f63da h: refs/heads/master v: v3
1 parent 45322cf commit 133dd50

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 5d2a6c73ca5b0e082c3fb2a3eee40e18029355f9
2+
refs/heads/master: f3f63da7c8ac7c89b95a85f1e7c1d4ec300dea0d

trunk/src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
418418
arith-0.rs \
419419
arith-1.rs \
420420
arith-2.rs \
421+
bind-trivial.rs \
421422
bitwise.rs \
422423
bool-not.rs \
423424
box.rs \

trunk/src/comp/middle/trans.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,18 +1952,30 @@ impure fn trans_bind(@block_ctxt cx, @ast.expr f,
19521952
vec[option.t[@ast.expr]] args,
19531953
&ast.ann ann) -> result {
19541954
auto f_res = trans_lval(cx, f);
1955-
auto bcx = f_res.res.bcx;
1956-
auto pair_t = node_type(cx.fcx.ccx, ann);
1957-
auto pair_v = bcx.build.Alloca(pair_t);
19581955
if (f_res.is_mem) {
19591956
cx.fcx.ccx.sess.unimpl("re-binding existing function");
19601957
} else {
1961-
auto code_cell =
1962-
bcx.build.GEP(pair_v, vec(C_int(0),
1963-
C_int(abi.fn_field_code)));
1964-
bcx.build.Store(f_res.res.val, code_cell);
1958+
let vec[@ty.t] bound = vec();
1959+
for (option.t[@ast.expr] argopt in args) {
1960+
alt (argopt) {
1961+
case (none[@ast.expr]) {
1962+
}
1963+
case (some[@ast.expr](?e)) {
1964+
append[@ty.t](bound, ty.expr_ty(e));
1965+
}
1966+
}
1967+
}
1968+
if (_vec.len[@ty.t](bound) == 0u) {
1969+
// Trivial 'binding': just return the static pair-ptr.
1970+
ret f_res.res;
1971+
} else {
1972+
auto bcx = f_res.res.bcx;
1973+
auto pair_t = node_type(cx.fcx.ccx, ann);
1974+
auto pair_v = bcx.build.Alloca(pair_t);
1975+
cx.fcx.ccx.sess.unimpl("nontrivial binding");
1976+
ret res(bcx, pair_v);
1977+
}
19651978
}
1966-
ret res(bcx, pair_v);
19671979
}
19681980

19691981
impure fn trans_call(@block_ctxt cx, @ast.expr f,

0 commit comments

Comments
 (0)