-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Lint casts to u128 in cast_lossless
#13146
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
Conversation
877ac4c to
610c5e2
Compare
|
I think the linked zulip thread is wrong ^^ @Alexendoo could you link the correct one? |
610c5e2 to
8fa2d85
Compare
| match cast_to_hir.kind { | ||
| TyKind::Infer => { | ||
| let sugg = if cast_from_expr.precedence().order() == PREC_PREFIX { | ||
| format!("({from}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a missing ) here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can this just use Sugg::hir().maybe_par() or does that not work here? I believe the current version won't handle parenthesized expressions like (1i8 + 1i8) as _ correctly. Would need < PREC_POSTFIX or something like that I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 I wonder why I did not add tests for this
It was meant to be from_snippet rather than from so that PREC_PREFIX would cover the unary op cases, but that still missed x as u16 as _
I didn't use it initially because Sugg had an issue with macro spans but fixing it was easier than I thought so it does now
|
Also suggesting |
8fa2d85 to
6d28e1a
Compare
|
Nice, looks all good to me now, thanks! @bors r+ |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Reverts #12496 per https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Should.20.60as.20u128.60.20trigger.20cast_lossless
Also changes the lint messages and refactors the suggestion production - Fixes #12695
changelog: [
cast_lossless]: lint casts tou128