Skip to content

Extend byte_char_slices to cover arrays#16770

Merged
samueltardieu merged 2 commits into
rust-lang:masterfrom
profetia:issue16759
Apr 15, 2026
Merged

Extend byte_char_slices to cover arrays#16770
samueltardieu merged 2 commits into
rust-lang:masterfrom
profetia:issue16759

Conversation

@profetia
Copy link
Copy Markdown
Member

@profetia profetia commented Mar 26, 2026

Closes #16759

changelog: [byte_char_slices] enhance to cover arrays

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

r? @samueltardieu

rustbot has assigned @samueltardieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 26, 2026

Lintcheck changes for d0c0f3a

Lint Added Removed Changed
clippy::byte_char_slices 4 0 0

This comment will be updated if you push new changes

@samueltardieu
Copy link
Copy Markdown
Member

I wonder whether it would be interesting to see how this array is then used. If all uses are adjusted and auto-dereferenced, then suggesting b"…" (without *) would make sense.

@profetia
Copy link
Copy Markdown
Member Author

Agree.

@profetia
Copy link
Copy Markdown
Member Author

Implemented. The lint is now moved to late pass. I also avoid arrays with comments or cfg, looking into the lint check results.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

Copy link
Copy Markdown
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

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

Could you also add some more tests? Like:

    let with_escape: u8 = [b'\'', b'"', b'\x00', b'\n', b'\\'].iter().copied().sum();
    //~^ byte_char_slices

    takes_array_ref(&[b'a', b'b']);
    //~^ byte_char_slices

    takes_array_ref_ref(&&[b'a', b'b']);
    //~^ byte_char_slices
}

fn takes_array_ref(_: &[u8; 2]) {}

fn takes_array_ref_ref(_: &&[u8; 2]) {}

View changes since this review

Comment thread clippy_lints/src/byte_char_slices.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Apr 5, 2026
@rustbot

This comment has been minimized.

@profetia profetia requested a review from samueltardieu April 6, 2026 20:47
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Apr 6, 2026
Copy link
Copy Markdown
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

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

Last nit: could you fix the PR title, the commit message and the changelog? This is not really a false negative as the lint name talks about slices, this is more of an enhancement, so that byte_char_slices now handle arrays as well.

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Apr 7, 2026
@profetia profetia changed the title Fix byte_char_slices FN on arrays Extend byte_char_slices to cover arrays Apr 7, 2026
@profetia
Copy link
Copy Markdown
Member Author

profetia commented Apr 7, 2026

Done. Thank you!

@profetia profetia requested a review from samueltardieu April 7, 2026 22:28
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Apr 7, 2026
@rustbot

This comment has been minimized.

@samueltardieu
Copy link
Copy Markdown
Member

@profetia Tell me when you've rebased it and I'll merge it.

@samueltardieu
Copy link
Copy Markdown
Member

Also, can you invert the order of the two commits? This would make sure that tests pass after every commit, whereas in the current situation after the first commit tests won't pass.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Copy link
Copy Markdown
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

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

I was able to do the rebase and commit inversion. I'll merge.

View changes since this review

@samueltardieu samueltardieu enabled auto-merge April 15, 2026 16:18
@samueltardieu samueltardieu added this pull request to the merge queue Apr 15, 2026
Merged via the queue into rust-lang:master with commit c0adb72 Apr 15, 2026
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 15, 2026
@profetia
Copy link
Copy Markdown
Member Author

I have been quite busy lately. Big thanks for help working on this :)

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.

byte_char_slices should trigger on arrays

3 participants