Skip to content

Moved lints from strings to methods - #17512

Merged
blyxyas merged 1 commit into
rust-lang:masterfrom
MassimilianoBaglioni:strings-to-method-refactor
Sep 14, 2026
Merged

blyxyas merged 1 commit into
rust-lang:masterfrom
MassimilianoBaglioni:strings-to-method-refactor

Conversation

@MassimilianoBaglioni

@MassimilianoBaglioni MassimilianoBaglioni commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

changelog: none

Moves STRING_FROM_UTF8_AS_BYTES and TRIM_SPLIT_WHITESPACE from strings.rs into the shared Methods dispatch in methods.rs.

Questions:

  • TRIM_SPLIT_WHITESPACE now inherits the from_expansion() check in Methods::check_expr. It had no macro guard before. Tests still pass (no test covers macro-expanded call sites), but this is an untested behavior change worth flagging.
  • I tried moving STRING_LIT_AS_BYTES too, but some tests use macros, and the from_expansion() check in Methods::check_expr prevents the lint from firing on those cases, so tests failed. I kept it in strings.rs for now because of this. How should I proceed?
  • STR_TO_STRING not moved yet, one branch matches ExprKind::Path, not MethodCall, so it doesn't fit the shared dispatch. Should this get its own arm in check_expr, stay separate, or something else?

Also happy to get feedback/comments on the code already moved, not just on the open questions above.

fixes #14253

@rustbot rustbot added the needs-fcp PRs that add, remove, or rename lints and need an FCP label Aug 6, 2026
@MassimilianoBaglioni
MassimilianoBaglioni marked this pull request as ready for review August 6, 2026 13:30
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. labels Aug 6, 2026
@Jarcho

Jarcho commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Can you split this into one commit per lint moved, please. Also when fixing CI errors you're better off force-pushing. We're going to ask you to squash those commits before merging and it doesn't affect reviewers much if you're immediately changing commits.

@MassimilianoBaglioni
MassimilianoBaglioni force-pushed the strings-to-method-refactor branch from 04a75b8 to 27e5b3f Compare August 11, 2026 17:06
@rustbot

This comment has been minimized.

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

community review: lgtm, I mostly just verified that the code is still the same code.

(the questions in the pr descriptions are better answered by a real reviewer)

View changes since this review

@MassimilianoBaglioni
MassimilianoBaglioni force-pushed the strings-to-method-refactor branch from 27e5b3f to e28d0b2 Compare August 23, 2026 23:29
@rustbot

This comment has been minimized.

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

Community review: LGTM

The corresponding code was properly moved.

View changes since this review

Comment on lines +6048 to +6050
(sym::split_whitespace, []) => {
trim_split_white_space::check(cx, expr, recv, call_span);
},

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.

This is a fix rather than an internal change because of the macro guard you pointed out in the PR description. If necessary, you can split the commit of TRIM_SPLIT_WHITESPACE into two:

  1. Add macro guard in string.rs (fix)
  2. Move it to methods/mod.rs (internal change)

I'm not sure whether combining them into single fix is conventional.

@rustbot rustbot removed the S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. label Sep 4, 2026
@rustbot

rustbot commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

r? @blyxyas

rustbot has assigned @blyxyas for the project review.
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: 9 candidates
  • 9 candidates expanded to 9 candidates
  • Random selection from 6 candidates

@blyxyas blyxyas left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking good, just a question, and this should be good-to-go!!

ฅ(•ㅅ•❀)ฅ

View changes since this review

Comment thread clippy_lints/src/strings.rs Outdated
}

if let ExprKind::MethodCall(path, receiver, ..) = &e.kind
if !e.span.in_external_macro(cx.sess().source_map())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did you move this external macro call up? It's more expensive than checking if we're dealing with a method call.

It should be kept at the same place ^ↀᴥↀ^

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.

You are completely right. I didn't want to move it in the first place; I probably moved it unintentionally while messing around with things :)

Should be fixed now

@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 Sep 7, 2026
@rustbot

rustbot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@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 Sep 9, 2026

@blyxyas blyxyas left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for addressing this issue! ❤️ ฅ•ω•ฅ
Could you squash the commits @MassimilianoBaglioni

View changes since this review

@rustbot

This comment has been minimized.

@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

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.

@blyxyas
blyxyas added this pull request to the merge queue Sep 14, 2026
Merged via the queue into rust-lang:master with commit 47e8223 Sep 14, 2026
13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp PRs that add, remove, or rename lints and need an FCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor the clippy_lints/src/strings.rs file

6 participants