@@ -21,6 +21,7 @@ use rustc::middle::traits;
21
21
use rustc:: mir:: repr:: ItemKind ;
22
22
use trans:: common:: { Block , fulfill_obligation} ;
23
23
use trans:: base;
24
+ use trans:: closure;
24
25
use trans:: expr;
25
26
use trans:: monomorphize;
26
27
use trans:: meth;
@@ -38,6 +39,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
38
39
substs : & ' tcx Substs < ' tcx > ,
39
40
did : DefId )
40
41
-> OperandRef < ' tcx > {
42
+ debug ! ( "trans_item_ref(ty={:?}, kind={:?}, substs={:?}, did={})" ,
43
+ ty, kind, substs, bcx. tcx( ) . item_path_str( did) ) ;
44
+
41
45
match kind {
42
46
ItemKind :: Function => self . trans_fn_ref ( bcx, ty, substs, did) ,
43
47
ItemKind :: Method => match bcx. tcx ( ) . impl_or_trait_item ( did) . container ( ) {
@@ -68,6 +72,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
68
72
substs : & ' tcx Substs < ' tcx > ,
69
73
did : DefId )
70
74
-> OperandRef < ' tcx > {
75
+ debug ! ( "trans_fn_ref(ty={:?}, substs={:?}, did={})" ,
76
+ ty, substs, bcx. tcx( ) . item_path_str( did) ) ;
77
+
71
78
let did = inline:: maybe_instantiate_inline ( bcx. ccx ( ) , did) ;
72
79
73
80
if !substs. types . is_empty ( ) || is_named_tuple_constructor ( bcx. tcx ( ) , did) {
@@ -101,9 +108,14 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
101
108
trait_id : DefId ,
102
109
substs : & ' tcx Substs < ' tcx > )
103
110
-> OperandRef < ' tcx > {
111
+ debug ! ( "trans_static_method(ty={:?}, method={}, trait={}, substs={:?})" ,
112
+ ty,
113
+ bcx. tcx( ) . item_path_str( method_id) ,
114
+ bcx. tcx( ) . item_path_str( trait_id) ,
115
+ substs) ;
116
+
104
117
let ccx = bcx. ccx ( ) ;
105
118
let tcx = bcx. tcx ( ) ;
106
- let mname = tcx. item_name ( method_id) ;
107
119
let subst:: SeparateVecsPerParamSpace {
108
120
types : rcvr_type,
109
121
selfs : rcvr_self,
@@ -118,6 +130,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
118
130
match vtbl {
119
131
traits:: VtableImpl ( traits:: VtableImplData { impl_def_id, substs : imp_substs, .. } ) => {
120
132
assert ! ( !imp_substs. types. needs_infer( ) ) ;
133
+
134
+ let mname = tcx. item_name ( method_id) ;
135
+
121
136
let subst:: SeparateVecsPerParamSpace {
122
137
types : impl_type,
123
138
selfs : impl_self,
@@ -130,6 +145,17 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
130
145
let mthsubsts = tcx. mk_substs ( mth. substs ) ;
131
146
self . trans_fn_ref ( bcx, ty, mthsubsts, mth. method . def_id )
132
147
} ,
148
+ traits:: VtableClosure ( data) => {
149
+ let trait_closure_kind = bcx. tcx ( ) . lang_items . fn_trait_kind ( trait_id) . unwrap ( ) ;
150
+ let llfn = closure:: trans_closure_method ( bcx. ccx ( ) ,
151
+ data. closure_def_id ,
152
+ data. substs ,
153
+ trait_closure_kind) ;
154
+ OperandRef {
155
+ ty : ty,
156
+ val : OperandValue :: Immediate ( llfn)
157
+ }
158
+ } ,
133
159
traits:: VtableObject ( ref data) => {
134
160
let idx = traits:: get_vtable_index_of_object_method ( tcx, data, method_id) ;
135
161
OperandRef :: from_rvalue_datum (
0 commit comments