Skip to content

Commit 23b1917

Browse files
committed
Rust: Add tests for parameter in source model
1 parent 05d5c1d commit 23b1917

File tree

3 files changed

+192
-164
lines changed

3 files changed

+192
-164
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,33 @@ fn test_enum_method_source() {
249249
}
250250
}
251251

252+
mod source_into_function {
253+
use super::sink;
254+
255+
// has a source model
256+
fn pass_source<A>(_i: i64, f: impl FnOnce(i64) -> A) -> A {
257+
f(42)
258+
}
259+
260+
fn test_source_into_function() {
261+
let a = |a| sink(a); // $ MISSING: hasValueFlow=1
262+
pass_source(1, a);
263+
264+
pass_source(2, |a| {
265+
sink(a); // $ MISSING: hasValueFlow=2
266+
});
267+
268+
fn f(a: i64) {
269+
sink(a) // $ MISSING: hasValueFlow=3
270+
}
271+
pass_source(3, f);
272+
273+
pass_source(4, async move |a| {
274+
sink(a); // $ MISSING: hasValueFlow=4
275+
});
276+
}
277+
}
278+
252279
// has a sink model
253280
fn enum_sink(e: MyFieldEnum) {}
254281

0 commit comments

Comments
 (0)