if a && b {
return Some(10);
}
- if a {
- Some(20)
- } else {
- Some(30)
- }
+ if a { Some(20) } else { Some(30) }
}
// public fns should not be linted
pub fn func3(a: bool) -> Option<i32> {
- if a {
- Some(1)
- } else {
- Some(1)
- }
+ if a { Some(1) } else { Some(1) }
}
// should not be linted
fn func4(a: bool) -> Option<i32> {
- if a {
- Some(1)
- } else {
- None
- }
+ if a { Some(1) } else { None }
}
// should be linted
// should not be linted
fn func8(a: bool) -> Result<i32, ()> {
- if a {
- Ok(1)
- } else {
- Err(())
- }
+ if a { Ok(1) } else { Err(()) }
}
// should not be linted
})
}
+// should be linted
+fn issue_6640_1(a: bool, b: bool) -> Option<()> {
+ if a && b {
+ return Some(());
+ }
+ if a {
+ Some(());
+ Some(())
+ } else {
+ return Some(());
+ }
+}
+
+// should be linted
+fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
+ if a && b {
+ return Ok(());
+ }
+ if a {
+ Ok(())
+ } else {
+ return Ok(());
+ }
+}
+
+// should not be linted
+fn issue_6640_3() -> Option<()> {
+ if true { Some(()) } else { None }
+}
+
+// should not be linted
+fn issue_6640_4() -> Result<(), ()> {
+ if true { Ok(()) } else { Err(()) }
+}
+
fn main() {
// method calls are not linted
func1(true, true);
func2(true, true);
+ issue_6640_1(true, true);
+ issue_6640_2(true, true);
}