Skip to content

Commit 7473082

Browse files
committed
---
yaml --- r: 63872 b: refs/heads/snap-stage3 c: 2a40c5d h: refs/heads/master v: v3
1 parent 2ae6147 commit 7473082

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
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: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 08a5278bb5cd11d7a4f986db627a585bdad878d7
4+
refs/heads/snap-stage3: 2a40c5db469b5065f64c69ae7874f162ff2669a8
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/callee.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,7 @@ pub fn trans_call_inner(in_cx: block,
615615
}
616616
Method(d) => {
617617
// Weird but true: we pass self in the *environment* slot!
618-
let llself = PointerCast(bcx,
619-
d.llself,
620-
Type::opaque_box(ccx).ptr_to());
621-
(d.llfn, llself)
618+
(d.llfn, d.llself)
622619
}
623620
Closure(d) => {
624621
// Closures are represented as (llfn, llclosure) pair:
@@ -944,10 +941,6 @@ pub fn trans_arg_expr(bcx: block,
944941
if formal_arg_ty != arg_datum.ty {
945942
// this could happen due to e.g. subtyping
946943
let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, &formal_arg_ty);
947-
let llformal_arg_ty = match self_mode {
948-
ty::ByRef => llformal_arg_ty.ptr_to(),
949-
ty::ByCopy => llformal_arg_ty,
950-
};
951944
debug!("casting actual type (%s) to match formal (%s)",
952945
bcx.val_to_str(val), bcx.llty_str(llformal_arg_ty));
953946
val = PointerCast(bcx, val, llformal_arg_ty);

branches/snap-stage3/src/librustc/middle/trans/meth.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ pub fn trans_self_arg(bcx: block,
133133
let _icx = push_ctxt("impl::trans_self_arg");
134134
let mut temp_cleanups = ~[];
135135

136-
// Compute the type of self.
137-
let self_ty = monomorphize_type(bcx, mentry.self_ty);
136+
// self is passed as an opaque box in the environment slot
137+
let self_ty = ty::mk_opaque_box(bcx.tcx());
138138
let result = trans_arg_expr(bcx,
139139
self_ty,
140140
mentry.self_mode,
@@ -576,7 +576,6 @@ pub fn trans_trait_callee_from_llval(bcx: block,
576576
let llbox = Load(bcx, GEPi(bcx, llpair, [0u, abi::trt_field_box]));
577577

578578
// Munge `llself` appropriately for the type of `self` in the method.
579-
let self_mode;
580579
match explicit_self {
581580
ast::sty_static => {
582581
bcx.tcx().sess.bug("shouldn't see static method here");
@@ -597,12 +596,6 @@ pub fn trans_trait_callee_from_llval(bcx: block,
597596
llself = llbox;
598597
}
599598
}
600-
601-
let llscratch = alloca(bcx, val_ty(llself));
602-
Store(bcx, llself, llscratch);
603-
llself = llscratch;
604-
605-
self_mode = ty::ByRef;
606599
}
607600
ast::sty_box(_) => {
608601
// Bump the reference count on the box.
@@ -615,28 +608,20 @@ pub fn trans_trait_callee_from_llval(bcx: block,
615608
ty::BoxTraitStore => llself = llbox,
616609
_ => bcx.tcx().sess.bug("@self receiver with non-@Trait")
617610
}
618-
619-
let llscratch = alloca(bcx, val_ty(llself));
620-
Store(bcx, llself, llscratch);
621-
llself = llscratch;
622-
623-
self_mode = ty::ByRef;
624611
}
625612
ast::sty_uniq(_) => {
626613
// Pass the unique pointer.
627614
match store {
628615
ty::UniqTraitStore => llself = llbox,
629616
_ => bcx.tcx().sess.bug("~self receiver with non-~Trait")
630617
}
631-
632-
let llscratch = alloca(bcx, val_ty(llself));
633-
Store(bcx, llself, llscratch);
634-
llself = llscratch;
635-
636-
self_mode = ty::ByRef;
637618
}
638619
}
639620

621+
let llscratch = alloca(bcx, val_ty(llself));
622+
Store(bcx, llself, llscratch);
623+
llself = PointerCast(bcx, llscratch, Type::opaque_box(ccx).ptr_to());
624+
640625
// Load the function from the vtable and cast it to the expected type.
641626
debug!("(translating trait callee) loading method");
642627
let llcallee_ty = type_of_fn_from_ty(ccx, callee_ty);
@@ -652,7 +637,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
652637
llfn: mptr,
653638
llself: llself,
654639
self_ty: ty::mk_opaque_box(bcx.tcx()),
655-
self_mode: self_mode,
640+
self_mode: ty::ByRef,
656641
explicit_self: explicit_self
657642
/* XXX: Some(llbox) */
658643
})

0 commit comments

Comments
 (0)