Skip to content

Add suggestion to cast_sign_loss and cast_possible_wrap using the cast_{un,}signed() methods #15384

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 3 commits into
base: master
Choose a base branch
from

Conversation

RunDevelopment
Copy link

@RunDevelopment RunDevelopment commented Aug 1, 2025

changelog: [cast_sign_loss, cast_possible_wrap]: add suggestion using cast_{un,}signed() methods

Fixes #14150

This PR adds a suggestion to cast_sign_loss and cast_possible_wrap, which fixes reported warnings using the cast_{un,}signed() methods, as proposed in #14150. Suggestions are only made if MSRV is >=1.87.

Also, I'm not 100% sure about the suggestion message yet. I'm open for suggestions.

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 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 Aug 1, 2025
Copy link

github-actions bot commented Aug 1, 2025

Lintcheck changes for 4e286bb

Lint Added Removed Changed
clippy::cast_possible_wrap 0 0 253
clippy::cast_sign_loss 0 0 294

This comment will be updated if you push new changes

@samueltardieu
Copy link
Member

You should also include a test with a MSRV of 1.86 to ensure the suggestions are not emitted.

@samueltardieu samueltardieu added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Aug 2, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Aug 3, 2025
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) has-merge-commits PR has merge commits, merge with caution. labels Aug 3, 2025
@RunDevelopment
Copy link
Author

I applied all suggestions from the review. Hope this is good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propose fix for cast_sign_loss and cast_possible_wrap
4 participants