Skip to content
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

correct suggestion for manual_div_ceil lint #13864

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

Conversation

lapla-cogito
Copy link
Contributor

fix #13843

The manual_div_ceil lint makes incorrect suggestion when type suffixes need to be made explicit in the suggested code.

changelog: [manual_div_ceil]: suggested code now includes appropriate type suffixes where necessary

@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2024

r? @xFrednet

rustbot has assigned @xFrednet.
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 Dec 22, 2024
@lapla-cogito lapla-cogito force-pushed the issue_13843 branch 2 times, most recently from 13e5caf to 67aec36 Compare December 22, 2024 16:18
Comment on lines 157 to 159
let type_suffix = if cx.typeck_results().expr_ty(lhs).is_numeric()
&& !is_include_type_suffix(cx, lhs)
&& matches!(lhs.kind, ExprKind::Lit(_) | ExprKind::Unary(_, _))
{
format!("_{}", cx.typeck_results().expr_ty(rhs))
} else {
String::new()
};
Copy link
Contributor Author

@lapla-cogito lapla-cogito Dec 22, 2024

Choose a reason for hiding this comment

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

If lhs is a numeric and a literal (e.g. 3) or unary (e.g. -3) that needs to be type-suffixed, make the type suffix to match the type of rhs here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

manual_div_ceil lint can suggest broken code
4 participants