@@ -176,7 +176,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
176
176
self . demand_eqtype ( span, inferred_kind. to_ty ( self . tcx ) , closure_kind_ty) ;
177
177
178
178
// If we have an origin, store it.
179
- if let Some ( origin) = delegate. current_origin {
179
+ if let Some ( origin) = delegate. current_origin . clone ( ) {
180
+ let origin = if self . tcx . features ( ) . capture_disjoint_fields {
181
+ origin
182
+ } else {
183
+ // FIXME(project-rfc-2229#26): Once rust-lang#80092 is merged, we should restrict the
184
+ // precision of origin as well. Otherwise, this will cause issues when project-rfc-2229#26
185
+ // is fixed as we might see Index projections in the origin, which we can't print because
186
+ // we don't store enough information.
187
+ ( origin. 0 , Place { projections : vec ! [ ] , ..origin. 1 } )
188
+ } ;
189
+
180
190
self . typeck_results
181
191
. borrow_mut ( )
182
192
. closure_kind_origins_mut ( )
@@ -563,7 +573,7 @@ struct InferBorrowKind<'a, 'tcx> {
563
573
564
574
// If we modified `current_closure_kind`, this field contains a `Some()` with the
565
575
// variable access that caused us to do so.
566
- current_origin : Option < ( Span , Symbol ) > ,
576
+ current_origin : Option < ( Span , Place < ' tcx > ) > ,
567
577
568
578
/// For each Place that is captured by the closure, we track the minimal kind of
569
579
/// access we need (ref, ref mut, move, etc) and the expression that resulted in such access.
@@ -628,7 +638,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
628
638
upvar_id. closure_expr_id ,
629
639
ty:: ClosureKind :: FnOnce ,
630
640
usage_span,
631
- var_name ( tcx , upvar_id . var_path . hir_id ) ,
641
+ place_with_id . place . clone ( ) ,
632
642
) ;
633
643
634
644
let capture_info = ty:: CaptureInfo {
@@ -720,7 +730,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
720
730
upvar_id. closure_expr_id ,
721
731
ty:: ClosureKind :: FnMut ,
722
732
tcx. hir ( ) . span ( diag_expr_id) ,
723
- var_name ( tcx , upvar_id . var_path . hir_id ) ,
733
+ place_with_id . place . clone ( ) ,
724
734
) ;
725
735
}
726
736
}
@@ -765,11 +775,11 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
765
775
closure_id : LocalDefId ,
766
776
new_kind : ty:: ClosureKind ,
767
777
upvar_span : Span ,
768
- var_name : Symbol ,
778
+ place : Place < ' tcx > ,
769
779
) {
770
780
debug ! (
771
- "adjust_closure_kind(closure_id={:?}, new_kind={:?}, upvar_span={:?}, var_name={ })" ,
772
- closure_id, new_kind, upvar_span, var_name
781
+ "adjust_closure_kind(closure_id={:?}, new_kind={:?}, upvar_span={:?}, place={:? })" ,
782
+ closure_id, new_kind, upvar_span, place
773
783
) ;
774
784
775
785
// Is this the closure whose kind is currently being inferred?
@@ -797,7 +807,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
797
807
| ( ty:: ClosureKind :: FnMut , ty:: ClosureKind :: FnOnce ) => {
798
808
// new kind is stronger than the old kind
799
809
self . current_closure_kind = new_kind;
800
- self . current_origin = Some ( ( upvar_span, var_name ) ) ;
810
+ self . current_origin = Some ( ( upvar_span, place ) ) ;
801
811
}
802
812
}
803
813
}
0 commit comments