Skip to content

Conversation

@sylvestre
Copy link
Contributor

after #9848

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)


for (idx, selector) in settings.selectors.iter().enumerate() {
let key_index = idx + 1;
let key_index = idx.saturating_add(1);
Copy link
Contributor

@xtqqczze xtqqczze Feb 2, 2026

Choose a reason for hiding this comment

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

enumerate() itself doesn’t guard against overflow, so guarding only at idx + 1 doesn’t add real safety.

In any case, I think idx.checked_add(1).unwrap() would make more sense.

Copy link
Contributor

@xtqqczze xtqqczze Feb 2, 2026

Choose a reason for hiding this comment

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

Hang on, there is no potential overflow, key_index has the range 1..settings.selectors.len()

They all optimise to the same anyway: https://godbolt.org/z/f4WzhP1vf

@@ -1800,7 +1803,7 @@ fn emit_debug_warnings(
show_error!("{}", translate!("sort-warning-simple-byte-comparison"));

for (idx, selector) in settings.selectors.iter().enumerate() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (idx, selector) in settings.selectors.iter().enumerate() {
for (key_index, selector) in (1..).zip(settings.selectors.iter()) {

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.

2 participants