@@ -21,6 +21,7 @@ use rustc::ty::cast::CastKind as TyCastKind;
21
21
use rustc:: hir;
22
22
use rustc:: hir:: def_id:: LocalDefId ;
23
23
use rustc:: mir:: { BorrowKind } ;
24
+ use syntax_pos:: Span ;
24
25
25
26
impl < ' tcx > Mirror < ' tcx > for & ' tcx hir:: Expr {
26
27
type Output = Expr < ' tcx > ;
@@ -232,16 +233,17 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
232
233
233
234
let kind = match expr. node {
234
235
// Here comes the interesting stuff:
235
- hir:: ExprKind :: MethodCall ( .. , ref args) => {
236
+ hir:: ExprKind :: MethodCall ( _ , method_span , ref args) => {
236
237
// Rewrite a.b(c) into UFCS form like Trait::b(a, c)
237
- let expr = method_callee ( cx, expr, None ) ;
238
+ let expr = method_callee ( cx, expr, method_span , None ) ;
238
239
let args = args. iter ( )
239
240
. map ( |e| e. to_ref ( ) )
240
241
. collect ( ) ;
241
242
ExprKind :: Call {
242
243
ty : expr. ty ,
243
244
fun : expr. to_ref ( ) ,
244
245
args,
246
+ from_hir_call : true ,
245
247
}
246
248
}
247
249
@@ -254,7 +256,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
254
256
255
257
// rewrite f(u, v) into FnOnce::call_once(f, (u, v))
256
258
257
- let method = method_callee ( cx, expr, None ) ;
259
+ let method = method_callee ( cx, expr, fun . span , None ) ;
258
260
259
261
let arg_tys = args. iter ( ) . map ( |e| cx. tables ( ) . expr_ty_adjusted ( e) ) ;
260
262
let tupled_args = Expr {
@@ -268,6 +270,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
268
270
ty : method. ty ,
269
271
fun : method. to_ref ( ) ,
270
272
args : vec ! [ fun. to_ref( ) , tupled_args. to_ref( ) ] ,
273
+ from_hir_call : true ,
271
274
}
272
275
} else {
273
276
let adt_data = if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, ref path) ) =
@@ -321,6 +324,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
321
324
ty : cx. tables ( ) . node_id_to_type ( fun. hir_id ) ,
322
325
fun : fun. to_ref ( ) ,
323
326
args : args. to_ref ( ) ,
327
+ from_hir_call : true ,
324
328
}
325
329
}
326
330
}
@@ -812,6 +816,7 @@ fn user_annotated_ty_for_adt(
812
816
fn method_callee < ' a , ' gcx , ' tcx > (
813
817
cx : & mut Cx < ' a , ' gcx , ' tcx > ,
814
818
expr : & hir:: Expr ,
819
+ span : Span ,
815
820
overloaded_callee : Option < ( DefId , & ' tcx Substs < ' tcx > ) > ,
816
821
) -> Expr < ' tcx > {
817
822
let temp_lifetime = cx. region_scope_tree . temporary_scope ( expr. hir_id . local_id ) ;
@@ -832,7 +837,7 @@ fn method_callee<'a, 'gcx, 'tcx>(
832
837
Expr {
833
838
temp_lifetime,
834
839
ty,
835
- span : expr . span ,
840
+ span,
836
841
kind : ExprKind :: Literal {
837
842
literal : ty:: Const :: zero_sized ( cx. tcx ( ) , ty) ,
838
843
user_ty,
@@ -1093,11 +1098,12 @@ fn overloaded_operator<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
1093
1098
expr : & ' tcx hir:: Expr ,
1094
1099
args : Vec < ExprRef < ' tcx > > )
1095
1100
-> ExprKind < ' tcx > {
1096
- let fun = method_callee ( cx, expr, None ) ;
1101
+ let fun = method_callee ( cx, expr, expr . span , None ) ;
1097
1102
ExprKind :: Call {
1098
1103
ty : fun. ty ,
1099
1104
fun : fun. to_ref ( ) ,
1100
1105
args,
1106
+ from_hir_call : false ,
1101
1107
}
1102
1108
}
1103
1109
@@ -1132,7 +1138,7 @@ fn overloaded_place<'a, 'gcx, 'tcx>(
1132
1138
// construct the complete expression `foo()` for the overloaded call,
1133
1139
// which will yield the &T type
1134
1140
let temp_lifetime = cx. region_scope_tree . temporary_scope ( expr. hir_id . local_id ) ;
1135
- let fun = method_callee ( cx, expr, overloaded_callee) ;
1141
+ let fun = method_callee ( cx, expr, expr . span , overloaded_callee) ;
1136
1142
let ref_expr = Expr {
1137
1143
temp_lifetime,
1138
1144
ty : ref_ty,
@@ -1141,6 +1147,7 @@ fn overloaded_place<'a, 'gcx, 'tcx>(
1141
1147
ty : fun. ty ,
1142
1148
fun : fun. to_ref ( ) ,
1143
1149
args,
1150
+ from_hir_call : false ,
1144
1151
} ,
1145
1152
} ;
1146
1153
0 commit comments