forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#7462 - xFrednet:7369-branches-sharing-code-el…
…se-expr-fp, r=camsteffen FP fix and documentation for `branches_sharing_code` lint Closes rust-lang/rust-clippy#7369 Related rust-lang/rust-clippy#7452 I'm still thinking about the best way to fix this. I could simply add another visitor to ensure that the moved expressions don't modify values being used in the condition, but I'm not totally happy with this due to the complexity. I therefore only documented it for now changelog: [`branches_sharing_code`] fixed false positive where block expressions would sometimes be ignored.
- Loading branch information
Showing
2 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![allow(dead_code)] | ||
#![deny(clippy::if_same_then_else, clippy::branches_sharing_code)] | ||
|
||
// ################################## | ||
// # Issue clippy#7369 | ||
// ################################## | ||
#[derive(Debug)] | ||
pub struct FooBar { | ||
foo: Vec<u32>, | ||
} | ||
|
||
impl FooBar { | ||
pub fn bar(&mut self) { | ||
if true { | ||
self.foo.pop(); | ||
} else { | ||
self.baz(); | ||
|
||
self.foo.pop(); | ||
|
||
self.baz() | ||
} | ||
} | ||
|
||
fn baz(&mut self) {} | ||
} | ||
|
||
fn main() {} |