mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #18007 from hvitved/rust/cfg/and-let
Rust: Improve CFG for `let` expressions
This commit is contained in:
@@ -71,7 +71,13 @@ module ConditionalCompletionSplitting {
|
||||
child = parent.(LogicalNotExpr).getExpr() and
|
||||
childCompletion.getDual() = parentCompletion
|
||||
or
|
||||
childCompletion = parentCompletion and
|
||||
(
|
||||
childCompletion = parentCompletion
|
||||
or
|
||||
// needed for `let` expressions
|
||||
childCompletion.(MatchCompletion).getValue() =
|
||||
parentCompletion.(BooleanCompletion).getValue()
|
||||
) and
|
||||
(
|
||||
child = parent.(BinaryLogicalOperation).getAnOperand()
|
||||
or
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -62,15 +62,15 @@ mod loop_expression {
|
||||
}
|
||||
|
||||
fn test_loop_label_shadowing(b: bool) -> ! {
|
||||
'loop: loop {
|
||||
'label: loop {
|
||||
1;
|
||||
'loop: loop {
|
||||
'label: loop {
|
||||
if b {
|
||||
continue;
|
||||
} else if b {
|
||||
continue 'loop;
|
||||
continue 'label;
|
||||
}
|
||||
continue 'loop;
|
||||
continue 'label;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,24 @@ mod if_expression {
|
||||
0
|
||||
}
|
||||
|
||||
fn test_and_if_let(a: bool, b: Option<bool>, c: bool) -> bool {
|
||||
if a && let Some(d) = b {
|
||||
d
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn test_and_if_let2(a: bool, b: i64, c: bool) -> bool {
|
||||
if a && let d = b
|
||||
&& c
|
||||
{
|
||||
d > 0
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn test_nested_if(a: i64) -> i64 {
|
||||
if (if a < 0 { a < -10 } else { a > 10 }) {
|
||||
1
|
||||
@@ -262,6 +280,10 @@ mod logical_operators {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn test_and_return(a: bool) {
|
||||
a && return;
|
||||
}
|
||||
}
|
||||
|
||||
mod question_mark_operator {
|
||||
|
||||
Reference in New Issue
Block a user