Skip to content

Commit a5d4aed

Browse files
committed
Address some comments
1 parent 13dc584 commit a5d4aed

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/librustc_passes/ast_validation.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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;
910
use rustc::lint;
1011
use rustc::session::Session;
1112
use syntax::ast::*;
@@ -32,22 +33,16 @@ struct AstValidator<'a> {
3233
}
3334

3435
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);
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

Comments
 (0)