Skip to content

Commit 813c413

Browse files
committed
A few tests for infinite loops
1 parent a0a230d commit 813c413

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// error-pattern:some control paths may return
2+
/* Make sure a loop{} with a break in it can't be
3+
the tailexpr in the body of a diverging function */
4+
fn forever() -> ! {
5+
loop {
6+
break;
7+
}
8+
ret 42;
9+
}
10+
11+
fn main() {
12+
if (1 == 2) { forever(); }
13+
}

src/test/run-pass/loop-diverges.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Make sure a loop{} can be the tailexpr in the body
2+
of a diverging function */
3+
4+
fn forever() -> ! {
5+
loop{}
6+
}
7+
8+
fn main() {
9+
if (1 == 2) { forever(); }
10+
}

0 commit comments

Comments
 (0)