@@ -560,7 +560,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
560560 reasons
561561 }
562562
563- fn ty_contains_trait (
563+ /// Returns true if `ty` may implement `trait_def_id`
564+ fn ty_impls_trait (
564565 & self ,
565566 ty : Ty < ' tcx > ,
566567 cause : & ObligationCause < ' tcx > ,
@@ -615,32 +616,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
615616 let clone_obligation_should_hold = tcx
616617 . lang_items ( )
617618 . clone_trait ( )
618- . map ( |clone_trait| self . ty_contains_trait ( ty, & cause, clone_trait) )
619+ . map ( |clone_trait| self . ty_impls_trait ( ty, & cause, clone_trait) )
619620 . unwrap_or ( false ) ;
620621 let sync_obligation_should_hold = tcx
621622 . lang_items ( )
622623 . sync_trait ( )
623- . map ( |sync_trait| self . ty_contains_trait ( ty, & cause, sync_trait) )
624+ . map ( |sync_trait| self . ty_impls_trait ( ty, & cause, sync_trait) )
624625 . unwrap_or ( false ) ;
625626 let send_obligation_should_hold = tcx
626627 . lang_items ( )
627628 . send_trait ( )
628- . map ( |send_trait| self . ty_contains_trait ( ty, & cause, send_trait) )
629+ . map ( |send_trait| self . ty_impls_trait ( ty, & cause, send_trait) )
629630 . unwrap_or ( false ) ;
630631 let unpin_obligation_should_hold = tcx
631632 . lang_items ( )
632633 . unpin_trait ( )
633- . map ( |unpin_trait| self . ty_contains_trait ( ty, & cause, unpin_trait) )
634+ . map ( |unpin_trait| self . ty_impls_trait ( ty, & cause, unpin_trait) )
634635 . unwrap_or ( false ) ;
635636 let unwind_safe_obligation_should_hold = tcx
636637 . lang_items ( )
637638 . unwind_safe_trait ( )
638- . map ( |unwind_safe_trait| self . ty_contains_trait ( ty, & cause, unwind_safe_trait) )
639+ . map ( |unwind_safe_trait| self . ty_impls_trait ( ty, & cause, unwind_safe_trait) )
639640 . unwrap_or ( false ) ;
640641 let ref_unwind_safe_obligation_should_hold = tcx
641642 . lang_items ( )
642643 . ref_unwind_safe_trait ( )
643- . map ( |ref_unwind_safe_trait| self . ty_contains_trait ( ty, & cause, ref_unwind_safe_trait) )
644+ . map ( |ref_unwind_safe_trait| self . ty_impls_trait ( ty, & cause, ref_unwind_safe_trait) )
644645 . unwrap_or ( false ) ;
645646
646647 // Check whether catpured fields also implement the trait
@@ -652,34 +653,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
652653 let clone_obligation_holds_for_capture = tcx
653654 . lang_items ( )
654655 . clone_trait ( )
655- . map ( |clone_trait| self . ty_contains_trait ( ty, & cause, clone_trait) )
656+ . map ( |clone_trait| self . ty_impls_trait ( ty, & cause, clone_trait) )
656657 . unwrap_or ( false ) ;
657658 let sync_obligation_holds_for_capture = tcx
658659 . lang_items ( )
659660 . sync_trait ( )
660- . map ( |sync_trait| self . ty_contains_trait ( ty, & cause, sync_trait) )
661+ . map ( |sync_trait| self . ty_impls_trait ( ty, & cause, sync_trait) )
661662 . unwrap_or ( false ) ;
662663 let send_obligation_holds_for_capture = tcx
663664 . lang_items ( )
664665 . send_trait ( )
665- . map ( |send_trait| self . ty_contains_trait ( ty, & cause, send_trait) )
666+ . map ( |send_trait| self . ty_impls_trait ( ty, & cause, send_trait) )
666667 . unwrap_or ( false ) ;
667668 let unpin_obligation_holds_for_capture = tcx
668669 . lang_items ( )
669670 . unpin_trait ( )
670- . map ( |unpin_trait| self . ty_contains_trait ( ty, & cause, unpin_trait) )
671+ . map ( |unpin_trait| self . ty_impls_trait ( ty, & cause, unpin_trait) )
671672 . unwrap_or ( false ) ;
672673 let unwind_safe_obligation_holds_for_capture = tcx
673674 . lang_items ( )
674675 . unwind_safe_trait ( )
675- . map ( |unwind_safe| self . ty_contains_trait ( ty, & cause, unwind_safe) )
676+ . map ( |unwind_safe| self . ty_impls_trait ( ty, & cause, unwind_safe) )
676677 . unwrap_or ( false ) ;
677678 let ref_unwind_safe_obligation_holds_for_capture = tcx
678679 . lang_items ( )
679680 . ref_unwind_safe_trait ( )
680- . map ( |ref_unwind_safe_trait| {
681- self . ty_contains_trait ( ty, & cause, ref_unwind_safe_trait)
682- } )
681+ . map ( |ref_unwind_safe_trait| self . ty_impls_trait ( ty, & cause, ref_unwind_safe_trait) )
683682 . unwrap_or ( false ) ;
684683
685684 if !clone_obligation_holds_for_capture && clone_obligation_should_hold {
@@ -732,11 +731,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
732731 min_captures : Option < & ty:: RootVariableMinCaptureList < ' tcx > > ,
733732 closure_clause : hir:: CaptureBy ,
734733 var_hir_id : hir:: HirId ,
735- ) -> Option < ( ) > {
734+ ) -> bool {
736735 let ty = self . infcx . resolve_vars_if_possible ( self . node_ty ( var_hir_id) ) ;
737736
738737 if !ty. needs_drop ( self . tcx , self . tcx . param_env ( closure_def_id. expect_local ( ) ) ) {
739- return None ;
738+ return false ;
740739 }
741740
742741 let root_var_min_capture_list = if let Some ( root_var_min_capture_list) =
@@ -749,11 +748,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
749748
750749 match closure_clause {
751750 // Only migrate if closure is a move closure
752- hir:: CaptureBy :: Value => return Some ( ( ) ) ,
751+ hir:: CaptureBy :: Value => return true ,
753752 hir:: CaptureBy :: Ref => { }
754753 }
755754
756- return None ;
755+ return false ;
757756 } ;
758757
759758 let projections_list = root_var_min_capture_list
@@ -779,10 +778,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
779778 projections_list,
780779 )
781780 {
782- return Some ( ( ) ) ;
781+ return true ;
783782 }
784783
785- return None ;
784+ return false ;
786785 }
787786
788787 /// Figures out the list of root variables (and their types) that aren't completely
@@ -816,27 +815,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
816815
817816 // Perform auto-trait analysis
818817 for ( & var_hir_id, _) in upvars. iter ( ) {
819- // println!("CHeck auto traits");
820- let mut need_some_migrations = false ;
818+ let mut need_migration = false ;
821819 if let Some ( trait_migration_cause) =
822820 self . compute_2229_migrations_for_trait ( min_captures, closure_clause, var_hir_id)
823821 {
824- need_some_migrations = true ;
822+ need_migration = true ;
825823 auto_trait_reasons. extend ( trait_migration_cause) ;
826824 }
827825
828- if let Some ( _ ) = self . compute_2229_migrations_for_drop (
826+ if self . compute_2229_migrations_for_drop (
829827 closure_def_id,
830828 closure_span,
831829 min_captures,
832830 closure_clause,
833831 var_hir_id,
834832 ) {
835- need_some_migrations = true ;
833+ need_migration = true ;
836834 drop_reorder_reason = true ;
837835 }
838836
839- if need_some_migrations {
837+ if need_migration {
840838 need_migrations. push ( var_hir_id) ;
841839 }
842840 }
0 commit comments