mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Merge pull request #18590 from paldepind/rust-control-flow-test
Rust: Add two additional control flow tests
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -134,6 +134,14 @@ mod if_expression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_if_without_else(b: bool) -> i64 {
|
||||||
|
let mut i = 3;
|
||||||
|
if b {
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
i
|
||||||
|
}
|
||||||
|
|
||||||
fn test_if_let_else(a: Option<i64>) -> i64 {
|
fn test_if_let_else(a: Option<i64>) -> i64 {
|
||||||
if let Some(n) = a {
|
if let Some(n) = a {
|
||||||
n
|
n
|
||||||
@@ -157,6 +165,17 @@ mod if_expression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_nested_if_2(cond1: bool, cond2: bool) -> () {
|
||||||
|
if cond1 {
|
||||||
|
if cond2 {
|
||||||
|
println!("1");
|
||||||
|
} else {
|
||||||
|
println!("2");
|
||||||
|
}
|
||||||
|
println!("3");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn test_nested_if_match(a: i64) -> i64 {
|
fn test_nested_if_match(a: i64) -> i64 {
|
||||||
if (match a {
|
if (match a {
|
||||||
0 => true,
|
0 => true,
|
||||||
|
|||||||
Reference in New Issue
Block a user