remove unnecessary condition
`_local` isn't visited in `_local = <rhs>` statements in the situation we care about
This commit is contained in:
parent
1b7b33e513
commit
47f8bacc46
|
@ -461,12 +461,10 @@ impl Visitor<'tcx> for UsedLocals<'tcx> {
|
||||||
|
|
||||||
fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _location: Location) {
|
fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _location: Location) {
|
||||||
debug!("local: {:?} is_static: {:?}, ctx: {:?}", local, self.is_static, ctx);
|
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.
|
// Do not count _0 as a used in `return;` if it is a ZST.
|
||||||
let return_place = *local == RETURN_PLACE
|
let return_place = *local == RETURN_PLACE
|
||||||
&& matches!(ctx, PlaceContext::NonMutatingUse(visit::NonMutatingUseContext::Move));
|
&& 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 ty = self.local_decls[*local].ty;
|
||||||
let param_env_and = self.param_env.and(ty);
|
let param_env_and = self.param_env.and(ty);
|
||||||
if let Ok(layout) = self.tcx.layout_of(param_env_and) {
|
if let Ok(layout) = self.tcx.layout_of(param_env_and) {
|
||||||
|
|
Loading…
Reference in a new issue