@@ -698,8 +698,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
698
698
/// freeing up memory).
699
699
///
700
700
/// The way this function works is at a given call it looks at type `base_path_ty` of some base
701
- /// path say P and then vector of projection slices which represent the different captures
702
- /// starting off of P.
701
+ /// path say P and then list of projection slices which represent the different captures moved
702
+ /// into the closure starting off of P.
703
703
///
704
704
/// This will make more sense with an example:
705
705
///
@@ -842,23 +842,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
842
842
// `captured_projs.first().unwrap()` safely.
843
843
// - All entries in `captured_projs` have atleast one projection.
844
844
// Therefore we can call `captured_projs.first().unwrap().first().unwrap()` safely.
845
- ty:: Adt ( def, _) if def. is_box ( ) => {
846
- // We must deref to access paths on top of a Box.
847
- assert ! (
848
- captured_projs
849
- . iter( )
850
- . all( |projs| matches!( projs. first( ) . unwrap( ) . kind, ProjectionKind :: Deref ) )
851
- ) ;
852
845
853
- let next_ty = captured_projs. first ( ) . unwrap ( ) . first ( ) . unwrap ( ) . ty ;
854
- let captured_projs = captured_projs. iter ( ) . map ( |projs| & projs[ 1 ..] ) . collect ( ) ;
855
- self . has_significant_drop_outside_of_captures (
856
- closure_def_id,
857
- closure_span,
858
- next_ty,
859
- captured_projs,
860
- )
861
- }
846
+ // We don't capture derefs in case of move captures, which would have be applied to
847
+ // access any further paths.
848
+ ty:: Adt ( def, _) if def. is_box ( ) => unreachable ! ( ) ,
849
+ ty:: Ref ( ..) => unreachable ! ( ) ,
850
+ ty:: RawPtr ( ..) => unreachable ! ( ) ,
862
851
863
852
ty:: Adt ( def, substs) => {
864
853
// Multi-varaint enums are captured in entirety,
@@ -929,27 +918,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
929
918
} )
930
919
}
931
920
932
- ty:: Ref ( _, deref_ty, _) => {
933
- // Only Derefs can be applied to a Ref
934
- assert ! (
935
- captured_projs
936
- . iter( )
937
- . all( |projs| matches!( projs. first( ) . unwrap( ) . kind, ProjectionKind :: Deref ) )
938
- ) ;
939
-
940
- let captured_projs = captured_projs. iter ( ) . map ( |projs| & projs[ 1 ..] ) . collect ( ) ;
941
- self . has_significant_drop_outside_of_captures (
942
- closure_def_id,
943
- closure_span,
944
- deref_ty,
945
- captured_projs,
946
- )
947
- }
948
-
949
- // Unsafe Ptrs are captured in their entirety, which would've have been handled in
950
- // the case of single empty slice in `captured_projs`.
951
- ty:: RawPtr ( ..) => unreachable ! ( ) ,
952
-
921
+ // Anything else would be completely captured and therefore handled already.
953
922
_ => unreachable ! ( ) ,
954
923
}
955
924
}
0 commit comments