Skip to content

Commit 9638cbf

Browse files
nikomatsakisJorge Aparicio
authored andcommitted
---
yaml --- r: 171251 b: refs/heads/batch c: c98814b h: refs/heads/master i: 171249: 37d93a2 171247: 4e116a6 v: v3
1 parent 3490a1a commit 9638cbf

File tree

6 files changed

+86
-3
lines changed

6 files changed

+86
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/issue-18208-method-dispatch-2: 9e1eae4fb9b6527315b4441cf8a0f5ca911d1671
3030
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32-
refs/heads/batch: f97b124a44944feb41c39a4478eda55dbc5da44d
32+
refs/heads/batch: c98814b1243ddde1f41fbc86815397b3091f2215
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 496dc4eae7de9d14cd49511a9acfbf5f11ae6c3f
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/batch/src/librustc_trans/trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
100100

101101
fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
102102
-> Callee<'blk, 'tcx> {
103-
let DatumBlock { mut bcx, datum, .. } = expr::trans(bcx, expr);
103+
let DatumBlock { bcx, datum, .. } = expr::trans(bcx, expr);
104104
match datum.ty.sty {
105105
ty::ty_bare_fn(..) => {
106106
let llval = datum.to_llscalarish(bcx);

branches/batch/src/librustc_trans/trans/meth.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,27 @@ pub fn trans_object_shim<'a, 'tcx>(
599599
bcx.val_to_string(llobject));
600600

601601
// the remaining arguments will be, well, whatever they are
602+
let input_tys =
603+
match fty.abi {
604+
RustCall => {
605+
// unpack the tuple to extract the input type arguments:
606+
match fty.sig.0.inputs[1].sty {
607+
ty::ty_tup(ref tys) => tys.as_slice(),
608+
_ => {
609+
bcx.sess().bug(
610+
format!("rust-call expects a tuple not {}",
611+
fty.sig.0.inputs[1].repr(tcx)).as_slice());
612+
}
613+
}
614+
}
615+
_ => {
616+
// skip the self parameter:
617+
fty.sig.0.inputs.slice_from(1)
618+
}
619+
};
620+
602621
let llargs: Vec<_> =
603-
fty.sig.0.inputs[1..].iter()
622+
input_tys.iter()
604623
.enumerate()
605624
.map(|(i, _)| {
606625
let llarg = get_param(fcx.llfn, fcx.arg_pos(i+1) as u32);
@@ -609,6 +628,7 @@ pub fn trans_object_shim<'a, 'tcx>(
609628
llarg
610629
})
611630
.collect();
631+
612632
assert!(!fcx.needs_ret_allocas);
613633

614634
let dest =
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests calls to closure arguments where the closure takes 1 argument.
12+
// This is a bit tricky due to rust-call ABI.
13+
14+
fn foo(f: &mut FnMut(int) -> int) -> int {
15+
f(22)
16+
}
17+
18+
fn main() {
19+
let z = foo(&mut |x| x *100);
20+
assert_eq!(z, 2200);
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests calls to closure arguments where the closure takes 2 arguments.
12+
// This is a bit tricky due to rust-call ABI.
13+
14+
fn foo(f: &mut FnMut(int, int) -> int) -> int {
15+
f(1, 2)
16+
}
17+
18+
fn main() {
19+
let z = foo(&mut |x, y| x * 10 + y);
20+
assert_eq!(z, 12);
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests calls to closure arguments where the closure takes 0 arguments.
12+
// This is a bit tricky due to rust-call ABI.
13+
14+
fn foo(f: &mut FnMut()) -> int {
15+
f()
16+
}
17+
18+
fn main() {
19+
let z = foo(|| 22);
20+
assert_eq!(z, 22);
21+
}

0 commit comments

Comments
 (0)