diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-09-07 20:02:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-07 20:02:29 +0200 |
| commit | 36557d1046da672559bda949afa8256add67058b (patch) | |
| tree | 7f3e8d7312d46ebf6d9e96ebd3d5d808edee99f3 /compiler/rustc_mir_transform/src | |
| parent | e4e4829579440fc6739ee027eb0fe0a308675137 (diff) | |
| parent | 4e7a068c9a155807b40a592a092d8bc77d33d47c (diff) | |
| download | rust-36557d1046da672559bda949afa8256add67058b.tar.gz rust-36557d1046da672559bda949afa8256add67058b.zip | |
Rollup merge of #146297 - cjgillot:may-observe-address, r=saethlin
Introduce PlaceContext::may_observe_address. A small utility method to avoid open-coding the logic in several MIR opts.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/ssa.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index cd9a7f4a39d..73c249a3c8c 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -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; } |
