|
1 | 1 | use std::borrow::Cow; |
| 2 | +use std::cell::RefCell; |
2 | 3 |
|
3 | 4 | use rustc_index::bit_set::DenseBitSet; |
4 | 5 | use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor}; |
@@ -115,12 +116,12 @@ type BorrowedLocalsResults<'mir, 'tcx> = ResultsCursor<'mir, 'tcx, MaybeBorrowed |
115 | 116 | /// Dataflow analysis that determines whether each local requires storage at a |
116 | 117 | /// given location; i.e. whether its storage can go away without being observed. |
117 | 118 | pub struct MaybeRequiresStorage<'mir, 'tcx> { |
118 | | - borrowed_locals: BorrowedLocalsResults<'mir, 'tcx>, |
| 119 | + borrowed_locals: RefCell<BorrowedLocalsResults<'mir, 'tcx>>, |
119 | 120 | } |
120 | 121 |
|
121 | 122 | impl<'mir, 'tcx> MaybeRequiresStorage<'mir, 'tcx> { |
122 | 123 | pub fn new(borrowed_locals: BorrowedLocalsResults<'mir, 'tcx>) -> Self { |
123 | | - MaybeRequiresStorage { borrowed_locals } |
| 124 | + MaybeRequiresStorage { borrowed_locals: RefCell::new(borrowed_locals) } |
124 | 125 | } |
125 | 126 | } |
126 | 127 |
|
@@ -294,9 +295,10 @@ impl<'tcx> Analysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> { |
294 | 295 |
|
295 | 296 | impl<'tcx> MaybeRequiresStorage<'_, 'tcx> { |
296 | 297 | /// Kill locals that are fully moved and have not been borrowed. |
297 | | - fn check_for_move(&mut self, state: &mut <Self as Analysis<'tcx>>::Domain, loc: Location) { |
298 | | - let body = self.borrowed_locals.body(); |
299 | | - let mut visitor = MoveVisitor { state, borrowed_locals: &mut self.borrowed_locals }; |
| 298 | + fn check_for_move(&self, state: &mut <Self as Analysis<'tcx>>::Domain, loc: Location) { |
| 299 | + let mut borrowed_locals = self.borrowed_locals.borrow_mut(); |
| 300 | + let body = borrowed_locals.body(); |
| 301 | + let mut visitor = MoveVisitor { state, borrowed_locals: &mut borrowed_locals }; |
300 | 302 | visitor.visit_location(body, loc); |
301 | 303 | } |
302 | 304 | } |
|
0 commit comments