use uX::from instead of _ as uX in non - const contexts#140435
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| func, | ||
| snippet, | ||
| span, | ||
| self.tcx.is_const_fn(def_id) |
There was a problem hiding this comment.
I don't believe this heuristic is complete. This leaves out const items and statics, for example.
There was a problem hiding this comment.
could you add some tests for statics, consts, and in const blocks?
There was a problem hiding this comment.
im not sure the heuristic is complete, but i added those tests and changed it a little.
compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
Outdated
Show resolved
Hide resolved
5f5d1c6 to
17737d6
Compare
compiler-errors
left a comment
There was a problem hiding this comment.
Just some nits, then I can approve.
| func, | ||
| snippet, | ||
| span, | ||
| self.tcx.is_const_fn(def_id) |
There was a problem hiding this comment.
Can you use tcx.hir_body_const_context(def_id.expect_local()).is_some()? That's actually probably the most correct way to do it.
compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
Outdated
Show resolved
Hide resolved
17737d6 to
a57f326
Compare
This comment has been minimized.
This comment has been minimized.
a57f326 to
c0b365d
Compare
|
@rustbot ready |
|
@bors r+ rollup |
|
☔ The latest upstream changes (presumably #141379) made this pull request unmergeable. Please resolve the merge conflicts. |
c0b365d to
8373bb1
Compare
|
@bend-n: 🔑 Insufficient privileges: Not in reviewers |
|
@bors r+ |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#135562 (Add ignore value suggestion in closure body) - rust-lang#139635 (Finalize repeat expr inference behaviour with inferred repeat counts) - rust-lang#139668 (Handle regions equivalent to 'static in non_local_bounds) - rust-lang#140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths) - rust-lang#140435 (use uX::from instead of _ as uX in non - const contexts) - rust-lang#141130 (rustc_on_unimplemented cleanups) - rust-lang#141286 (Querify `coroutine_hidden_types`) Failed merges: - rust-lang#140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#140435 - bend-n:use_ux_from_instead_of_bool_as_ux_unnecessary_transmutes, r=compiler-errors use uX::from instead of _ as uX in non - const contexts changes `transmute(bool) -> integer` to `integer::from` as opposed to `bool as integer`. rust-lang#136083 (comment) `@rustbot` label L-unnecessary_transmutes
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#135562 (Add ignore value suggestion in closure body) - rust-lang#139635 (Finalize repeat expr inference behaviour with inferred repeat counts) - rust-lang#139668 (Handle regions equivalent to 'static in non_local_bounds) - rust-lang#140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths) - rust-lang#140435 (use uX::from instead of _ as uX in non - const contexts) - rust-lang#141130 (rustc_on_unimplemented cleanups) - rust-lang#141286 (Querify `coroutine_hidden_types`) Failed merges: - rust-lang#140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs) r? `@ghost` `@rustbot` modify labels: rollup
changes
transmute(bool) -> integertointeger::fromas opposed tobool as integer.#136083 (comment)
@rustbot label L-unnecessary_transmutes