diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2020-07-11 08:48:25 -0400 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2020-07-15 10:54:06 -0400 |
| commit | 4c88070c87b81c3cf6c8409a78c35ebdf67a67c3 (patch) | |
| tree | 33c2badac7cd7c94c21466cf27cfce18b6b3594b /src | |
| parent | 02a24c8e2fd370041a24b7d93e8c3710b7b76015 (diff) | |
| download | rust-4c88070c87b81c3cf6c8409a78c35ebdf67a67c3.tar.gz rust-4c88070c87b81c3cf6c8409a78c35ebdf67a67c3.zip | |
Use mem::replace instead of rewriting it
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_resolve/late.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 528444b0e98..63b238faff6 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -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), @@ -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. |
