Skip to content

Commit 2879214

Browse files
nikomatsakisJorge Aparicio
authored andcommitted
---
yaml --- r: 168872 b: refs/heads/snap-stage3 c: c98814b h: refs/heads/master v: v3
1 parent 4ba34f4 commit 2879214

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 5e21e17d9638d14af41e27e5ca9a21c8a1bc0170
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: f97b124a44944feb41c39a4478eda55dbc5da44d
4+
refs/heads/snap-stage3: c98814b1243ddde1f41fbc86815397b3091f2215
55
refs/heads/try: 5204084bd2e46af7cc6e0147430e44dd0d657bbb
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/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/snap-stage3/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)