@@ -54,6 +54,7 @@ use util::ppaux::Repr;
54
54
55
55
use std:: gc:: Gc ;
56
56
use syntax:: ast;
57
+ use syntax:: ast_map;
57
58
use synabi = syntax:: abi;
58
59
59
60
pub struct MethodData {
@@ -66,7 +67,7 @@ pub enum CalleeData {
66
67
67
68
// Constructor for enum variant/tuple-like-struct
68
69
// i.e. Some, Ok
69
- TupleVariantConstructor ( subst:: Substs , ty:: Disr ) ,
70
+ NamedTupleConstructor ( subst:: Substs , ty:: Disr ) ,
70
71
71
72
// Represents a (possibly monomorphized) top-level fn item or method
72
73
// item. Note that this is just the fn-ptr and is not a Rust closure
@@ -138,6 +139,23 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> {
138
139
debug ! ( "trans_def(def={}, ref_expr={})" , def. repr( bcx. tcx( ) ) , ref_expr. repr( bcx. tcx( ) ) ) ;
139
140
let expr_ty = node_id_type ( bcx, ref_expr. id ) ;
140
141
match def {
142
+ def:: DefFn ( did, _) if {
143
+ let def_id = if did. krate != ast:: LOCAL_CRATE {
144
+ inline:: maybe_instantiate_inline ( bcx. ccx ( ) , did)
145
+ } else {
146
+ did
147
+ } ;
148
+ match bcx. tcx ( ) . map . find ( def_id. node ) {
149
+ Some ( ast_map:: NodeStructCtor ( _) ) => true ,
150
+ _ => false
151
+ }
152
+ } => {
153
+ let substs = node_id_substs ( bcx, ExprId ( ref_expr. id ) ) ;
154
+ Callee {
155
+ bcx : bcx,
156
+ data : NamedTupleConstructor ( substs, 0 )
157
+ }
158
+ }
141
159
def:: DefFn ( did, _) if match ty:: get ( expr_ty) . sty {
142
160
ty:: ty_bare_fn( ref f) => f. abi == synabi:: RustIntrinsic ,
143
161
_ => false
@@ -170,11 +188,15 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> {
170
188
171
189
Callee {
172
190
bcx : bcx,
173
- data : TupleVariantConstructor ( substs, vinfo. disr_val )
191
+ data : NamedTupleConstructor ( substs, vinfo. disr_val )
174
192
}
175
193
}
176
- def:: DefStruct ( def_id) => {
177
- fn_callee ( bcx, trans_fn_ref ( bcx, def_id, ExprId ( ref_expr. id ) ) )
194
+ def:: DefStruct ( _) => {
195
+ let substs = node_id_substs ( bcx, ExprId ( ref_expr. id ) ) ;
196
+ Callee {
197
+ bcx : bcx,
198
+ data : NamedTupleConstructor ( substs, 0 )
199
+ }
178
200
}
179
201
def:: DefStatic ( ..) |
180
202
def:: DefArg ( ..) |
@@ -719,13 +741,13 @@ pub fn trans_call_inner<'a>(
719
741
arg_cleanup_scope, args,
720
742
dest. unwrap ( ) , substs) ;
721
743
}
722
- TupleVariantConstructor ( substs, disr) => {
744
+ NamedTupleConstructor ( substs, disr) => {
723
745
assert ! ( dest. is_some( ) ) ;
724
746
fcx. pop_custom_cleanup_scope ( arg_cleanup_scope) ;
725
747
726
748
let ctor_ty = callee_ty. subst ( bcx. tcx ( ) , & substs) ;
727
- return base:: trans_enum_variant_constructor ( bcx, ctor_ty, disr,
728
- args, dest. unwrap ( ) ) ;
749
+ return base:: trans_named_tuple_constructor ( bcx, ctor_ty, disr,
750
+ args, dest. unwrap ( ) ) ;
729
751
}
730
752
} ;
731
753
0 commit comments