rust/compiler/rustc_mir_dataflow/src
bors 7b3cd075bb Auto merge of #90788 - ecstatic-morse:issue-90752, r=wesleywiser
Mark places as initialized when mutably borrowed

Fixes the example in #90752, but does not handle some corner cases involving raw pointers and unsafe. See [this comment](https://github.com/rust-lang/rust/issues/90752#issuecomment-965822895) for more information, or the second test.

Although I talked about both `MaybeUninitializedPlaces` and `MaybeInitializedPlaces` in #90752, this PR only changes the latter. That's because "maybe uninitialized" is the conservative choice, and marking them as definitely initialized (`!maybe_uninitialized`) when a mutable borrow is created could lead to problems if `addr_of_mut` to an uninitialized local is allowed. Additionally, places cannot become uninitialized via a mutable reference, so if a place is definitely initialized, taking a mutable reference to it should not change that.

I think it's correct to ignore interior mutability as nbdd0121 suggests below. Their analysis doesn't work inside of `core::cell`, which *does* have access to `UnsafeCell`'s field, but that won't be an issue unless we explicitly instantiate one with an `enum` within that module.

r? `@wesleywiser`
2021-11-23 17:44:33 +00:00
..
framework Ignore errors re: unreachable blocks in dataflow cursor unit tests 2021-10-23 21:55:57 -04:00
impls Mark mutably borrowed places as maybe initialized 2021-11-13 11:16:57 -08:00
move_paths Replace Fn impls with RPIT impls in rustc_index 2021-10-03 17:50:53 +02:00
drop_flag_effects.rs Move the dataflow framework to its own crate. 2021-09-07 19:57:07 +02:00
elaborate_drops.rs Use associated_item_def_ids more 2021-11-11 23:15:57 +00:00
lib.rs update cfg(bootstrap) 2021-10-23 21:55:57 -04:00
rustc_peek.rs Remove MaybeMutBorrowedLocals 2021-11-03 16:43:12 +01:00
storage.rs Move the dataflow framework to its own crate. 2021-09-07 19:57:07 +02:00