Visit place in BackwardIncompatibleDropHint statement
This commit is contained in:
parent
51548ce71f
commit
2f96e784e2
8 changed files with 19 additions and 25 deletions
|
@ -77,6 +77,9 @@ pub(crate) fn categorize(context: PlaceContext) -> Option<DefUse> {
|
||||||
// Debug info is neither def nor use.
|
// Debug info is neither def nor use.
|
||||||
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,
|
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,
|
||||||
|
|
||||||
|
// Backwards incompatible drop hint is not a use, just a marker for linting.
|
||||||
|
PlaceContext::NonUse(NonUseContext::BackwardIncompatibleDropHint) => None,
|
||||||
|
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Deinit | MutatingUseContext::SetDiscriminant) => {
|
PlaceContext::MutatingUse(MutatingUseContext::Deinit | MutatingUseContext::SetDiscriminant) => {
|
||||||
bug!("These statements are not allowed in this MIR phase")
|
bug!("These statements are not allowed in this MIR phase")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1301,7 +1301,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
||||||
error_reported
|
error_reported
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Through #123739, backward incompatible drops (BIDs) are introduced.
|
/// Through #123739, `BackwardIncompatibleDropHint`s (BIDs) are introduced.
|
||||||
/// We would like to emit lints whether borrow checking fails at these future drop locations.
|
/// We would like to emit lints whether borrow checking fails at these future drop locations.
|
||||||
#[instrument(level = "debug", skip(self, state))]
|
#[instrument(level = "debug", skip(self, state))]
|
||||||
fn check_backward_incompatible_drop(
|
fn check_backward_incompatible_drop(
|
||||||
|
|
|
@ -859,7 +859,7 @@ impl Debug for Statement<'_> {
|
||||||
BackwardIncompatibleDropHint { ref place, reason: _ } => {
|
BackwardIncompatibleDropHint { ref place, reason: _ } => {
|
||||||
// For now, we don't record the reason because there is only one use case,
|
// For now, we don't record the reason because there is only one use case,
|
||||||
// which is to report breaking change in drop order by Edition 2024
|
// which is to report breaking change in drop order by Edition 2024
|
||||||
write!(fmt, "backward incompatible drop({place:?})")
|
write!(fmt, "BackwardIncompatibleDropHint({place:?})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,9 +457,15 @@ macro_rules! make_mir_visitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
StatementKind::BackwardIncompatibleDropHint { place, .. } => {
|
||||||
|
self.visit_place(
|
||||||
|
place,
|
||||||
|
PlaceContext::NonUse(NonUseContext::BackwardIncompatibleDropHint),
|
||||||
|
location
|
||||||
|
);
|
||||||
|
}
|
||||||
StatementKind::ConstEvalCounter => {}
|
StatementKind::ConstEvalCounter => {}
|
||||||
StatementKind::Nop => {}
|
StatementKind::Nop => {}
|
||||||
StatementKind::BackwardIncompatibleDropHint { .. } => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1348,6 +1354,8 @@ pub enum NonUseContext {
|
||||||
AscribeUserTy(ty::Variance),
|
AscribeUserTy(ty::Variance),
|
||||||
/// The data of a user variable, for debug info.
|
/// The data of a user variable, for debug info.
|
||||||
VarDebugInfo,
|
VarDebugInfo,
|
||||||
|
/// A `BackwardIncompatibleDropHint` statement, meant for edition 2024 lints.
|
||||||
|
BackwardIncompatibleDropHint,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
|
@ -1422,7 +1430,9 @@ impl PlaceContext {
|
||||||
use NonUseContext::*;
|
use NonUseContext::*;
|
||||||
match self {
|
match self {
|
||||||
PlaceContext::MutatingUse(_) => ty::Invariant,
|
PlaceContext::MutatingUse(_) => ty::Invariant,
|
||||||
PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant,
|
PlaceContext::NonUse(
|
||||||
|
StorageDead | StorageLive | VarDebugInfo | BackwardIncompatibleDropHint,
|
||||||
|
) => ty::Invariant,
|
||||||
PlaceContext::NonMutatingUse(
|
PlaceContext::NonMutatingUse(
|
||||||
Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | RawBorrow
|
Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | RawBorrow
|
||||||
| Projection,
|
| Projection,
|
||||||
|
|
|
@ -35,7 +35,8 @@ impl<'tcx> crate::MirPass<'tcx> for CleanupPostBorrowck {
|
||||||
// MIR building, and are not needed after InstrumentCoverage.
|
// MIR building, and are not needed after InstrumentCoverage.
|
||||||
CoverageKind::BlockMarker { .. } | CoverageKind::SpanMarker { .. },
|
CoverageKind::BlockMarker { .. } | CoverageKind::SpanMarker { .. },
|
||||||
)
|
)
|
||||||
| StatementKind::FakeRead(..) => statement.make_nop(),
|
| StatementKind::FakeRead(..)
|
||||||
|
| StatementKind::BackwardIncompatibleDropHint { .. } => statement.make_nop(),
|
||||||
StatementKind::Assign(box (
|
StatementKind::Assign(box (
|
||||||
_,
|
_,
|
||||||
Rvalue::Cast(
|
Rvalue::Cast(
|
||||||
|
|
|
@ -597,20 +597,6 @@ impl<'tcx> MutVisitor<'tcx> for LocalUpdater<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement(&mut self, statement: &mut Statement<'tcx>, location: Location) {
|
|
||||||
if let StatementKind::BackwardIncompatibleDropHint { place, reason: _ } =
|
|
||||||
&mut statement.kind
|
|
||||||
{
|
|
||||||
self.visit_local(
|
|
||||||
&mut place.local,
|
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Store),
|
|
||||||
location,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
self.super_statement(statement, location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_local(&mut self, l: &mut Local, _: PlaceContext, _: Location) {
|
fn visit_local(&mut self, l: &mut Local, _: PlaceContext, _: Location) {
|
||||||
*l = self.map[*l].unwrap();
|
*l = self.map[*l].unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,6 @@ fn method_1(_1: Guard) -> () {
|
||||||
}
|
}
|
||||||
|
|
||||||
bb7: {
|
bb7: {
|
||||||
backward incompatible drop(_2);
|
|
||||||
backward incompatible drop(_4);
|
|
||||||
backward incompatible drop(_5);
|
|
||||||
goto -> bb21;
|
goto -> bb21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,6 @@ fn method_1(_1: Guard) -> () {
|
||||||
}
|
}
|
||||||
|
|
||||||
bb7: {
|
bb7: {
|
||||||
backward incompatible drop(_2);
|
|
||||||
backward incompatible drop(_4);
|
|
||||||
backward incompatible drop(_5);
|
|
||||||
goto -> bb21;
|
goto -> bb21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue