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 d583342

Browse files
committedMar 10, 2023
Auto merge of #102256 - cjgillot:let-under, r=lcnr
Introduce a no-op `PlaceMention` statement for `let _ =`. Fixes #54003 Fixes #80059 Split from #101500 This PR introduces a new `PlaceMention` statement dedicated to matches that neither introduce bindings nor ascribe types. Without this, all traces of the match would vanish from MIR, making it impossible to diagnose unsafety or use in #101500. This allows to mark `let _ = <unsafe union access or dereference>` as requiring an unsafe block. Nominating for lang team, as this introduces an extra error.
2 parents 104f430 + 684de04 commit d583342

Some content is hidden

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

48 files changed

+271
-19
lines changed
 

‎compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
390390
| mir::StatementKind::Deinit(..)
391391
| mir::StatementKind::StorageLive(..)
392392
| mir::StatementKind::Retag { .. }
393+
| mir::StatementKind::PlaceMention(..)
393394
| mir::StatementKind::AscribeUserType(..)
394395
| mir::StatementKind::Coverage(..)
395396
| mir::StatementKind::Intrinsic(..)

‎compiler/rustc_borrowck/src/def_use.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
7272
PlaceContext::MutatingUse(MutatingUseContext::Drop) =>
7373
Some(DefUse::Drop),
7474

75+
// This statement exists to help unsafeck. It does not require the place to be live.
76+
PlaceContext::NonUse(NonUseContext::PlaceMention) => None,
7577
// Debug info is neither def nor use.
7678
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,
7779

0 commit comments

Comments
 (0)
Please sign in to comment.