Change comment to reflect switch to THIR unsafeck

This commit is contained in:
Nadrieril 2024-06-22 18:21:03 +02:00
parent ff49c3769b
commit beb1d35d7d

View File

@ -1258,21 +1258,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// cases. // cases.
let source_info = self.source_info(scrutinee_span); let source_info = self.source_info(scrutinee_span);
// Matching on a `scrutinee_place` with an uninhabited type doesn't // Matching on a scrutinee place of an uninhabited type doesn't generate any memory
// generate any memory reads by itself, and so if the place "expression" // reads by itself, and so if the place is uninitialized we wouldn't know. In order to
// contains unsafe operations like raw pointer dereferences or union // disallow the following:
// field projections, we wouldn't know to require an `unsafe` block // ```rust
// around a `match` equivalent to `std::intrinsics::unreachable()`. // let x: !;
// See issue #47412 for this hole being discovered in the wild. // match x {}
// ```
// we add a dummy read on the place.
// //
// HACK(eddyb) Work around the above issue by adding a dummy inspection // NOTE: If we require never patterns for empty matches, those will check that the place
// of `scrutinee_place`, specifically by applying `ReadForMatch`. // is initialized, and so this read would no longer be needed.
//
// NOTE: ReadForMatch also checks that the scrutinee is initialized.
// This is currently needed to not allow matching on an uninitialized,
// uninhabited value. If we get never patterns, those will check that
// the place is initialized, and so this read would only be used to
// check safety.
let cause_matched_place = FakeReadCause::ForMatchedPlace(None); let cause_matched_place = FakeReadCause::ForMatchedPlace(None);
if let Some(scrutinee_place) = scrutinee_place_builder.try_to_place(self) { if let Some(scrutinee_place) = scrutinee_place_builder.try_to_place(self) {