@@ -44,7 +44,7 @@ struct CheckWfFcxBuilder<'tcx> {
44
44
impl < ' tcx > CheckWfFcxBuilder < ' tcx > {
45
45
fn with_fcx < F > ( & mut self , f : F )
46
46
where
47
- F : for < ' b > FnOnce ( & FnCtxt < ' b , ' tcx > ) -> Vec < Ty < ' tcx > > ,
47
+ F : for < ' b > FnOnce ( & FnCtxt < ' b , ' tcx > ) -> FxHashSet < Ty < ' tcx > > ,
48
48
{
49
49
let id = self . id ;
50
50
let span = self . span ;
@@ -59,7 +59,7 @@ impl<'tcx> CheckWfFcxBuilder<'tcx> {
59
59
}
60
60
let wf_tys = f ( & fcx) ;
61
61
fcx. select_all_obligations_or_error ( ) ;
62
- fcx. regionck_item ( id, span, & wf_tys) ;
62
+ fcx. regionck_item ( id, span, wf_tys) ;
63
63
} ) ;
64
64
}
65
65
}
@@ -394,7 +394,7 @@ fn check_associated_item(
394
394
let item = fcx. tcx . associated_item ( fcx. tcx . hir ( ) . local_def_id ( item_id) ) ;
395
395
396
396
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 ) ,
398
398
ty:: ImplContainer ( def_id) => {
399
399
( fcx. impl_implied_bounds ( def_id, span) , fcx. tcx . type_of ( def_id) )
400
400
}
@@ -553,7 +553,7 @@ fn check_type_defn<'tcx, F>(
553
553
check_where_clauses ( fcx, item. span , item. def_id . to_def_id ( ) , None ) ;
554
554
555
555
// No implied bounds in a struct definition.
556
- vec ! [ ]
556
+ FxHashSet :: default ( )
557
557
} ) ;
558
558
}
559
559
@@ -579,7 +579,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
579
579
for_item ( tcx, item) . with_fcx ( |fcx| {
580
580
check_where_clauses ( fcx, item. span , item. def_id . to_def_id ( ) , None ) ;
581
581
582
- vec ! [ ]
582
+ FxHashSet :: default ( )
583
583
} ) ;
584
584
}
585
585
@@ -620,7 +620,7 @@ fn check_item_fn(
620
620
for_id ( tcx, item_id, span) . with_fcx ( |fcx| {
621
621
let def_id = tcx. hir ( ) . local_def_id ( item_id) ;
622
622
let sig = tcx. fn_sig ( def_id) ;
623
- let mut implied_bounds = vec ! [ ] ;
623
+ let mut implied_bounds = FxHashSet :: default ( ) ;
624
624
check_fn_or_method ( fcx, ident. span , sig, decl, def_id. to_def_id ( ) , & mut implied_bounds) ;
625
625
implied_bounds
626
626
} )
@@ -659,7 +659,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo
659
659
}
660
660
661
661
// No implied bounds in a const, etc.
662
- vec ! [ ]
662
+ FxHashSet :: default ( )
663
663
} ) ;
664
664
}
665
665
@@ -918,14 +918,14 @@ fn check_fn_or_method<'fcx, 'tcx>(
918
918
sig : ty:: PolyFnSig < ' tcx > ,
919
919
hir_decl : & hir:: FnDecl < ' _ > ,
920
920
def_id : DefId ,
921
- implied_bounds : & mut Vec < Ty < ' tcx > > ,
921
+ implied_bounds : & mut FxHashSet < Ty < ' tcx > > ,
922
922
) {
923
923
let sig = fcx. tcx . liberate_late_bound_regions ( def_id, sig) ;
924
924
925
925
// Unnormalized types in signature are WF too
926
926
implied_bounds. extend ( sig. inputs ( ) ) ;
927
927
// FIXME(#27579) return types should not be implied bounds
928
- implied_bounds. push ( sig. output ( ) ) ;
928
+ implied_bounds. insert ( sig. output ( ) ) ;
929
929
930
930
// Normalize the input and output types one at a time, using a different
931
931
// `WellFormedLoc` for each. We cannot call `normalize_associated_types`
@@ -977,7 +977,7 @@ fn check_fn_or_method<'fcx, 'tcx>(
977
977
) ;
978
978
979
979
// FIXME(#27579) return types should not be implied bounds
980
- implied_bounds. push ( sig. output ( ) ) ;
980
+ implied_bounds. insert ( sig. output ( ) ) ;
981
981
982
982
debug ! ( ?implied_bounds) ;
983
983
@@ -1513,7 +1513,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1513
1513
. collect ( )
1514
1514
}
1515
1515
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 > > {
1517
1521
match self . tcx . impl_trait_ref ( impl_def_id) {
1518
1522
Some ( trait_ref) => {
1519
1523
// Trait impl: take implied bounds from all types that
@@ -1526,7 +1530,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1526
1530
// Inherent impl: take implied bounds from the `self` type.
1527
1531
let self_ty = self . tcx . type_of ( impl_def_id) ;
1528
1532
let self_ty = self . normalize_associated_types_in ( span, self_ty) ;
1529
- vec ! [ self_ty]
1533
+ std :: array :: IntoIter :: new ( [ self_ty] ) . collect ( )
1530
1534
}
1531
1535
}
1532
1536
}
0 commit comments