Skip to content

Commit 46d0506

Browse files
committed
Rust: Add more type inference tests
1 parent 0e885e9 commit 46d0506

File tree

3 files changed

+3779
-3739
lines changed

3 files changed

+3779
-3739
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
@@ -5,9 +5,9 @@ multipleCallTargets
55
| dereference.rs:184:17:184:30 | ... .foo() |
66
| dereference.rs:186:17:186:25 | S.bar(...) |
77
| dereference.rs:187:17:187:29 | S.bar(...) |
8-
| main.rs:2437:13:2437:31 | ...::from(...) |
9-
| main.rs:2438:13:2438:31 | ...::from(...) |
10-
| main.rs:2439:13:2439:31 | ...::from(...) |
11-
| main.rs:2445:13:2445:31 | ...::from(...) |
12-
| main.rs:2446:13:2446:31 | ...::from(...) |
13-
| main.rs:2447:13:2447:31 | ...::from(...) |
8+
| main.rs:2459:13:2459:31 | ...::from(...) |
9+
| main.rs:2460:13:2460:31 | ...::from(...) |
10+
| main.rs:2461:13:2461:31 | ...::from(...) |
11+
| main.rs:2467:13:2467:31 | ...::from(...) |
12+
| main.rs:2468:13:2468:31 | ...::from(...) |
13+
| main.rs:2469:13:2469: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
@@ -676,6 +676,26 @@ mod function_trait_bounds {
676676
fn assoc(x: Self) -> A;
677677
}
678678

679+
impl<T: Default> MyTrait<T> for S2 {
680+
fn m1(self) -> T {
681+
Default::default() // $ target=default
682+
}
683+
684+
fn assoc(x: Self) -> T {
685+
Default::default() // $ target=default
686+
}
687+
}
688+
689+
impl MyTrait<i32> for S1 {
690+
fn m1(self) -> i32 {
691+
0
692+
}
693+
694+
fn assoc(x: Self) -> i32 {
695+
0
696+
}
697+
}
698+
679699
// Type parameter with bound occurs in the root of a parameter type.
680700

681701
fn call_trait_m1<T1, T2: MyTrait<T1> + Copy>(x: T2) -> T1 {
@@ -781,6 +801,8 @@ mod function_trait_bounds {
781801
println!("{:?}", b);
782802
let b = call_trait_thing_m1_3(y3); // $ type=b:S2 target=call_trait_thing_m1_3
783803
println!("{:?}", b);
804+
let x = S1::m2(S1); // $ target=m2 $ type=x:i32
805+
let y: i32 = S2::m2(S2); // $ target=m2
784806
}
785807
}
786808

0 commit comments

Comments
 (0)