Skip to content

Commit b6103e1

Browse files
committed
Rust: Add CFG test for early return in async block
Also made the test comply with `cargo check`.
1 parent ef9f383 commit b6103e1

File tree

6 files changed

+1176
-1063
lines changed

6 files changed

+1176
-1063
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
edges
2+
| test.rs:5:5:11:5 | enter test_and_if_let | test.rs:5:24:5:24 | a | |
3+
| test.rs:5:5:11:5 | exit test_and_if_let (normal) | test.rs:5:5:11:5 | exit test_and_if_let | |
4+
| test.rs:5:24:5:24 | a | test.rs:5:24:5:30 | Param | match |
5+
| test.rs:5:24:5:30 | Param | test.rs:5:33:5:33 | b | |
6+
| test.rs:5:33:5:33 | b | test.rs:5:33:5:47 | Param | match |
7+
| test.rs:5:33:5:47 | Param | test.rs:5:50:5:50 | c | |
8+
| test.rs:5:50:5:50 | c | test.rs:5:50:5:56 | Param | match |
9+
| test.rs:5:50:5:56 | Param | test.rs:6:12:6:12 | a | |
10+
| test.rs:5:67:11:5 | BlockExpr | test.rs:5:5:11:5 | exit test_and_if_let (normal) | |
11+
| test.rs:6:9:10:9 | IfExpr | test.rs:5:67:11:5 | BlockExpr | |
12+
| test.rs:6:12:6:12 | a | test.rs:6:12:6:31 | [boolean(false)] ... && ... | false |
13+
| test.rs:6:12:6:12 | a | test.rs:6:17:6:31 | LetExpr | true |
14+
| test.rs:6:12:6:31 | [boolean(false)] ... && ... | test.rs:9:13:9:17 | false | false |
15+
| test.rs:6:12:6:31 | [boolean(true)] ... && ... | test.rs:7:13:7:13 | d | true |
16+
| test.rs:6:17:6:31 | LetExpr | test.rs:6:31:6:31 | b | |
17+
| test.rs:6:21:6:27 | TupleStructPat | test.rs:6:12:6:31 | [boolean(false)] ... && ... | no-match |
18+
| test.rs:6:21:6:27 | TupleStructPat | test.rs:6:26:6:26 | d | match |
19+
| test.rs:6:26:6:26 | d | test.rs:6:12:6:31 | [boolean(true)] ... && ... | match |
20+
| test.rs:6:31:6:31 | b | test.rs:6:21:6:27 | TupleStructPat | |
21+
| test.rs:6:33:8:9 | BlockExpr | test.rs:6:9:10:9 | IfExpr | |
22+
| test.rs:7:13:7:13 | d | test.rs:6:33:8:9 | BlockExpr | |
23+
| test.rs:8:16:10:9 | BlockExpr | test.rs:6:9:10:9 | IfExpr | |
24+
| test.rs:9:13:9:17 | false | test.rs:8:16:10:9 | BlockExpr | |
25+
| test.rs:13:5:21:5 | enter test_and_if_let2 | test.rs:13:25:13:25 | a | |
26+
| test.rs:13:5:21:5 | exit test_and_if_let2 (normal) | test.rs:13:5:21:5 | exit test_and_if_let2 | |
27+
| test.rs:13:25:13:25 | a | test.rs:13:25:13:31 | Param | match |
28+
| test.rs:13:25:13:31 | Param | test.rs:13:34:13:34 | b | |
29+
| test.rs:13:34:13:34 | b | test.rs:13:34:13:39 | Param | match |
30+
| test.rs:13:34:13:39 | Param | test.rs:13:42:13:42 | c | |
31+
| test.rs:13:42:13:42 | c | test.rs:13:42:13:48 | Param | match |
32+
| test.rs:13:42:13:48 | Param | test.rs:14:12:14:12 | a | |
33+
| test.rs:13:59:21:5 | BlockExpr | test.rs:13:5:21:5 | exit test_and_if_let2 (normal) | |
34+
| test.rs:14:9:20:9 | IfExpr | test.rs:13:59:21:5 | BlockExpr | |
35+
| test.rs:14:12:14:12 | a | test.rs:14:12:14:25 | [boolean(false)] ... && ... | false |
36+
| test.rs:14:12:14:12 | a | test.rs:14:17:14:25 | LetExpr | true |
37+
| test.rs:14:12:14:25 | [boolean(false)] ... && ... | test.rs:14:12:15:16 | [boolean(false)] ... && ... | false |
38+
| test.rs:14:12:14:25 | [boolean(true)] ... && ... | test.rs:15:16:15:16 | c | true |
39+
| test.rs:14:12:15:16 | [boolean(false)] ... && ... | test.rs:19:13:19:17 | false | false |
40+
| test.rs:14:12:15:16 | [boolean(true)] ... && ... | test.rs:17:13:17:13 | d | true |
41+
| test.rs:14:17:14:25 | LetExpr | test.rs:14:25:14:25 | b | |
42+
| test.rs:14:21:14:21 | d | test.rs:14:12:14:25 | [boolean(true)] ... && ... | match |
43+
| test.rs:14:25:14:25 | b | test.rs:14:21:14:21 | d | |
44+
| test.rs:15:16:15:16 | c | test.rs:14:12:15:16 | [boolean(false)] ... && ... | false |
45+
| test.rs:15:16:15:16 | c | test.rs:14:12:15:16 | [boolean(true)] ... && ... | true |
46+
| test.rs:16:9:18:9 | BlockExpr | test.rs:14:9:20:9 | IfExpr | |
47+
| test.rs:17:13:17:13 | d | test.rs:17:17:17:17 | 0 | |
48+
| test.rs:17:13:17:17 | ... > ... | test.rs:16:9:18:9 | BlockExpr | |
49+
| test.rs:17:17:17:17 | 0 | test.rs:17:13:17:17 | ... > ... | |
50+
| test.rs:18:16:20:9 | BlockExpr | test.rs:14:9:20:9 | IfExpr | |
51+
| test.rs:19:13:19:17 | false | test.rs:18:16:20:9 | BlockExpr | |
52+
breakTarget
53+
continueTarget
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
query: utils/Cfg.ql
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// TODO: Move these tests into `controlflow` when they become stable features
2+
3+
mod if_expression {
4+
5+
fn test_and_if_let(a: bool, b: Option<bool>, c: bool) -> bool {
6+
if a && let Some(d) = b {
7+
d
8+
} else {
9+
false
10+
}
11+
}
12+
13+
fn test_and_if_let2(a: bool, b: i64, c: bool) -> bool {
14+
if a && let d = b
15+
&& c
16+
{
17+
d > 0
18+
} else {
19+
false
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)