Skip to content

Commit 9e9b988

Browse files
committed
Address more review comments
1 parent da57e1b commit 9e9b988

3 files changed

Lines changed: 1025 additions & 884 deletions

File tree

‎rust/ql/test/library-tests/type-inference/closure.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ mod simple_closures {
2828
let id2 = |b| b;
2929
let arg = Default::default(); // $ target=default type=arg:bool
3030
let _b2: bool = id2(arg); // $ certainType=_b2:bool
31+
32+
// The parameter type of `f1` is inferred from the argument.
33+
let f1 = |x| (x, false); // $ type=x@Option<T>:i32
34+
let _r = f1(Some(0)); // $ type=_r@(T_2)<T0>.Option<T>:i32
35+
36+
// The return type of `f2` is inferred from the type of the call expression.
37+
let f2 = |x| (x, false); // $ type=x@Option<T>:i32
38+
let _r: Option<i32> = f2(Default::default()).0; // $ fieldof=Tuple2 target=default
3139
}
3240
}
3341

0 commit comments

Comments
 (0)