Visit place in BackwardIncompatibleDropHint statement

This commit is contained in:
Michael Goulet 2025-04-13 22:01:54 +00:00
parent 51548ce71f
commit 2f96e784e2
8 changed files with 19 additions and 25 deletions

View file

@ -859,7 +859,7 @@ impl Debug for Statement<'_> {
BackwardIncompatibleDropHint { ref place, reason: _ } => {
// 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
write!(fmt, "backward incompatible drop({place:?})")
write!(fmt, "BackwardIncompatibleDropHint({place:?})")
}
}
}

View file

@ -457,9 +457,15 @@ macro_rules! make_mir_visitor {
}
}
}
StatementKind::BackwardIncompatibleDropHint { place, .. } => {
self.visit_place(
place,
PlaceContext::NonUse(NonUseContext::BackwardIncompatibleDropHint),
location
);
}
StatementKind::ConstEvalCounter => {}
StatementKind::Nop => {}
StatementKind::BackwardIncompatibleDropHint { .. } => {}
}
}
@ -1348,6 +1354,8 @@ pub enum NonUseContext {
AscribeUserTy(ty::Variance),
/// The data of a user variable, for debug info.
VarDebugInfo,
/// A `BackwardIncompatibleDropHint` statement, meant for edition 2024 lints.
BackwardIncompatibleDropHint,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -1422,7 +1430,9 @@ impl PlaceContext {
use NonUseContext::*;
match self {
PlaceContext::MutatingUse(_) => ty::Invariant,
PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant,
PlaceContext::NonUse(
StorageDead | StorageLive | VarDebugInfo | BackwardIncompatibleDropHint,
) => ty::Invariant,
PlaceContext::NonMutatingUse(
Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | RawBorrow
| Projection,