remove unnecessary condition

`_local` isn't visited in `_local = <rhs>` statements in the situation
we care about
This commit is contained in:
Erik Desjardins 2021-03-14 20:21:20 -04:00
parent 1b7b33e513
commit 47f8bacc46
1 changed files with 1 additions and 3 deletions

View File

@ -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 = <rhs>` 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) {