Skip to content

Commit

Permalink
Use mem::replace instead of rewriting it
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Jul 15, 2020
1 parent 02a24c8 commit 4c88070
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/librustc_resolve/late.rs
Expand Up @@ -504,10 +504,9 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {

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

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

0 comments on commit 4c88070

Please sign in to comment.