summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/never_loop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/never_loop.rs')
-rw-r--r--src/tools/clippy/tests/ui/never_loop.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/never_loop.rs b/src/tools/clippy/tests/ui/never_loop.rs
index 0a21589dd..3dbef1989 100644
--- a/src/tools/clippy/tests/ui/never_loop.rs
+++ b/src/tools/clippy/tests/ui/never_loop.rs
@@ -203,6 +203,32 @@ pub fn test17() {
};
}
+// Issue #9356: `continue` in else branch of let..else
+pub fn test18() {
+ let x = Some(0);
+ let y = 0;
+ // might loop
+ let _ = loop {
+ let Some(x) = x else {
+ if y > 0 {
+ continue;
+ } else {
+ return;
+ }
+ };
+
+ break x;
+ };
+ // never loops
+ let _ = loop {
+ let Some(x) = x else {
+ return;
+ };
+
+ break x;
+ };
+}
+
fn main() {
test1();
test2();