]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Auto merge of #69113 - ecstatic-morse:unified-dataflow-borrowed, r=wesleywiser
authorbors <bors@rust-lang.org>
Wed, 19 Feb 2020 04:57:10 +0000 (04:57 +0000)
committerbors <bors@rust-lang.org>
Wed, 19 Feb 2020 04:57:10 +0000 (04:57 +0000)
commit3a8108d8e52e13f3f1a151a93addfcf4a86b97f5
treecc8222823aa713e37dbc4bf0c0444bbd16377a17
parenta2fb0c28be794f28028884650db70c17fea8e35b
parent077a93c6a9b1c8ee0e541ea484f7e13c207d50d0
Auto merge of #69113 - ecstatic-morse:unified-dataflow-borrowed, r=wesleywiser

Combine `HaveBeenBorrowedLocals` and `IndirectlyMutableLocals` into one dataflow analysis

This PR began as an attempt to port `HaveBeenBorrowedLocals` to the new dataflow framework (see #68241 for prior art). Along the way, I noticed that it could share most of its code with `IndirectlyMutableLocals` and then found a few bugs in the two analyses:
- Neither one marked locals as borrowed after an `Rvalue::AddressOf`.
- `IndirectlyMutableLocals` was missing a minor fix that `HaveBeenBorrowedLocals` got in #61069. This is not a problem today since it is only used during const-checking, where custom drop glue is forbidden. However, this may change some day.

I decided to combine the two analyses so that they wouldn't diverge in the future while ensuring that they remain distinct types (called `MaybeBorrowedLocals` and `MaybeMutBorrowedLocals` to be consistent with the `Maybe{Un,}InitializedPlaces` naming scheme). I fixed the bugs and switched to exhaustive matching where possible to make them less likely in the future. Finally, I added comments explaining some of the finer points of the transfer function for these analyses (see #61069 and #65006).
src/librustc_mir/transform/check_consts/validation.rs
src/librustc_mir/transform/generator.rs