@@ -47,7 +47,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4747 if let Some ( lhs_deref_ty) = self . deref_once_mutably_for_diagnostic ( lhs_ty) {
4848 if self
4949 . lookup_op_method (
50- lhs_deref_ty,
50+ ( lhs , lhs_deref_ty) ,
5151 Some ( ( rhs, rhs_ty) ) ,
5252 Op :: Binary ( op, IsAssign :: Yes ) ,
5353 expected,
@@ -58,7 +58,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5858 // emitted a better suggestion during error handling in check_overloaded_binop.
5959 if self
6060 . lookup_op_method (
61- lhs_ty,
61+ ( lhs , lhs_ty) ,
6262 Some ( ( rhs, rhs_ty) ) ,
6363 Op :: Binary ( op, IsAssign :: Yes ) ,
6464 expected,
@@ -246,7 +246,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
246246 } ) ;
247247
248248 let result = self . lookup_op_method (
249- lhs_ty,
249+ ( lhs_expr , lhs_ty) ,
250250 Some ( ( rhs_expr, rhs_ty_var) ) ,
251251 Op :: Binary ( op, is_assign) ,
252252 expected,
@@ -391,7 +391,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
391391 |err : & mut DiagnosticBuilder < ' _ , _ > , lhs_deref_ty : Ty < ' tcx > | {
392392 if self
393393 . lookup_op_method (
394- lhs_deref_ty,
394+ ( lhs_expr , lhs_deref_ty) ,
395395 Some ( ( rhs_expr, rhs_ty) ) ,
396396 Op :: Binary ( op, is_assign) ,
397397 expected,
@@ -424,7 +424,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
424424 rhs_new_mutbl : Option < ast:: Mutability > | {
425425 if self
426426 . lookup_op_method (
427- lhs_adjusted_ty,
427+ ( lhs_expr , lhs_adjusted_ty) ,
428428 Some ( ( rhs_expr, rhs_adjusted_ty) ) ,
429429 Op :: Binary ( op, is_assign) ,
430430 expected,
@@ -479,7 +479,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
479479
480480 let is_compatible_after_call = |lhs_ty, rhs_ty| {
481481 self . lookup_op_method (
482- lhs_ty,
482+ ( lhs_expr , lhs_ty) ,
483483 Some ( ( rhs_expr, rhs_ty) ) ,
484484 Op :: Binary ( op, is_assign) ,
485485 expected,
@@ -578,7 +578,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
578578 // suggestion for the user.
579579 let errors = self
580580 . lookup_op_method (
581- lhs_ty,
581+ ( lhs_expr , lhs_ty) ,
582582 Some ( ( rhs_expr, rhs_ty) ) ,
583583 Op :: Binary ( op, is_assign) ,
584584 expected,
@@ -779,7 +779,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
779779 expected : Expectation < ' tcx > ,
780780 ) -> Ty < ' tcx > {
781781 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) {
783783 Ok ( method) => {
784784 self . write_method_call_and_enforce_effects ( ex. hir_id , ex. span , method) ;
785785 method. sig . output ( )
@@ -865,7 +865,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
865865
866866 fn lookup_op_method (
867867 & self ,
868- lhs_ty : Ty < ' tcx > ,
868+ ( lhs_expr , lhs_ty) : ( & ' tcx hir :: Expr < ' tcx > , Ty < ' tcx > ) ,
869869 opt_rhs : Option < ( & ' tcx hir:: Expr < ' tcx > , Ty < ' tcx > ) > ,
870870 op : Op ,
871871 expected : Expectation < ' tcx > ,
@@ -910,8 +910,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
910910 let cause = self . cause (
911911 span,
912912 traits:: BinOp {
913+ lhs_hir_id : lhs_expr. hir_id ,
914+ rhs_hir_id : opt_rhs_expr. map ( |expr| expr. hir_id ) ,
913915 rhs_span : opt_rhs_expr. map ( |expr| expr. span ) ,
914- is_lit : opt_rhs_expr. is_some_and ( |expr| matches ! ( expr. kind, hir:: ExprKind :: Lit ( _) ) ) ,
916+ rhs_is_lit : opt_rhs_expr
917+ . is_some_and ( |expr| matches ! ( expr. kind, hir:: ExprKind :: Lit ( _) ) ) ,
915918 output_ty : expected. only_has_type ( self ) ,
916919 } ,
917920 ) ;
0 commit comments