@@ -76,29 +76,18 @@ struct AstValidator<'a> {
76
76
warning_period_57979_impl_trait_in_proj : bool ,
77
77
}
78
78
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
-
95
79
impl < ' a > AstValidator < ' a > {
96
80
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
98
85
}
99
86
100
87
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;
102
91
}
103
92
104
93
fn with_banned_assoc_ty_bound ( & mut self , f : impl FnOnce ( & mut Self ) ) {
@@ -108,7 +97,9 @@ impl<'a> AstValidator<'a> {
108
97
}
109
98
110
99
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;
112
103
}
113
104
114
105
fn visit_assoc_ty_constraint_from_generic_args ( & mut self , constraint : & ' a AssocTyConstraint ) {
0 commit comments