Skip to content

Commit 72e305c

Browse files
committed
Rust: Add more type inference tests
1 parent 7d5664f commit 72e305c

File tree

3 files changed

+4169
-4129
lines changed

3 files changed

+4169
-4129
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ multipleCallTargets
99
| main.rs:590:9:590:18 | ...::m(...) |
1010
| main.rs:591:9:591:20 | ... .m() |
1111
| main.rs:592:9:592:24 | ...::m(...) |
12-
| main.rs:2524:13:2524:31 | ...::from(...) |
13-
| main.rs:2525:13:2525:31 | ...::from(...) |
14-
| main.rs:2526:13:2526:31 | ...::from(...) |
15-
| main.rs:2532:13:2532:31 | ...::from(...) |
16-
| main.rs:2533:13:2533:31 | ...::from(...) |
17-
| main.rs:2534:13:2534:31 | ...::from(...) |
12+
| main.rs:2546:13:2546:31 | ...::from(...) |
13+
| main.rs:2547:13:2547:31 | ...::from(...) |
14+
| main.rs:2548:13:2548:31 | ...::from(...) |
15+
| main.rs:2554:13:2554:31 | ...::from(...) |
16+
| main.rs:2555:13:2555:31 | ...::from(...) |
17+
| main.rs:2556:13:2556:31 | ...::from(...) |

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,26 @@ mod function_trait_bounds {
758758
fn assoc(x: Self) -> A;
759759
}
760760

761+
impl<T: Default> MyTrait<T> for S2 {
762+
fn m1(self) -> T {
763+
Default::default() // $ target=default
764+
}
765+
766+
fn assoc(x: Self) -> T {
767+
Default::default() // $ target=default
768+
}
769+
}
770+
771+
impl MyTrait<i32> for S1 {
772+
fn m1(self) -> i32 {
773+
0
774+
}
775+
776+
fn assoc(x: Self) -> i32 {
777+
0
778+
}
779+
}
780+
761781
// Type parameter with bound occurs in the root of a parameter type.
762782

763783
fn call_trait_m1<T1, T2: MyTrait<T1> + Copy>(x: T2) -> T1 {
@@ -863,6 +883,8 @@ mod function_trait_bounds {
863883
println!("{:?}", b);
864884
let b = call_trait_thing_m1_3(y3); // $ type=b:S2 target=call_trait_thing_m1_3
865885
println!("{:?}", b);
886+
let x = S1::m2(S1); // $ target=m2 $ type=x:i32
887+
let y: i32 = S2::m2(S2); // $ target=m2
866888
}
867889
}
868890

0 commit comments

Comments
 (0)