6
6
// This pass is supposed to perform only simple checks not requiring name resolution
7
7
// or type checking or some other kind of complex analysis.
8
8
9
+ use std:: mem;
9
10
use rustc:: lint;
10
11
use rustc:: session:: Session ;
11
12
use syntax:: ast:: * ;
@@ -32,22 +33,16 @@ struct AstValidator<'a> {
32
33
}
33
34
34
35
impl < ' 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 ) ;
40
38
f ( self ) ;
41
- self . is_impl_trait_banned = old_is_impl_trait_banned ;
39
+ self . is_impl_trait_banned = old ;
42
40
}
43
41
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) ;
49
44
f ( self ) ;
50
- self . outer_impl_trait = old_outer_impl_trait ;
45
+ self . outer_impl_trait = old ;
51
46
}
52
47
53
48
// Mirrors visit::walk_ty, but tracks relevant state
0 commit comments