@@ -76,29 +76,18 @@ struct AstValidator<'a> {
7676 warning_period_57979_impl_trait_in_proj : bool ,
7777}
7878
79- /// With the `new` value in `store`,
80- /// runs and returns the `scoped` computation,
81- /// resetting the old value of `store` after,
82- /// and returning the result of `scoped`.
83- fn with < C , T , S > (
84- this : & mut C ,
85- new : S ,
86- store : impl Fn ( & mut C ) -> & mut S ,
87- scoped : impl FnOnce ( & mut C ) -> T
88- ) -> T {
89- let old = mem:: replace ( store ( this) , new) ;
90- let ret = scoped ( this) ;
91- * store ( this) = old;
92- ret
93- }
94-
9579impl < ' a > AstValidator < ' a > {
9680 fn with_impl_trait_in_proj_warning < T > ( & mut self , v : bool , f : impl FnOnce ( & mut Self ) -> T ) -> T {
97- with ( self , v, |this| & mut this. warning_period_57979_impl_trait_in_proj , f)
81+ let old = mem:: replace ( & mut self . warning_period_57979_impl_trait_in_proj , v) ;
82+ let ret = f ( self ) ;
83+ self . warning_period_57979_impl_trait_in_proj = old;
84+ ret
9885 }
9986
10087 fn with_banned_impl_trait ( & mut self , f : impl FnOnce ( & mut Self ) ) {
101- with ( self , true , |this| & mut this. is_impl_trait_banned , f)
88+ let old = mem:: replace ( & mut self . is_impl_trait_banned , true ) ;
89+ f ( self ) ;
90+ self . is_impl_trait_banned = old;
10291 }
10392
10493 fn with_banned_assoc_ty_bound ( & mut self , f : impl FnOnce ( & mut Self ) ) {
@@ -108,7 +97,9 @@ impl<'a> AstValidator<'a> {
10897 }
10998
11099 fn with_impl_trait ( & mut self , outer : Option < OuterImplTrait > , f : impl FnOnce ( & mut Self ) ) {
111- with ( self , outer, |this| & mut this. outer_impl_trait , f)
100+ let old = mem:: replace ( & mut self . outer_impl_trait , outer) ;
101+ f ( self ) ;
102+ self . outer_impl_trait = old;
112103 }
113104
114105 fn visit_assoc_ty_constraint_from_generic_args ( & mut self , constraint : & ' a AssocTyConstraint ) {
0 commit comments