Skip to content

Commit f5b15eb

Browse files
committed
---
yaml --- r: 50810 b: refs/heads/try c: ab8e46b h: refs/heads/master v: v3
1 parent c007285 commit f5b15eb

File tree

5 files changed

+63
-27
lines changed

5 files changed

+63
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
5-
refs/heads/try: 99ac243e7b789b54231e4607aa775174c7c3995a
5+
refs/heads/try: ab8e46b0660e076e629e6775ed8da9890c5fbf1f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/trans/callee.rs

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,12 @@ pub fn trans_call_inner(
492492
}
493493
};
494494

495-
let llretslot = trans_ret_slot(bcx, fn_expr_ty, dest);
496-
497-
let mut llargs = ~[];
498-
llargs.push(llretslot);
499-
llargs.push(llenv);
500-
bcx = trans_args(bcx, args, fn_expr_ty,
501-
ret_flag, autoref_arg, &mut llargs);
495+
let args_res = trans_args(bcx, llenv, args, fn_expr_ty,
496+
dest, ret_flag, autoref_arg);
497+
bcx = args_res.bcx;
498+
let mut llargs = /*bad*/copy args_res.args;
502499

500+
let llretslot = args_res.retslot;
503501

504502
// Now that the arguments have finished evaluating, we need to revoke
505503
// the cleanup for the self argument, if it exists
@@ -557,12 +555,30 @@ pub enum CallArgs {
557555
ArgVals(&'self [ValueRef])
558556
}
559557

560-
pub fn trans_ret_slot(+bcx: block,
561-
+fn_ty: ty::t,
562-
+dest: expr::Dest) -> ValueRef
563-
{
558+
pub struct Args {
559+
bcx: block,
560+
args: ~[ValueRef],
561+
retslot: ValueRef
562+
}
563+
564+
pub fn trans_args(cx: block,
565+
llenv: ValueRef,
566+
+args: CallArgs,
567+
fn_ty: ty::t,
568+
dest: expr::Dest,
569+
ret_flag: Option<ValueRef>,
570+
+autoref_arg: AutorefArg) -> Args {
571+
let _icx = cx.insn_ctxt("trans_args");
572+
let mut temp_cleanups = ~[];
573+
let arg_tys = ty::ty_fn_args(fn_ty);
574+
let mut llargs: ~[ValueRef] = ~[];
575+
576+
let mut bcx = cx;
577+
564578
let retty = ty::ty_fn_ret(fn_ty);
565-
match dest {
579+
580+
// Arg 0: Output pointer.
581+
let llretslot = match dest {
566582
expr::SaveIn(dst) => dst,
567583
expr::Ignore => {
568584
if ty::type_is_nil(retty) {
@@ -573,21 +589,13 @@ pub fn trans_ret_slot(+bcx: block,
573589
alloc_ty(bcx, retty)
574590
}
575591
}
576-
}
577-
}
592+
};
593+
llargs.push(llretslot);
578594

579-
pub fn trans_args(+cx: block,
580-
+args: CallArgs,
581-
+fn_ty: ty::t,
582-
+ret_flag: Option<ValueRef>,
583-
+autoref_arg: AutorefArg,
584-
+llargs: &mut ~[ValueRef]) -> block
585-
{
586-
let _icx = cx.insn_ctxt("trans_args");
587-
let mut temp_cleanups = ~[];
588-
let arg_tys = ty::ty_fn_args(fn_ty);
595+
// Arg 1: Env (closure-bindings / self value)
596+
llargs.push(llenv);
589597

590-
let mut bcx = cx;
598+
// ... then explicit args.
591599

592600
// First we figure out the caller's view of the types of the arguments.
593601
// This will be needed if this is a generic call, because the callee has
@@ -616,7 +624,7 @@ pub fn trans_args(+cx: block,
616624
revoke_clean(bcx, *c)
617625
}
618626

619-
return bcx;
627+
Args { bcx: bcx, args: llargs, retslot: llretslot }
620628
}
621629

622630
pub enum AutorefArg {

branches/try/src/libsyntax/ext/expand.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,15 @@ pub fn core_macros() -> ~str {
464464
}
465465
)
466466

467+
macro_rules! assert_eq (
468+
($given:expr , $expected:expr) =>
469+
({let given_val = $given;
470+
let expected_val = $expected;
471+
// check both directions of equality....
472+
if !((given_val == expected_val) && (expected_val == given_val)) {
473+
fail!(fmt!(\"expected: %?, given: %?\",expected_val,given_val));
474+
}}))
475+
467476
macro_rules! condition (
468477

469478
{ $c:ident: $in:ty -> $out:ty; } => {
@@ -481,6 +490,7 @@ pub fn core_macros() -> ~str {
481490
}
482491
)
483492

493+
484494
}";
485495
}
486496
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// error-pattern:expected: 15, given: 14
2+
3+
#[deriving_eq]
4+
struct Point { x : int }
5+
6+
fn main() {
7+
assert_eq!(14,15);
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[deriving_eq]
2+
struct Point { x : int }
3+
4+
fn main() {
5+
assert_eq!(14,14);
6+
assert_eq!(~"abc",~"abc");
7+
assert_eq!(~Point{x:34},~Point{x:34});
8+
assert_eq!(&Point{x:34},&Point{x:34});
9+
assert_eq!(@Point{x:34},@Point{x:34});
10+
}

0 commit comments

Comments
 (0)