Skip to content

Commit

Permalink
Merge pull request #17854 from geoffw0/cleanuptest
Browse files Browse the repository at this point in the history
Rust: Clean up unreachable test
  • Loading branch information
geoffw0 authored Oct 28, 2024
2 parents f5d14db + e5818f6 commit 41df9ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 0 additions & 5 deletions rust/ql/test/query-tests/unusedentities/UnusedValue.expected
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@
| more.rs:46:9:46:14 | a_ptr4 | Variable is assigned a value that is never used. |
| more.rs:61:9:61:13 | d_ptr | Variable is assigned a value that is never used. |
| more.rs:67:9:67:17 | f_ptr | Variable is assigned a value that is never used. |
| unreachable.rs:166:6:166:6 | x | Variable is assigned a value that is never used. |
| unreachable.rs:190:14:190:14 | a | Variable is assigned a value that is never used. |
| unreachable.rs:199:9:199:9 | a | Variable is assigned a value that is never used. |
| unreachable.rs:210:11:210:11 | a | Variable is assigned a value that is never used. |
| unreachable.rs:217:6:217:6 | a | Variable is assigned a value that is never used. |
10 changes: 5 additions & 5 deletions rust/ql/test/query-tests/unusedentities/unreachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn unreachable_loop() {
do_something(); // BAD: unreachable code
}

for x in 1..10 {
for _ in 1..10 {
if cond() {
continue;
do_something(); // BAD: unreachable code
Expand All @@ -187,7 +187,7 @@ fn unreachable_paren() {
}

fn unreachable_let_1() {
if let Some(a) = maybe_get_a_number() {
if let Some(_) = maybe_get_a_number() {
do_something();
return;
} else {
Expand All @@ -196,7 +196,7 @@ fn unreachable_let_1() {

do_something(); // SPURIOUS: unreachable code

if let a = get_a_number() { // (always succeeds)
if let _ = get_a_number() { // (always succeeds)
do_something();
return;
} else {
Expand All @@ -207,14 +207,14 @@ fn unreachable_let_1() {
}

fn unreachable_let_2() {
let Some(a) = maybe_get_a_number() else {
let Some(_) = maybe_get_a_number() else {
do_something();
return;
};

do_something();

let a = maybe_get_a_number() else { // (always succeeds)
let _ = maybe_get_a_number() else { // (always succeeds)
do_something(); // BAD: unreachable code
return;
};
Expand Down

0 comments on commit 41df9ae

Please sign in to comment.