@@ -9,6 +9,7 @@ use crate::traits::normalize_projection_type;
9
9
10
10
use rustc_data_structures:: fx:: FxHashSet ;
11
11
use rustc_data_structures:: stack:: ensure_sufficient_stack;
12
+ use rustc_data_structures:: sync:: Lrc ;
12
13
use rustc_errors:: { error_code, struct_span_err, Applicability , DiagnosticBuilder , Style } ;
13
14
use rustc_hir as hir;
14
15
use rustc_hir:: def:: DefKind ;
@@ -678,19 +679,18 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
678
679
has_custom_message : bool ,
679
680
) -> bool {
680
681
let span = obligation. cause . span ;
681
- let points_at_for_iter = matches ! (
682
- span. ctxt( ) . outer_expn_data( ) . kind,
683
- ExpnKind :: Desugaring ( DesugaringKind :: ForLoop ( ForLoopLoc :: IntoIter ) )
684
- ) ;
685
682
686
- let code =
687
- if let ( ObligationCauseCode :: FunctionArgumentObligation { parent_code, .. } , false ) =
688
- ( & obligation. cause . code , points_at_for_iter)
689
- {
690
- parent_code. clone ( )
691
- } else {
692
- return false ;
693
- } ;
683
+ let code = if let ObligationCauseCode :: FunctionArgumentObligation { parent_code, .. } =
684
+ & obligation. cause . code
685
+ {
686
+ parent_code. clone ( )
687
+ } else if let ExpnKind :: Desugaring ( DesugaringKind :: ForLoop ( ForLoopLoc :: IntoIter ) ) =
688
+ span. ctxt ( ) . outer_expn_data ( ) . kind
689
+ {
690
+ Lrc :: new ( obligation. cause . code . clone ( ) )
691
+ } else {
692
+ return false ;
693
+ } ;
694
694
695
695
// List of traits for which it would be nonsensical to suggest borrowing.
696
696
// For instance, immutable references are always Copy, so suggesting to
0 commit comments