Skip to content

Commit b408228

Browse files
committed
Change comment to reflect switch to THIR unsafeck
1 parent 5877182 commit b408228

File tree

1 file changed

+10
-14
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+10
-14
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -1258,21 +1258,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
12581258
// cases.
12591259
let source_info = self.source_info(scrutinee_span);
12601260

1261-
// Matching on a `scrutinee_place` with an uninhabited type doesn't
1262-
// generate any memory reads by itself, and so if the place "expression"
1263-
// contains unsafe operations like raw pointer dereferences or union
1264-
// field projections, we wouldn't know to require an `unsafe` block
1265-
// around a `match` equivalent to `std::intrinsics::unreachable()`.
1266-
// See issue #47412 for this hole being discovered in the wild.
1267-
//
1268-
// HACK(eddyb) Work around the above issue by adding a dummy inspection
1269-
// of `scrutinee_place`, specifically by applying `ReadForMatch`.
1261+
// Matching on a scrutinee place of an uninhabited type doesn't generate any memory
1262+
// reads by itself, and so if the place is uninitialized we wouldn't know. In order to
1263+
// disallow the following:
1264+
// ```rust
1265+
// let x: !;
1266+
// match x {}
1267+
// ```
1268+
// we add a dummy read on the place.
12701269
//
1271-
// NOTE: ReadForMatch also checks that the scrutinee is initialized.
1272-
// This is currently needed to not allow matching on an uninitialized,
1273-
// uninhabited value. If we get never patterns, those will check that
1274-
// the place is initialized, and so this read would only be used to
1275-
// check safety.
1270+
// NOTE: If we require never patterns for empty matches, those will check that the place
1271+
// is initialized, and so this read would no longer be needed.
12761272
let cause_matched_place = FakeReadCause::ForMatchedPlace(None);
12771273

12781274
if let Some(scrutinee_place) = scrutinee_place_builder.try_to_place(self) {

0 commit comments

Comments
 (0)