Content-Length: 341768 | pFad | http://github.com/github/codeql/pull/19954/commits/22091d2f28243a191a744fbd94c1f05b05505786

3E Rust: Rework type inference for impl Trait in return position by hvitved · Pull Request #19954 · github/codeql · GitHub
Skip to content

Rust: Rework type inference for impl Trait in return position #19954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Rust: Add more type inference tests
  • Loading branch information
hvitved committed Jul 11, 2025
commit 22091d2f28243a191a744fbd94c1f05b05505786
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
multipleCallTargets
| dereference.rs:61:15:61:24 | e1.deref() |
| main.rs:2186:13:2186:31 | ...::from(...) |
| main.rs:2187:13:2187:31 | ...::from(...) |
| main.rs:2188:13:2188:31 | ...::from(...) |
| main.rs:2194:13:2194:31 | ...::from(...) |
| main.rs:2195:13:2195:31 | ...::from(...) |
| main.rs:2196:13:2196:31 | ...::from(...) |
| main.rs:2200:13:2200:31 | ...::from(...) |
| main.rs:2201:13:2201:31 | ...::from(...) |
| main.rs:2202:13:2202:31 | ...::from(...) |
| main.rs:2208:13:2208:31 | ...::from(...) |
| main.rs:2209:13:2209:31 | ...::from(...) |
| main.rs:2210:13:2210:31 | ...::from(...) |
14 changes: 14 additions & 0 deletions rust/ql/test/library-tests/type-inference/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1854,8 +1854,10 @@ mod async_ {
}

mod impl_trait {
#[derive(Clone)]
struct S1;
struct S2;
struct S3<T3>(T3);

trait Trait1 {
fn f1(&self) {} // Trait1f1
Expand Down Expand Up @@ -1887,10 +1889,21 @@ mod impl_trait {
}
}

impl<T: Clone> MyTrait<T> for S3<T> {
fn get_a(&self) -> T {
let S3(t) = self;
t.clone()
}
}

fn get_a_my_trait() -> impl MyTrait<S2> {
S1
}

fn get_a_my_trait2<T: Clone>(x: T) -> impl MyTrait<T> {
S3(x)
}

fn uses_my_trait1<A, B: MyTrait<A>>(t: B) -> A {
t.get_a() // $ method=MyTrait::get_a
}
Expand All @@ -1908,6 +1921,7 @@ mod impl_trait {
let a = get_a_my_trait(); // $ method=get_a_my_trait
let c = uses_my_trait2(a); // $ type=c:S2 method=uses_my_trait2
let d = uses_my_trait2(S1); // $ type=d:S2 method=uses_my_trait2
let e = get_a_my_trait2(S1).get_a(); // $ method=get_a_my_trait2 method=MyTrait::get_a $ MISSING: type=e:S1
}
}

Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/codeql/pull/19954/commits/22091d2f28243a191a744fbd94c1f05b05505786

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy