Skip to content

parsed_string_literals: new lint #14794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented May 13, 2025

This lint detects parsing of string literals into IP addresses when they are known correct.

changelog: [parsed_string_literals]: new lint

Inspired by this Zulip comment.

@rustbot
Copy link
Collaborator

rustbot commented May 13, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 13, 2025
@Jarcho
Copy link
Contributor

Jarcho commented May 14, 2025

Is there any reason to limit linting this to just ip addresses? Any call to parse on a string literal has the same issue regardless of the type. The suggestion would have to be specialised per type so it could only exist for a subset of cases. Possibly a config to ignore specific types, but I'm not sure if this would be needed.

@samueltardieu
Copy link
Contributor Author

I guess this could be extended, but at this stage I'm not sure we should make a generic lint for this. Specialized lints can be collectively renamed into a more generic one if we don't see one of them being disabled in isolation. I'd be more comfortable with a separate lint for the time being.

In any case, I'll suspend this PR until rust-lang/rust#140976 is merged and synced to Clippy (hopefully tomorrow).

@rustbot author

@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 May 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 14, 2025

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

@rustbot

This comment has been minimized.

@samueltardieu samueltardieu force-pushed the unnecessary-ip-addr-parse branch 2 times, most recently from ceb8d7f to 938d056 Compare May 21, 2025 20:50
@samueltardieu
Copy link
Contributor Author

Rebased to take advantage of the new diagnostic items.

What about clippy::parsed_string_literals as a name?

@Jarcho
Copy link
Contributor

Jarcho commented May 21, 2025

That sounds like a good name.

@Jarcho
Copy link
Contributor

Jarcho commented May 21, 2025

This lint detects parsing of string literals into IP addresses when they
are known correct.
@samueltardieu samueltardieu force-pushed the unnecessary-ip-addr-parse branch from 938d056 to ead8755 Compare May 21, 2025 22:07
@samueltardieu samueltardieu changed the title unnecessary_ip_addr_parse: new lint parsed_string_literals: new lint May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants