Introduce PlaceContext::may_observe_address.

This commit is contained in:
Camille GILLOT
2025-06-23 16:05:09 +00:00
committed by Camille Gillot
parent bea625f327
commit 4e7a068c9a
3 changed files with 23 additions and 8 deletions

View File

@@ -225,6 +225,9 @@ impl SsaVisitor<'_, '_> {
impl<'tcx> Visitor<'tcx> for SsaVisitor<'_, 'tcx> {
fn visit_local(&mut self, local: Local, ctxt: PlaceContext, loc: Location) {
if ctxt.may_observe_address() {
self.borrowed_locals.insert(local);
}
match ctxt {
PlaceContext::MutatingUse(MutatingUseContext::Projection)
| PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => bug!(),
@@ -237,7 +240,6 @@ impl<'tcx> Visitor<'tcx> for SsaVisitor<'_, 'tcx> {
PlaceContext::NonMutatingUse(
NonMutatingUseContext::SharedBorrow | NonMutatingUseContext::FakeBorrow,
) => {
self.borrowed_locals.insert(local);
self.check_dominates(local, loc);
self.direct_uses[local] += 1;
}