Skip to content

Commit 4c88070

Browse files
committed
Use mem::replace instead of rewriting it
1 parent 02a24c8 commit 4c88070

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/librustc_resolve/late.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,9 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
504504

505505
visit::walk_fn_ret_ty(this, &declaration.output);
506506

507-
let previous_state = this.in_func_body;
508507
// Ignore errors in function bodies if this is rustdoc
509508
// Be sure not to set this until the function signature has been resolved.
510-
this.in_func_body = true;
509+
let previous_state = replace(&mut this.in_func_body, true);
511510
// Resolve the function body, potentially inside the body of an async closure
512511
match fn_kind {
513512
FnKind::Fn(.., body) => walk_list!(this, visit_block, body),
@@ -1175,9 +1174,8 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
11751174
impl_items: &'ast [P<AssocItem>],
11761175
) {
11771176
debug!("resolve_implementation");
1178-
let old_ignore = self.in_func_body;
11791177
// Never ignore errors in trait implementations.
1180-
self.in_func_body = false;
1178+
let old_ignore = replace(&mut self.in_func_body, false);
11811179
// If applicable, create a rib for the type parameters.
11821180
self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
11831181
// Dummy self type for better errors if `Self` is used in the trait path.

0 commit comments

Comments
 (0)