Content-Length: 320399 | pFad | http://github.com/github/codeql/pull/20020/commits/a96d3d7be8a87678696553b7578d975e527c0127

65 Rust: Type inference for pattern matching by hvitved · Pull Request #20020 · github/codeql · GitHub
Skip to content

Rust: Type inference for pattern matching #20020

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

Merged
merged 5 commits into from
Jul 11, 2025
Merged
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
Prev Previous commit
Next Next commit
Rust: Add more type inference tests
  • Loading branch information
hvitved committed Jul 11, 2025
commit a96d3d7be8a87678696553b7578d975e527c0127
26 changes: 26 additions & 0 deletions rust/ql/test/library-tests/type-inference/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,10 @@ mod explicit_type_args {
field: T5,
}

fn foo<T>(x: T) -> T {
x
}

pub fn f() {
let x1: Option<S1<S2>> = S1::assoc_fun(); // $ type=x1:T.T.S2 method=assoc_fun
let x2 = S1::<S2>::assoc_fun(); // $ type=x2:T.T.S2 method=assoc_fun
Expand All @@ -2315,6 +2319,7 @@ mod explicit_type_args {
{
field: S2::default(), // $ method=default
};
let x14 = foo::<i32>(Default::default()); // $ type=x14:i32 method=default method=foo
}
}

Expand Down Expand Up @@ -2457,6 +2462,27 @@ pub mod pattern_matching {
_ => (),
}

let opt1 = Some(Default::default()); // $ MISSING: type=opt1:T.i32 method=default
#[rustfmt::skip]
let _ = if let Some::<i32>(x) = opt1
{
x; // $ MISSING: type=x:i32
};

let opt2 = Some(Default::default()); // $ MISSING: type=opt2:T.i32 method=default
#[rustfmt::skip]
let _ = if let Option::Some::<i32>(x) = opt2
{
x; // $ MISSING: type=x:i32
};

let opt3 = Some(Default::default()); // $ type=opt3:T.i32 method=default
#[rustfmt::skip]
let _ = if let Option::<i32>::Some(x) = opt3
{
x; // $ type=x:i32
};

None
}
}
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/20020/commits/a96d3d7be8a87678696553b7578d975e527c0127

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy