Skip to content

fix: nightly clippy redundant else block lint - #13601

Merged
sylvestre merged 12 commits into
uutils:mainfrom
HackingRepo:patch-6
Jul 28, 2026
Merged

fix: nightly clippy redundant else block lint#13601
sylvestre merged 12 commits into
uutils:mainfrom
HackingRepo:patch-6

Conversation

@HackingRepo

Copy link
Copy Markdown
Contributor

Hi, @cakebaker

we saw that when doing cargo clippy locally

warning: redundant else block
   --> src/bin/coreutils.rs:140:6
    |
140 |       } else {
    |  ______^
141 | |         // GNU just fails, but busybox tests needs usage
142 | |         // todo: patch the test suite instead
143 | |         if binary_as_util.ends_with("box") {
...   |
148 | |         process::exit(1);
149 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
help: remove the `else` block and move the contents out
    |
140 ~     }
141 +     // GNU just fails, but busybox tests needs usage
142 +     // todo: patch the test suite instead
143 +     if binary_as_util.ends_with("box") {
144 +         usage(&utils, binary_as_util);
145 +     } else {
146 +         let _ = writeln!(io::stderr(), "coreutils: missing argument");
147 +     }
148 +     process::exit(1);

Hi, @cakebaker 

we saw that when doing cargo clippy locally

```rust
warning: redundant else block
   --> src/bin/coreutils.rs:140:6
    |
140 |       } else {
    |  ______^
141 | |         // GNU just fails, but busybox tests needs usage
142 | |         // todo: patch the test suite instead
143 | |         if binary_as_util.ends_with("box") {
...   |
148 | |         process::exit(1);
149 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
help: remove the `else` block and move the contents out
    |
140 ~     }
141 +     // GNU just fails, but busybox tests needs usage
142 +     // todo: patch the test suite instead
143 +     if binary_as_util.ends_with("box") {
144 +         usage(&utils, binary_as_util);
145 +     } else {
146 +         let _ = writeln!(io::stderr(), "coreutils: missing argument");
147 +     }
148 +     process::exit(1);
```
@sylvestre

Copy link
Copy Markdown
Contributor

Could you please add this in the ci too?

@sylvestre

Copy link
Copy Markdown
Contributor

we already have .github/workflows/code-quality.yml
but we didn't catch this case
so, just extend it to catch it

@HackingRepo

Copy link
Copy Markdown
Contributor Author

ah ok

@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 339 untouched benchmarks
🆕 3 new benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation uniq_check_chars[(10000, "1")] 14.4 ms 14.9 ms -3.24%
Memory timeout_quick_exit 79 KB 16.2 KB ×4.9
Memory timeout_enforced 19.4 KB 16.5 KB +17.81%
🆕 Memory timer_expiry_latency[0.001] N/A 79.9 KB N/A
🆕 Memory timer_expiry_latency[0.005] N/A 17 KB N/A
🆕 Memory timer_expiry_latency[0.02] N/A 17 KB N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing HackingRepo:patch-6 (abc9fca) with main (9d0c43a)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@HackingRepo

Copy link
Copy Markdown
Contributor Author

@sylvestre i used cargo nightly that why, because new lints introduced

@HackingRepo

Copy link
Copy Markdown
Contributor Author

@sylvestre can we add nightly tests too or no?

@sylvestre

Copy link
Copy Markdown
Contributor

ok, please revert the change then :)
thanks

Ah, i misunderstond, so i need revoke only the run clippy script that change needs to be keeped
@HackingRepo

Copy link
Copy Markdown
Contributor Author

ok now done

@HackingRepo HackingRepo changed the title fix: clippy redundant else block fix: nightly clippy redundant else block lint Jul 27, 2026
Comment thread src/bin/coreutils.rs
validation::unrecognized_option(binary_as_util, &util_os);
}
process::exit(1);
validation::not_found(&util_os);

@xtqqczze xtqqczze Jul 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change seems to be sound, but perhaps somewhat confusing as you now need to understand that validation::not_found etc exits the process to understand the control flow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you are right

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually not_found returns the never type, so the behaviour can be deduced from this.

@HackingRepo
HackingRepo requested a review from xtqqczze July 27, 2026 12:18

@xtqqczze xtqqczze left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why has validation::not_found been removed?

@HackingRepo

Copy link
Copy Markdown
Contributor Author

ah ok, i will revert it

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/pid-pipe (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)

@HackingRepo

HackingRepo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@cakebaker and @sylvestre can you merge that>

@sylvestre
sylvestre merged commit 4855c67 into uutils:main Jul 28, 2026
160 of 162 checks passed
@HackingRepo
HackingRepo deleted the patch-6 branch July 28, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants