]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk
authorbors <bors@rust-lang.org>
Thu, 14 Oct 2021 13:21:46 +0000 (13:21 +0000)
committerbors <bors@rust-lang.org>
Thu, 14 Oct 2021 13:21:46 +0000 (13:21 +0000)
commit0a56eb11fafdd3c9d86c100b6b90505f5f9fdb00
tree37f0352dc7c9bb2f06bdbf0728e83623b075a845
parentc34ac8747ca96d09cb08b8f5adddead826e77c06
parent8fc329f5d2305d2f127752e7af3a37e07a1a89dc
Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk

Add check that live_region is live in sanitize_promoted

This pull request fixes #88434 by adding a check in `sanitize_promoted` to ensure that only regions which are actually live are added to the `liveness_constraints` of the `BorrowCheckContext`.

To implement this change, I needed to add a method to `LivenessValues` which gets the elements contained by a region:

    /// Returns an iterator of all the elements contained by the region `r`
    crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_

Then, inside `sanitize_promoted`, we check whether the iterator returned by this method is non-empty to ensure that the region is actually live at at least one location before adding that region to the `liveness_constraints` of the `BorrowCheckContext`.

This is my first pull request to the Rust repo, so any feedback on how I can improve this pull request or if there is a better way to fix this issue would be very appreciated.
compiler/rustc_borrowck/src/type_check/mod.rs