Skip to content

Commit 04bf2f5

Browse files
committed
Rust: Add more type inference tests
1 parent f7195f0 commit 04bf2f5

File tree

2 files changed

+677
-640
lines changed

2 files changed

+677
-640
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,8 +1844,10 @@ mod async_ {
18441844
}
18451845

18461846
mod impl_trait {
1847+
#[derive(Clone)]
18471848
struct S1;
18481849
struct S2;
1850+
struct S3<T3>(T3);
18491851

18501852
trait Trait1 {
18511853
fn f1(&self) {} // Trait1f1
@@ -1877,10 +1879,21 @@ mod impl_trait {
18771879
}
18781880
}
18791881

1882+
impl<T: Clone> MyTrait<T> for S3<T> {
1883+
fn get_a(&self) -> T {
1884+
let S3(t) = self;
1885+
t.clone()
1886+
}
1887+
}
1888+
18801889
fn get_a_my_trait() -> impl MyTrait<S2> {
18811890
S1
18821891
}
18831892

1893+
fn get_a_my_trait2<T: Clone>(x: T) -> impl MyTrait<T> {
1894+
S3(x)
1895+
}
1896+
18841897
fn uses_my_trait1<A, B: MyTrait<A>>(t: B) -> A {
18851898
t.get_a() // $ method=MyTrait::get_a
18861899
}
@@ -1898,6 +1911,7 @@ mod impl_trait {
18981911
let a = get_a_my_trait();
18991912
let c = uses_my_trait2(a); // $ type=c:S2
19001913
let d = uses_my_trait2(S1); // $ type=d:S2
1914+
let e = get_a_my_trait2(S1).get_a(); // $ method=MyTrait::get_a $ MISSING: type=e:S1
19011915
}
19021916
}
19031917

0 commit comments

Comments
 (0)