Skip to content

Commit d37787c

Browse files
committed
Rust: Add type inference tests for literals
1 parent 3fc9da7 commit d37787c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,20 @@ mod try_expressions {
978978
}
979979
}
980980

981+
mod builtins {
982+
pub fn f() {
983+
let x: i32 = 1; // $ MISSING: type=x:i32
984+
let y = 2; // $ MISSING: type=y:i32
985+
let z = x + y; // $ MISSING: type=z:i32
986+
let z = x.abs(); // $ MISSING: method=abs $ MISSING: type=z:i32
987+
'c';
988+
"Hello";
989+
123.0f64;
990+
true;
991+
false;
992+
}
993+
}
994+
981995
fn main() {
982996
field_access::f();
983997
method_impl::f();
@@ -995,4 +1009,5 @@ fn main() {
9951009
implicit_self_borrow::f();
9961010
borrowed_typed::f();
9971011
try_expressions::f();
1012+
builtins::f();
9981013
}

rust/ql/test/library-tests/type-inference/type-inference.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ inferType
10941094
| main.rs:975:49:975:62 | ...::Ok(...) | E | main.rs:925:5:926:14 | S1 |
10951095
| main.rs:975:49:975:62 | ...::Ok(...) | T | main.rs:925:5:926:14 | S1 |
10961096
| main.rs:975:60:975:61 | S1 | | main.rs:925:5:926:14 | S1 |
1097-
| main.rs:983:5:983:20 | ...::f(...) | | main.rs:67:5:67:21 | Foo |
1098-
| main.rs:984:5:984:60 | ...::g(...) | | main.rs:67:5:67:21 | Foo |
1099-
| main.rs:984:20:984:38 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |
1100-
| main.rs:984:41:984:59 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |
1097+
| main.rs:997:5:997:20 | ...::f(...) | | main.rs:67:5:67:21 | Foo |
1098+
| main.rs:998:5:998:60 | ...::g(...) | | main.rs:67:5:67:21 | Foo |
1099+
| main.rs:998:20:998:38 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |
1100+
| main.rs:998:41:998:59 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |

0 commit comments

Comments
 (0)