Merge pull request #17854 from geoffw0/cleanuptest

Rust: Clean up unreachable test
This commit is contained in:
Geoffrey White 2024-10-28 14:29:42 +00:00 коммит произвёл GitHub
Родитель f5d14dbe07 e5818f6f2e
Коммит 41df9ae4fc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 5 добавлений и 10 удалений

Просмотреть файл

@ -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. |

Просмотреть файл

@ -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
@ -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 {
@ -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 {
@ -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;
};