Skip to content

Commit 665da39

Browse files
committed
Rust: Add CFG test for nested function
1 parent d0f73ac commit 665da39

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

rust/ql/test/library-tests/controlflow/Cfg.expected

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,26 @@ edges
565565
| test.rs:299:13:299:27 | ExprStmt | test.rs:299:26:299:26 | 1 | |
566566
| test.rs:299:26:299:26 | 1 | test.rs:299:13:299:26 | BreakExpr | |
567567
| test.rs:301:9:301:9 | x | test.rs:296:18:302:5 | BlockExpr | |
568+
| test.rs:305:1:311:1 | enter test_nested_function | test.rs:306:5:306:18 | LetStmt | |
569+
| test.rs:305:1:311:1 | exit test_nested_function (normal) | test.rs:305:1:311:1 | exit test_nested_function | |
570+
| test.rs:305:27:311:1 | BlockExpr | test.rs:305:1:311:1 | exit test_nested_function (normal) | |
571+
| test.rs:306:5:306:18 | LetStmt | test.rs:306:17:306:17 | 0 | |
572+
| test.rs:306:9:306:13 | x | test.rs:307:5:309:5 | nested | match, no-match |
573+
| test.rs:306:17:306:17 | 0 | test.rs:306:9:306:13 | x | |
574+
| test.rs:307:5:309:5 | enter nested | test.rs:308:9:308:16 | ExprStmt | |
575+
| test.rs:307:5:309:5 | exit nested (normal) | test.rs:307:5:309:5 | exit nested | |
576+
| test.rs:307:5:309:5 | nested | test.rs:310:5:310:19 | ExprStmt | |
577+
| test.rs:307:29:309:5 | BlockExpr | test.rs:307:5:309:5 | exit nested (normal) | |
578+
| test.rs:308:9:308:10 | * ... | test.rs:308:15:308:15 | 1 | |
579+
| test.rs:308:9:308:15 | ... += ... | test.rs:307:29:309:5 | BlockExpr | |
580+
| test.rs:308:9:308:16 | ExprStmt | test.rs:308:10:308:10 | x | |
581+
| test.rs:308:10:308:10 | x | test.rs:308:9:308:10 | * ... | |
582+
| test.rs:308:15:308:15 | 1 | test.rs:308:9:308:15 | ... += ... | |
583+
| test.rs:310:5:310:10 | PathExpr | test.rs:310:17:310:17 | x | |
584+
| test.rs:310:5:310:18 | CallExpr | test.rs:305:27:311:1 | BlockExpr | |
585+
| test.rs:310:5:310:19 | ExprStmt | test.rs:310:5:310:10 | PathExpr | |
586+
| test.rs:310:12:310:17 | RefExpr | test.rs:310:5:310:18 | CallExpr | |
587+
| test.rs:310:17:310:17 | x | test.rs:310:12:310:17 | RefExpr | |
568588
breakTarget
569589
| test.rs:16:17:16:21 | BreakExpr | test.rs:10:9:22:9 | LoopExpr |
570590
| test.rs:30:21:30:25 | BreakExpr | test.rs:28:13:35:13 | LoopExpr |

rust/ql/test/library-tests/controlflow/test.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,11 @@ fn labelled_block2() -> i64 {
301301
x
302302
};
303303
}
304+
305+
fn test_nested_function() {
306+
let mut x = 0;
307+
fn nested(x : &mut i64) {
308+
*x += 1;
309+
}
310+
nested(&mut x);
311+
}

0 commit comments

Comments
 (0)