diff options
| author | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2024-06-05 10:57:27 +0200 |
|---|---|---|
| committer | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2024-06-05 10:57:27 +0200 |
| commit | 7b5b7a70101324e590709c0e80effc5d99fc69de (patch) | |
| tree | 892d4c43d49f0fb4d66c88c9eb2ad0fb759d5bda /compiler/rustc_borrowck/src/dataflow.rs | |
| parent | 85f90a461262f7ca37a6e629933d455fa9c3ee48 (diff) | |
| download | rust-7b5b7a70101324e590709c0e80effc5d99fc69de.tar.gz rust-7b5b7a70101324e590709c0e80effc5d99fc69de.zip | |
Remove confusing `use_polonius` flag and do less cloning
The `use_polonius` flag is both redundant and confusing since every function it's propagated to also checks if `all_facts` is `Some`, the true test of whether to generate Polonius facts for Polonius or for external consumers. This PR makes that path clearer by simply doing away with the argument and handling the logic in precisely two places: where facts are populated (check for `Some`), and where `all_facts` are initialised. It also delays some statements until after that check to avoid the miniscule performance penalty of executing them when Polonius is disabled. This also addresses @lqd's concern in #125652 by reducing the size of what is cloned out of Polonius facts to just the facts being added, as opposed to the entire vector of potential inputs, and added descriptive comments. *Reviewer note*: the comments in [add_extra_drop_facts](https://github.com/rust-lang/rust/blob/85f90a461262f7ca37a6e629933d455fa9c3ee48/compiler/rustc_borrowck/src/type_check/liveness/trace.rs#L219) should be inspected by a reviewer, in particular the one on L#259 in this PR, which should be trivial for someone with the right background knowledge. I also included some minor lints I found on the way there that I couldn't help myself from addressing.
Diffstat (limited to 'compiler/rustc_borrowck/src/dataflow.rs')
| -rw-r--r-- | compiler/rustc_borrowck/src/dataflow.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index ec7d4582a60..f2b5ddcd782 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -43,9 +43,9 @@ impl<'mir, 'tcx> ResultsVisitable<'tcx> for BorrowckResults<'mir, 'tcx> { } fn reset_to_block_entry(&self, state: &mut Self::FlowState, block: BasicBlock) { - state.borrows.clone_from(&self.borrows.entry_set_for_block(block)); - state.uninits.clone_from(&self.uninits.entry_set_for_block(block)); - state.ever_inits.clone_from(&self.ever_inits.entry_set_for_block(block)); + state.borrows.clone_from(self.borrows.entry_set_for_block(block)); + state.uninits.clone_from(self.uninits.entry_set_for_block(block)); + state.ever_inits.clone_from(self.ever_inits.entry_set_for_block(block)); } fn reconstruct_before_statement_effect( |
