Skip to content

Commit 7a6ab70

Browse files
committed
Rust: Add test for free function with context-based typing
1 parent 7094fb0 commit 7a6ab70

File tree

3 files changed

+376
-360
lines changed

3 files changed

+376
-360
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
multipleResolvedTargets
22
| main.rs:2223:9:2223:31 | ... .my_add(...) |
33
| main.rs:2225:9:2225:29 | ... .my_add(...) |
4-
| main.rs:2733:13:2733:17 | x.f() |
4+
| main.rs:2740:13:2740:17 | x.f() |

rust/ql/test/library-tests/type-inference/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,10 @@ mod context_typed {
26432643
fn f(self) {}
26442644
}
26452645

2646+
fn free_function<T: Default>() -> T {
2647+
Default::default() // $ target=default
2648+
}
2649+
26462650
pub fn f() {
26472651
let x = None; // $ type=x:T.i32
26482652
let x: Option<i32> = x;
@@ -2693,6 +2697,9 @@ mod context_typed {
26932697

26942698
let s = Default::default(); // $ target=default type=s:S
26952699
S::f(s); // $ target=f
2700+
2701+
let z = free_function(); // $ target=free_function MISSING: type=z:i32
2702+
x.push(z); // $ target=push
26962703
}
26972704
}
26982705

0 commit comments

Comments
 (0)