@@ -54,6 +54,7 @@ use util::ppaux::Repr;
5454
5555use std:: gc:: Gc ;
5656use syntax:: ast;
57+ use syntax:: ast_map;
5758use synabi = syntax:: abi;
5859
5960pub struct MethodData {
@@ -66,7 +67,7 @@ pub enum CalleeData {
6667
6768 // Constructor for enum variant/tuple-like-struct
6869 // i.e. Some, Ok
69- TupleVariantConstructor ( subst:: Substs , ty:: Disr ) ,
70+ NamedTupleConstructor ( subst:: Substs , ty:: Disr ) ,
7071
7172 // Represents a (possibly monomorphized) top-level fn item or method
7273 // 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> {
138139 debug ! ( "trans_def(def={}, ref_expr={})" , def. repr( bcx. tcx( ) ) , ref_expr. repr( bcx. tcx( ) ) ) ;
139140 let expr_ty = node_id_type ( bcx, ref_expr. id ) ;
140141 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+ }
141159 def:: DefFn ( did, _) if match ty:: get ( expr_ty) . sty {
142160 ty:: ty_bare_fn( ref f) => f. abi == synabi:: RustIntrinsic ,
143161 _ => false
@@ -170,11 +188,15 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> {
170188
171189 Callee {
172190 bcx : bcx,
173- data : TupleVariantConstructor ( substs, vinfo. disr_val )
191+ data : NamedTupleConstructor ( substs, vinfo. disr_val )
174192 }
175193 }
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+ }
178200 }
179201 def:: DefStatic ( ..) |
180202 def:: DefArg ( ..) |
@@ -719,13 +741,13 @@ pub fn trans_call_inner<'a>(
719741 arg_cleanup_scope, args,
720742 dest. unwrap ( ) , substs) ;
721743 }
722- TupleVariantConstructor ( substs, disr) => {
744+ NamedTupleConstructor ( substs, disr) => {
723745 assert ! ( dest. is_some( ) ) ;
724746 fcx. pop_custom_cleanup_scope ( arg_cleanup_scope) ;
725747
726748 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 ( ) ) ;
729751 }
730752 } ;
731753
0 commit comments