Can only const prop temporaries
Variables might error in branches that are not reachable due to the variable value.
This commit is contained in:
parent
05a03d7537
commit
dde68dcfe5
1 changed files with 6 additions and 1 deletions
|
@ -286,7 +286,12 @@ impl CanConstProp {
|
|||
found_assignment: IndexVec::from_elem(false, &mir.local_decls),
|
||||
};
|
||||
for (local, val) in cpv.can_const_prop.iter_enumerated_mut() {
|
||||
*val = mir.local_kind(local) != LocalKind::Arg;
|
||||
// cannot use args at all
|
||||
// cannot use locals because if x < y { y - x } else { x - y } would
|
||||
// lint for x != y
|
||||
// FIXME(oli-obk): lint variables until they are used in a condition
|
||||
// FIXME(oli-obk): lint if return value is constant
|
||||
*val = mir.local_kind(local) == LocalKind::Temp;
|
||||
}
|
||||
cpv.visit_mir(mir);
|
||||
cpv.can_const_prop
|
||||
|
|
Loading…
Add table
Reference in a new issue