Skip to content

Commit 9e5551b

Browse files
committed
---
yaml --- r: 85501 b: refs/heads/dist-snap c: 29ab2da h: refs/heads/master i: 85499: 3d24669 v: v3
1 parent 74d3062 commit 9e5551b

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: a1066130c07b864a1612c49b4b84dc34d5f113a1
9+
refs/heads/dist-snap: 29ab2daa5efebb59b5ad4a2710d570e89696e583
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee {
132132
ast::def_struct(def_id) => {
133133
fn_callee(bcx, trans_fn_ref(bcx, def_id, ref_expr.id))
134134
}
135-
ast::def_static(*) |
136135
ast::def_arg(*) |
137136
ast::def_local(*) |
138137
ast::def_binding(*) |
@@ -141,7 +140,7 @@ pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee {
141140
datum_callee(bcx, ref_expr)
142141
}
143142
ast::def_mod(*) | ast::def_foreign_mod(*) | ast::def_trait(*) |
144-
ast::def_ty(*) | ast::def_prim_ty(*) |
143+
ast::def_static(*) | ast::def_ty(*) | ast::def_prim_ty(*) |
145144
ast::def_use(*) | ast::def_typaram_binder(*) |
146145
ast::def_region(*) | ast::def_label(*) | ast::def_ty_param(*) |
147146
ast::def_self_ty(*) | ast::def_method(*) => {

branches/dist-snap/src/librustc/middle/trans/expr.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,14 +795,18 @@ fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::expr,
795795
return bcx;
796796
}
797797
}
798-
ast::def_struct(*) => {
798+
ast::def_struct(def_id) => {
799799
let ty = expr_ty(bcx, ref_expr);
800800
match ty::get(ty).sty {
801801
ty::ty_struct(did, _) if ty::has_dtor(ccx.tcx, did) => {
802802
let repr = adt::represent_type(ccx, ty);
803803
adt::trans_start_init(bcx, repr, lldest, 0);
804804
}
805-
_ => {}
805+
ty::ty_bare_fn(*) => {
806+
let fn_data = callee::trans_fn_ref(bcx, def_id, ref_expr.id);
807+
Store(bcx, fn_data.llfn, lldest);
808+
}
809+
_ => ()
806810
}
807811
return bcx;
808812
}

branches/dist-snap/src/test/run-pass/static-function-pointer.rs renamed to branches/dist-snap/src/test/run-pass/tuple-struct-constructor-pointer.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn f(x: int) -> int { x }
12-
13-
static F: extern fn(int) -> int = f;
14-
static mut G: extern fn(int) -> int = f;
11+
#[deriving(Eq)]
12+
struct Foo(int);
13+
#[deriving(Eq)]
14+
struct Bar(int, int);
1515

1616
fn main() {
17-
F(42);
18-
unsafe { G(7); }
17+
let f: extern fn(int) -> Foo = Foo;
18+
let g: extern fn(int, int) -> Bar = Bar;
19+
assert_eq!(f(42), Foo(42));
20+
assert_eq!(g(4, 7), Bar(4, 7));
1921
}

0 commit comments

Comments
 (0)