Skip to content

Commit 00e4f58

Browse files
committed
Rust: Add tests for chained let expressions
1 parent ff288d7 commit 00e4f58

19 files changed

+4925
-4506
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
deadEnd
2+
| main.rs:30:12:30:12 | x |
3+
| main.rs:255:17:255:17 | n |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
multipleCallTargets
2-
| main.rs:445:18:445:24 | n.len() |
2+
| main.rs:471:18:471:24 | n.len() |

rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected

Lines changed: 1094 additions & 1079 deletions
Large diffs are not rendered by default.

rust/ql/test/library-tests/dataflow/local/inline-flow.expected

Lines changed: 545 additions & 545 deletions
Large diffs are not rendered by default.

rust/ql/test/library-tests/dataflow/local/main.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(let_chains)]
12
// Tests for intraprocedural data flow.
23

34
fn source(i: i64) -> i64 {
@@ -21,6 +22,19 @@ fn direct() {
2122
fn variable_usage() {
2223
let s = source(2);
2324
sink(s); // $ hasValueFlow=2
25+
26+
if let x = s {
27+
sink(x); // $ MISSING: hasValueFlow=2
28+
};
29+
30+
if let x = s
31+
&& {
32+
sink(x); // $ MISSING: hasValueFlow=2
33+
true
34+
}
35+
{
36+
sink(x); // $ MISSING: hasValueFlow=2
37+
};
2438
}
2539

2640
fn if_expression(cond: bool) {
@@ -236,6 +250,18 @@ fn option_pattern_match_unqualified() {
236250
}
237251
}
238252

253+
fn option_chained_let() {
254+
let s1 = Some(source(45));
255+
if let Some(n) = s1
256+
&& {
257+
sink(n); // $ MISSING: hasValueFlow=45
258+
true
259+
}
260+
{
261+
sink(n); // $ MISSING: hasValueFlow=45
262+
}
263+
}
264+
239265
fn option_unwrap() {
240266
let s1 = Some(source(19));
241267
sink(s1.unwrap()); // $ hasValueFlow=19
@@ -558,6 +584,7 @@ fn main() {
558584
struct_nested_match();
559585
option_pattern_match_qualified();
560586
option_pattern_match_unqualified();
587+
option_chained_let();
561588
option_unwrap();
562589
option_unwrap_or();
563590
option_questionmark();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
qltest_use_nightly: true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
deadEnd
2+
| main.rs:280:17:280:17 | x |
3+
| main.rs:296:17:296:17 | x |
4+
| main.rs:315:20:315:20 | x |
5+
| main.rs:335:20:335:20 | x |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
multipleCallTargets
2-
| main.rs:87:19:87:40 | ...::from(...) |
3-
| main.rs:106:19:106:40 | ...::from(...) |
2+
| main.rs:89:19:89:40 | ...::from(...) |
3+
| main.rs:111:19:111:40 | ...::from(...) |

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

Lines changed: 1753 additions & 1625 deletions
Large diffs are not rendered by default.

rust/ql/test/library-tests/variables/Ssa.expected

Lines changed: 702 additions & 657 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)