Skip to content

use uX::from instead of _ as uX in non - const contexts #140435

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

bend-n
Copy link
Contributor

@bend-n bend-n commented Apr 29, 2025

changes transmute(bool) -> integer to integer::from as opposed to bool as integer.
#136083 (comment)

@rustbot label L-unnecessary_transmutes

@rustbot
Copy link
Collaborator

rustbot commented Apr 29, 2025

r? @estebank

rustbot has assigned @estebank.
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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 29, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 29, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added the L-unnecessary_transmutes Lint: unnecessary_transmutes label Apr 29, 2025
func,
snippet,
span,
self.tcx.is_const_fn(def_id)
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe this heuristic is complete. This leaves out const items and statics, for example.

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 add some tests for statics, consts, and in const blocks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

im not sure the heuristic is complete, but i added those tests and changed it a little.

@bend-n bend-n force-pushed the use_ux_from_instead_of_bool_as_ux_unnecessary_transmutes branch 2 times, most recently from 4050a31 to 5f5d1c6 Compare April 30, 2025 07:18
@bend-n bend-n force-pushed the use_ux_from_instead_of_bool_as_ux_unnecessary_transmutes branch from 5f5d1c6 to 17737d6 Compare April 30, 2025 07:18
@bend-n bend-n requested a review from compiler-errors May 4, 2025 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L-unnecessary_transmutes Lint: unnecessary_transmutes S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants