@@ -47,7 +47,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
47
47
if let Some ( lhs_deref_ty) = self . deref_once_mutably_for_diagnostic ( lhs_ty) {
48
48
if self
49
49
. lookup_op_method (
50
- lhs_deref_ty,
50
+ ( lhs , lhs_deref_ty) ,
51
51
Some ( ( rhs, rhs_ty) ) ,
52
52
Op :: Binary ( op, IsAssign :: Yes ) ,
53
53
expected,
@@ -58,7 +58,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
58
58
// emitted a better suggestion during error handling in check_overloaded_binop.
59
59
if self
60
60
. lookup_op_method (
61
- lhs_ty,
61
+ ( lhs , lhs_ty) ,
62
62
Some ( ( rhs, rhs_ty) ) ,
63
63
Op :: Binary ( op, IsAssign :: Yes ) ,
64
64
expected,
@@ -246,7 +246,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
246
246
} ) ;
247
247
248
248
let result = self . lookup_op_method (
249
- lhs_ty,
249
+ ( lhs_expr , lhs_ty) ,
250
250
Some ( ( rhs_expr, rhs_ty_var) ) ,
251
251
Op :: Binary ( op, is_assign) ,
252
252
expected,
@@ -391,7 +391,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
391
391
|err : & mut DiagnosticBuilder < ' _ , _ > , lhs_deref_ty : Ty < ' tcx > | {
392
392
if self
393
393
. lookup_op_method (
394
- lhs_deref_ty,
394
+ ( lhs_expr , lhs_deref_ty) ,
395
395
Some ( ( rhs_expr, rhs_ty) ) ,
396
396
Op :: Binary ( op, is_assign) ,
397
397
expected,
@@ -424,7 +424,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
424
424
rhs_new_mutbl : Option < ast:: Mutability > | {
425
425
if self
426
426
. lookup_op_method (
427
- lhs_adjusted_ty,
427
+ ( lhs_expr , lhs_adjusted_ty) ,
428
428
Some ( ( rhs_expr, rhs_adjusted_ty) ) ,
429
429
Op :: Binary ( op, is_assign) ,
430
430
expected,
@@ -479,7 +479,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
479
479
480
480
let is_compatible_after_call = |lhs_ty, rhs_ty| {
481
481
self . lookup_op_method (
482
- lhs_ty,
482
+ ( lhs_expr , lhs_ty) ,
483
483
Some ( ( rhs_expr, rhs_ty) ) ,
484
484
Op :: Binary ( op, is_assign) ,
485
485
expected,
@@ -578,7 +578,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
578
578
// suggestion for the user.
579
579
let errors = self
580
580
. lookup_op_method (
581
- lhs_ty,
581
+ ( lhs_expr , lhs_ty) ,
582
582
Some ( ( rhs_expr, rhs_ty) ) ,
583
583
Op :: Binary ( op, is_assign) ,
584
584
expected,
@@ -779,7 +779,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
779
779
expected : Expectation < ' tcx > ,
780
780
) -> Ty < ' tcx > {
781
781
assert ! ( op. is_by_value( ) ) ;
782
- match self . lookup_op_method ( operand_ty, None , Op :: Unary ( op, ex. span ) , expected) {
782
+ match self . lookup_op_method ( ( ex , operand_ty) , None , Op :: Unary ( op, ex. span ) , expected) {
783
783
Ok ( method) => {
784
784
self . write_method_call_and_enforce_effects ( ex. hir_id , ex. span , method) ;
785
785
method. sig . output ( )
@@ -865,7 +865,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
865
865
866
866
fn lookup_op_method (
867
867
& self ,
868
- lhs_ty : Ty < ' tcx > ,
868
+ ( lhs_expr , lhs_ty) : ( & ' tcx hir :: Expr < ' tcx > , Ty < ' tcx > ) ,
869
869
opt_rhs : Option < ( & ' tcx hir:: Expr < ' tcx > , Ty < ' tcx > ) > ,
870
870
op : Op ,
871
871
expected : Expectation < ' tcx > ,
@@ -909,8 +909,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
909
909
let cause = self . cause (
910
910
span,
911
911
traits:: BinOp {
912
+ lhs_hir_id : lhs_expr. hir_id ,
913
+ rhs_hir_id : opt_rhs_expr. map ( |expr| expr. hir_id ) ,
912
914
rhs_span : opt_rhs_expr. map ( |expr| expr. span ) ,
913
- is_lit : opt_rhs_expr. is_some_and ( |expr| matches ! ( expr. kind, hir:: ExprKind :: Lit ( _) ) ) ,
915
+ rhs_is_lit : opt_rhs_expr
916
+ . is_some_and ( |expr| matches ! ( expr. kind, hir:: ExprKind :: Lit ( _) ) ) ,
914
917
output_ty : expected. only_has_type ( self ) ,
915
918
} ,
916
919
) ;
0 commit comments