You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pubfndemo(net_loop_movement:i64) -> i64{if net_loop_movement == 0{0}elseif net_loop_movement < 0{// Net movement was negative, so conservatively assume// it was zero (e.g. the loop may run zero times).0}else{// Net loop movement was positive, so we can't// assume any bounds.1}}
I wouldn't expect if_same_then_else to fire in this case. I'm explicitly documenting why the second case is a fallback. This is a reduced reproduction from this original source code.
It produces the following message:
error: this `if` has identical blocks
--> src/bounds.rs:99:37
|
99 | } else if net_loop_movement < 0 {
| _____________________________________^
100 | | // Net movement was negative, so conservatively assume
101 | | // it was zero (e.g. the loop may run zero times).
102 | | 0
103 | | } else {
| |_____^
|
= note: `#[deny(clippy::if_same_then_else)]` on by default
note: same as this
--> src/bounds.rs:97:31
|
97 | if net_loop_movement == 0 {
| _______________________________^
98 | | 0
99 | | } else if net_loop_movement < 0 {
| |_____^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
Could the check be more conservative? Perhaps not firing if there's an additional else later, or considering blocks to be different based on trivia like comments?
I tried this code:
I wouldn't expect if_same_then_else to fire in this case. I'm explicitly documenting why the second case is a fallback. This is a reduced reproduction from this original source code.
It produces the following message:
Could the check be more conservative? Perhaps not firing if there's an additional
else
later, or considering blocks to be different based on trivia like comments?Meta
cargo clippy -V
:clippy 0.0.212 (623fb90 2020-09-26)
rustc -Vv
:The text was updated successfully, but these errors were encountered: