From 817c27744ddd6627dcc05fc35f92534b6be6435b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Christopher=20K=C3=B6hl?= Date: Fri, 9 Sep 2022 11:56:10 +0200 Subject: [PATCH] Handle StorageLive --- compiler/rustc_mir_dataflow/src/value_analysis.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 80d343e2b53..bdcb18f93b9 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -83,20 +83,21 @@ fn super_statement(&self, statement: &Statement<'tcx>, state: &mut State { // Could treat this as writing a constant to a pseudo-place. + // But discriminants are currently not tracked, so we do nothing. + // Related: https://github.com/rust-lang/unsafe-code-guidelines/issues/84 } StatementKind::CopyNonOverlapping(..) => { // FIXME: What to do here? } - StatementKind::StorageDead(local) => { - // It is UB to access an unallocated local. + StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { + // It is UB to read from an unitialized or unallocated local. state.flood(Place::from(*local).as_ref(), self.map()); } StatementKind::Deinit(box place) => { - // It is UB to access `uninit` bytes. + // It is UB to read `uninit` bytes. state.flood(place.as_ref(), self.map()); } StatementKind::Nop - | StatementKind::StorageLive(..) | StatementKind::Retag(..) | StatementKind::FakeRead(..) | StatementKind::Coverage(..)