Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix integer_division false negative for NonZero denominators #14664

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

alex-semenyuk
Copy link
Member

@alex-semenyuk alex-semenyuk commented Apr 21, 2025

Close #14652

changelog: [integer_division]: fix false negative for NonZero denominators

@rustbot
Copy link
Collaborator

rustbot commented Apr 21, 2025

r? @llogiq

rustbot has assigned @llogiq.
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 Apr 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 2, 2025

Failed to set assignee to Clippy: cannot assign: response: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/assignees#add-assignees-to-an-issue","status":"404"}

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@alex-semenyuk
Copy link
Member Author

r? clippy

@rustbot rustbot assigned blyxyas and unassigned llogiq May 2, 2025
Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

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

Great bugfix, althought I have some light comments =^w^= 🐱

Comment on lines +16 to +17
let left_ty = cx.typeck_results().expr_ty(left);
let right_ty = cx.typeck_results().expr_ty(right);
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this to below that initial op == hir::BinOpKind::Div so that we don't calculate expression types on all expressions?

@@ -12,4 +16,8 @@ fn main() {
//~^ integer_division

let x = 1. / 2.0;

Copy link
Member

Choose a reason for hiding this comment

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

Just for future resilience, could you also add a test for NonZero / <integer> and NonZero / NonZero

@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 5, 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.

integer_division false negative for NonZero denominators
4 participants