Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 625e4dd

Browse files
committedApr 11, 2022
Auto merge of #95125 - JakobDegen:uninit-variant-rvalue, r=oli-obk
Add new `Deinit` statement This rvalue replaces `SetDiscriminant` for ADTs. This PR is an alternative to #94590 , which only specifies that the behavior of `SetDiscriminant` is the same as what this rvalue would do. The motivation for this change are discussed in that PR and [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/SetDiscriminant.20and.20aggregate.20initialization.20.2394590) r? `@oli-obk`
2 parents 43998d5 + 2f03767 commit 625e4dd

File tree

128 files changed

+744
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+744
-293
lines changed
 

‎compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
386386

387387
mir::StatementKind::FakeRead(..)
388388
| mir::StatementKind::SetDiscriminant { .. }
389+
| mir::StatementKind::Deinit(..)
389390
| mir::StatementKind::StorageLive(..)
390391
| mir::StatementKind::Retag { .. }
391392
| mir::StatementKind::AscribeUserType(..)

‎compiler/rustc_borrowck/src/def_use.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,9 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
7272

7373
// Debug info is neither def nor use.
7474
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,
75+
76+
PlaceContext::MutatingUse(MutatingUseContext::Deinit | MutatingUseContext::SetDiscriminant) => {
77+
bug!("These statements are not allowed in this MIR phase")
78+
}
7579
}
7680
}

0 commit comments

Comments
 (0)
Please sign in to comment.