1
Fork 0

cleanup mir visitor for rustc::pass_by_value

This commit is contained in:
lcnr 2022-07-01 16:21:21 +02:00
parent 7e2733bb1d
commit cf9c0a5935
23 changed files with 193 additions and 150 deletions

View file

@ -81,7 +81,7 @@ where
// deinitialized, although clearly it is only partially deinitialized. This analysis is not
// actually used anywhere at the moment, so this is not critical, but this does need to be fixed
// before it starts being used again.
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, NonUseContext};
match context {
// These are handled specially in `call_return_effect` and `yield_resume_effect`.

View file

@ -111,7 +111,7 @@ where
}
}
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
// Because we do not call `super_place` above, `visit_local` is only called for locals that
// do not appear as part of a `Place` in the MIR. This handles cases like the implicit use
// of the return place in a `Return` terminator or the index in an `Index` projection.

View file

@ -288,12 +288,12 @@ impl<'a, 'mir, 'tcx, T> Visitor<'tcx> for MoveVisitor<'a, 'mir, 'tcx, T>
where
T: GenKill<Local>,
{
fn visit_local(&mut self, local: &Local, context: PlaceContext, loc: Location) {
fn visit_local(&mut self, local: Local, context: PlaceContext, loc: Location) {
if PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) == context {
let mut borrowed_locals = self.borrowed_locals.borrow_mut();
borrowed_locals.seek_before_primary_effect(loc);
if !borrowed_locals.contains(*local) {
self.trans.kill(*local);
if !borrowed_locals.contains(local) {
self.trans.kill(local);
}
}
}