From 47f8bacc469a6d90ace323eb482f273988674dd1 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sun, 14 Mar 2021 20:21:20 -0400 Subject: [PATCH] remove unnecessary condition `_local` isn't visited in `_local = ` statements in the situation we care about --- compiler/rustc_mir/src/transform/simplify.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_mir/src/transform/simplify.rs b/compiler/rustc_mir/src/transform/simplify.rs index 7ca3191121e..d2314a9ba15 100644 --- a/compiler/rustc_mir/src/transform/simplify.rs +++ b/compiler/rustc_mir/src/transform/simplify.rs @@ -461,12 +461,10 @@ impl Visitor<'tcx> for UsedLocals<'tcx> { fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _location: Location) { debug!("local: {:?} is_static: {:?}, ctx: {:?}", local, self.is_static, ctx); - // Do not count a local as used in `_local = ` if RHS is a ZST. - let store = matches!(ctx, PlaceContext::MutatingUse(MutatingUseContext::Store)); // Do not count _0 as a used in `return;` if it is a ZST. let return_place = *local == RETURN_PLACE && matches!(ctx, PlaceContext::NonMutatingUse(visit::NonMutatingUseContext::Move)); - if !self.is_static && (store || return_place) { + if !self.is_static && return_place { let ty = self.local_decls[*local].ty; let param_env_and = self.param_env.and(ty); if let Ok(layout) = self.tcx.layout_of(param_env_and) {