@@ -44,7 +44,7 @@ struct CheckWfFcxBuilder<'tcx> {
4444impl < ' tcx > CheckWfFcxBuilder < ' tcx > {
4545 fn with_fcx < F > ( & mut self , f : F )
4646 where
47- F : for < ' b > FnOnce ( & FnCtxt < ' b , ' tcx > ) -> Vec < Ty < ' tcx > > ,
47+ F : for < ' b > FnOnce ( & FnCtxt < ' b , ' tcx > ) -> FxHashSet < Ty < ' tcx > > ,
4848 {
4949 let id = self . id ;
5050 let span = self . span ;
@@ -59,7 +59,7 @@ impl<'tcx> CheckWfFcxBuilder<'tcx> {
5959 }
6060 let wf_tys = f ( & fcx) ;
6161 fcx. select_all_obligations_or_error ( ) ;
62- fcx. regionck_item ( id, span, & wf_tys) ;
62+ fcx. regionck_item ( id, span, wf_tys) ;
6363 } ) ;
6464 }
6565}
@@ -394,7 +394,7 @@ fn check_associated_item(
394394 let item = fcx. tcx . associated_item ( fcx. tcx . hir ( ) . local_def_id ( item_id) ) ;
395395
396396 let ( mut implied_bounds, self_ty) = match item. container {
397- ty:: TraitContainer ( _) => ( vec ! [ ] , fcx. tcx . types . self_param ) ,
397+ ty:: TraitContainer ( _) => ( FxHashSet :: default ( ) , fcx. tcx . types . self_param ) ,
398398 ty:: ImplContainer ( def_id) => {
399399 ( fcx. impl_implied_bounds ( def_id, span) , fcx. tcx . type_of ( def_id) )
400400 }
@@ -553,7 +553,7 @@ fn check_type_defn<'tcx, F>(
553553 check_where_clauses ( fcx, item. span , item. def_id . to_def_id ( ) , None ) ;
554554
555555 // No implied bounds in a struct definition.
556- vec ! [ ]
556+ FxHashSet :: default ( )
557557 } ) ;
558558}
559559
@@ -579,7 +579,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
579579 for_item ( tcx, item) . with_fcx ( |fcx| {
580580 check_where_clauses ( fcx, item. span , item. def_id . to_def_id ( ) , None ) ;
581581
582- vec ! [ ]
582+ FxHashSet :: default ( )
583583 } ) ;
584584}
585585
@@ -620,7 +620,7 @@ fn check_item_fn(
620620 for_id ( tcx, item_id, span) . with_fcx ( |fcx| {
621621 let def_id = tcx. hir ( ) . local_def_id ( item_id) ;
622622 let sig = tcx. fn_sig ( def_id) ;
623- let mut implied_bounds = vec ! [ ] ;
623+ let mut implied_bounds = FxHashSet :: default ( ) ;
624624 check_fn_or_method ( fcx, ident. span , sig, decl, def_id. to_def_id ( ) , & mut implied_bounds) ;
625625 implied_bounds
626626 } )
@@ -659,7 +659,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo
659659 }
660660
661661 // No implied bounds in a const, etc.
662- vec ! [ ]
662+ FxHashSet :: default ( )
663663 } ) ;
664664}
665665
@@ -918,14 +918,14 @@ fn check_fn_or_method<'fcx, 'tcx>(
918918 sig : ty:: PolyFnSig < ' tcx > ,
919919 hir_decl : & hir:: FnDecl < ' _ > ,
920920 def_id : DefId ,
921- implied_bounds : & mut Vec < Ty < ' tcx > > ,
921+ implied_bounds : & mut FxHashSet < Ty < ' tcx > > ,
922922) {
923923 let sig = fcx. tcx . liberate_late_bound_regions ( def_id, sig) ;
924924
925925 // Unnormalized types in signature are WF too
926926 implied_bounds. extend ( sig. inputs ( ) ) ;
927927 // FIXME(#27579) return types should not be implied bounds
928- implied_bounds. push ( sig. output ( ) ) ;
928+ implied_bounds. insert ( sig. output ( ) ) ;
929929
930930 // Normalize the input and output types one at a time, using a different
931931 // `WellFormedLoc` for each. We cannot call `normalize_associated_types`
@@ -977,7 +977,7 @@ fn check_fn_or_method<'fcx, 'tcx>(
977977 ) ;
978978
979979 // FIXME(#27579) return types should not be implied bounds
980- implied_bounds. push ( sig. output ( ) ) ;
980+ implied_bounds. insert ( sig. output ( ) ) ;
981981
982982 debug ! ( ?implied_bounds) ;
983983
@@ -1513,7 +1513,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15131513 . collect ( )
15141514 }
15151515
1516- pub ( super ) fn impl_implied_bounds ( & self , impl_def_id : DefId , span : Span ) -> Vec < Ty < ' tcx > > {
1516+ pub ( super ) fn impl_implied_bounds (
1517+ & self ,
1518+ impl_def_id : DefId ,
1519+ span : Span ,
1520+ ) -> FxHashSet < Ty < ' tcx > > {
15171521 match self . tcx . impl_trait_ref ( impl_def_id) {
15181522 Some ( trait_ref) => {
15191523 // Trait impl: take implied bounds from all types that
@@ -1526,7 +1530,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15261530 // Inherent impl: take implied bounds from the `self` type.
15271531 let self_ty = self . tcx . type_of ( impl_def_id) ;
15281532 let self_ty = self . normalize_associated_types_in ( span, self_ty) ;
1529- vec ! [ self_ty]
1533+ std :: array :: IntoIter :: new ( [ self_ty] ) . collect ( )
15301534 }
15311535 }
15321536 }
0 commit comments