Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
index ae8241ec2c..813c07a505 100644
--- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
+++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
@@ -387,4 +387,27 @@ fn test() {
"#,
);
}
+
+ #[test]
+ fn no_diagnostic_if_tail_exists_in_else_branch() {
+ check_diagnostics_with_needless_return_disabled(
+ r#"
+fn test1(a: bool) {
+ let _x = if a {
+ return;
+ } else {
+ 1
+ };
+}
+
+fn test2(a: bool) -> i32 {
+ if a {
+ return 1;
+ } else {
+ 0
+ }
+}
+"#,
+ );
+ }
}