@@ -433,10 +433,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
433
433
}
434
434
}
435
435
436
- fn with_hir_id_owner < F , T > ( & mut self , owner : Option < NodeId > , f : F ) -> T
437
- where
438
- F : FnOnce ( & mut Self ) -> T ,
439
- {
436
+ fn with_hir_id_owner < T > (
437
+ & mut self ,
438
+ owner : Option < NodeId > ,
439
+ f : impl FnOnce ( & mut Self ) -> T ,
440
+ ) -> T {
440
441
let old = mem:: replace ( & mut self . hir_id_owner , owner) ;
441
442
let r = f ( self ) ;
442
443
self . hir_id_owner = old;
@@ -577,10 +578,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
577
578
lowered
578
579
}
579
580
580
- fn lower_node_id_generic < F > ( & mut self , ast_node_id : NodeId , alloc_hir_id : F ) -> hir:: HirId
581
- where
582
- F : FnOnce ( & mut Self ) -> hir:: HirId ,
583
- {
581
+ fn lower_node_id_generic (
582
+ & mut self ,
583
+ ast_node_id : NodeId ,
584
+ alloc_hir_id : impl FnOnce ( & mut Self ) -> hir:: HirId ,
585
+ ) -> hir:: HirId {
584
586
if ast_node_id == DUMMY_NODE_ID {
585
587
return hir:: DUMMY_HIR_ID ;
586
588
}
@@ -604,10 +606,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
604
606
}
605
607
}
606
608
607
- fn with_hir_id_owner < F , T > ( & mut self , owner : NodeId , f : F ) -> T
608
- where
609
- F : FnOnce ( & mut Self ) -> T ,
610
- {
609
+ fn with_hir_id_owner < T > ( & mut self , owner : NodeId , f : impl FnOnce ( & mut Self ) -> T ) -> T {
611
610
let counter = self
612
611
. item_local_id_counters
613
612
. insert ( owner, HIR_ID_COUNTER_LOCKED )
@@ -736,15 +735,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
736
735
/// Presuming that in-band lifetimes are enabled, then
737
736
/// `self.anonymous_lifetime_mode` will be updated to match the
738
737
/// parameter while `f` is running (and restored afterwards).
739
- fn collect_in_band_defs < T , F > (
738
+ fn collect_in_band_defs < T > (
740
739
& mut self ,
741
740
parent_id : DefId ,
742
741
anonymous_lifetime_mode : AnonymousLifetimeMode ,
743
- f : F ,
744
- ) -> ( Vec < hir:: GenericParam < ' hir > > , T )
745
- where
746
- F : FnOnce ( & mut Self ) -> ( Vec < hir:: GenericParam < ' hir > > , T ) ,
747
- {
742
+ f : impl FnOnce ( & mut Self ) -> ( Vec < hir:: GenericParam < ' hir > > , T ) ,
743
+ ) -> ( Vec < hir:: GenericParam < ' hir > > , T ) {
748
744
assert ! ( !self . is_collecting_in_band_lifetimes) ;
749
745
assert ! ( self . lifetimes_to_define. is_empty( ) ) ;
750
746
let old_anonymous_lifetime_mode = self . anonymous_lifetime_mode ;
@@ -847,10 +843,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
847
843
// This is used to track which lifetimes have already been defined, and
848
844
// which are new in-band lifetimes that need to have a definition created
849
845
// for them.
850
- fn with_in_scope_lifetime_defs < T , F > ( & mut self , params : & [ GenericParam ] , f : F ) -> T
851
- where
852
- F : FnOnce ( & mut Self ) -> T ,
853
- {
846
+ fn with_in_scope_lifetime_defs < T > (
847
+ & mut self ,
848
+ params : & [ GenericParam ] ,
849
+ f : impl FnOnce ( & mut Self ) -> T ,
850
+ ) -> T {
854
851
let old_len = self . in_scope_lifetimes . len ( ) ;
855
852
let lt_def_names = params. iter ( ) . filter_map ( |param| match param. kind {
856
853
GenericParamKind :: Lifetime { .. } => Some ( ParamName :: Plain ( param. ident . modern ( ) ) ) ,
@@ -870,16 +867,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
870
867
/// Presuming that in-band lifetimes are enabled, then
871
868
/// `self.anonymous_lifetime_mode` will be updated to match the
872
869
/// parameter while `f` is running (and restored afterwards).
873
- fn add_in_band_defs < F , T > (
870
+ fn add_in_band_defs < T > (
874
871
& mut self ,
875
872
generics : & Generics ,
876
873
parent_id : DefId ,
877
874
anonymous_lifetime_mode : AnonymousLifetimeMode ,
878
- f : F ,
879
- ) -> ( hir:: Generics < ' hir > , T )
880
- where
881
- F : FnOnce ( & mut Self , & mut Vec < hir:: GenericParam < ' hir > > ) -> T ,
882
- {
875
+ f : impl FnOnce ( & mut Self , & mut Vec < hir:: GenericParam < ' hir > > ) -> T ,
876
+ ) -> ( hir:: Generics < ' hir > , T ) {
883
877
let ( in_band_defs, ( mut lowered_generics, res) ) =
884
878
self . with_in_scope_lifetime_defs ( & generics. params , |this| {
885
879
this. collect_in_band_defs ( parent_id, anonymous_lifetime_mode, |this| {
@@ -917,10 +911,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
917
911
( lowered_generics, res)
918
912
}
919
913
920
- fn with_dyn_type_scope < T , F > ( & mut self , in_scope : bool , f : F ) -> T
921
- where
922
- F : FnOnce ( & mut Self ) -> T ,
923
- {
914
+ fn with_dyn_type_scope < T > ( & mut self , in_scope : bool , f : impl FnOnce ( & mut Self ) -> T ) -> T {
924
915
let was_in_dyn_type = self . is_in_dyn_type ;
925
916
self . is_in_dyn_type = in_scope;
926
917
@@ -931,10 +922,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
931
922
result
932
923
}
933
924
934
- fn with_new_scopes < T , F > ( & mut self , f : F ) -> T
935
- where
936
- F : FnOnce ( & mut Self ) -> T ,
937
- {
925
+ fn with_new_scopes < T > ( & mut self , f : impl FnOnce ( & mut Self ) -> T ) -> T {
938
926
let was_in_loop_condition = self . is_in_loop_condition ;
939
927
self . is_in_loop_condition = false ;
940
928
0 commit comments