diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2018-01-30 16:38:14 +0100 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2018-03-08 08:34:15 +0100 |
| commit | dde68dcfe536189ddde835299b59830d9f97b1f0 (patch) | |
| tree | 1939eaddc1f79c6c5e6c13bf88a4719c27fb6dd7 | |
| parent | 05a03d753796e5adf89a97222a1c085ad1cbb904 (diff) | |
| download | rust-dde68dcfe536189ddde835299b59830d9f97b1f0.tar.gz rust-dde68dcfe536189ddde835299b59830d9f97b1f0.zip | |
Can only const prop temporaries
Variables might error in branches that are not reachable due to the variable value.
| -rw-r--r-- | src/librustc_mir/transform/const_prop.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index fc2a149cfe9..09c72c4bf93 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -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 |
