66// This pass is supposed to perform only simple checks not requiring name resolution
77// or type checking or some other kind of complex analysis.
88
9+ use std:: mem;
910use rustc:: lint;
1011use rustc:: session:: Session ;
1112use syntax:: ast:: * ;
@@ -32,22 +33,16 @@ struct AstValidator<'a> {
3233}
3334
3435impl < ' a > AstValidator < ' a > {
35- fn with_banned_impl_trait < F > ( & mut self , f : F )
36- where F : FnOnce ( & mut Self )
37- {
38- let old_is_impl_trait_banned = self . is_impl_trait_banned ;
39- self . is_impl_trait_banned = true ;
36+ fn with_banned_impl_trait ( & mut self , f : impl FnOnce ( & mut Self ) ) {
37+ let old = mem:: replace ( & mut self . is_impl_trait_banned , true ) ;
4038 f ( self ) ;
41- self . is_impl_trait_banned = old_is_impl_trait_banned ;
39+ self . is_impl_trait_banned = old ;
4240 }
4341
44- fn with_impl_trait < F > ( & mut self , outer_impl_trait : Option < Span > , f : F )
45- where F : FnOnce ( & mut Self )
46- {
47- let old_outer_impl_trait = self . outer_impl_trait ;
48- self . outer_impl_trait = outer_impl_trait;
42+ fn with_impl_trait ( & mut self , outer_impl_trait : Option < Span > , f : impl FnOnce ( & mut Self ) ) {
43+ let old = mem:: replace ( & mut self . outer_impl_trait , outer_impl_trait) ;
4944 f ( self ) ;
50- self . outer_impl_trait = old_outer_impl_trait ;
45+ self . outer_impl_trait = old ;
5146 }
5247
5348 // Mirrors visit::walk_ty, but tracks relevant state
0 commit comments