Skip to content

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented May 25, 2025

Make PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS (#130540) and UNNECESSARY_TRANSMUTES (#136083) into "normal" HIR-based lints.

Funny enough this came up in the review of the latter (#136083 (comment)), but I guess it just was overlooked.

But anywyas, there's no reason for these to be MIR lints; in fact, it makes the suggestions for them a bit more complicated than necessary.

Note that there's probably a few more simplifications and improvements to be done here. Follow-ups can be done in a separate PR, especially if they're about the messaging and suggestions themselves, which I didn't write.

@rustbot
Copy link
Collaborator

rustbot commented May 25, 2025

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
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 May 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 25, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@@ -1,7 +1,9 @@
#![deny(ptr_to_integer_transmute_in_consts)]
Copy link
Member Author

Choose a reason for hiding this comment

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

I made this test into a hard error for the lint, and removed the //~^ ERROR annotation in fn main, since we can't mix normal errors and lints since they happen after normal checking has happened.

_ => return,
};

cx.tcx.node_span_lint(UNNECESSARY_TRANSMUTES, expr.hir_id, expr.span, |diag| {
Copy link
Member Author

Choose a reason for hiding this comment

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

I chose to be lazy and use the old diagnostic machinery for the UNNECESSARY_TRANSMUTES lint, since it's kind of a pain in the ass to make it work "correctly" w/ the new machinery.

@BoxyUwU
Copy link
Member

BoxyUwU commented May 27, 2025

gamer+

@bors
Copy link
Collaborator

bors commented May 27, 2025

📌 Commit 295a8d5 has been approved by BoxyUwU

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 27, 2025
@compiler-errors
Copy link
Member Author

@bors rollup

bors added a commit that referenced this pull request May 28, 2025
Rollup of 8 pull requests

Successful merges:

 - #140367 (add `asm_cfg`: `#[cfg(...)]` within `asm!`)
 - #140894 (Make check-cfg diagnostics work in `#[doc(cfg(..))]`)
 - #141252 (gvn: bail out unavoidable non-ssa locals in repeat)
 - #141517 (rustdoc: use descriptive tooltip if doctest is conditionally ignored)
 - #141551 (Make two transmute-related MIR lints into HIR lint)
 - #141591 (ci: fix llvm test coverage)
 - #141647 (Bump master `stage0` compiler)
 - #141659 (Add `Result::map_or_default` and `Option::map_or_default`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e0278ed into rust-lang:master May 28, 2025
6 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 28, 2025
rust-timer added a commit that referenced this pull request May 28, 2025
Rollup merge of #141551 - compiler-errors:hir-lints, r=BoxyUwU

Make two transmute-related MIR lints into HIR lint

Make `PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS` (#130540) and `UNNECESSARY_TRANSMUTES` (#136083) into "normal" HIR-based lints.

Funny enough this came up in the review of the latter (#136083 (comment)), but I guess it just was overlooked.

But anywyas, there's no reason for these to be MIR lints; in fact, it makes the suggestions for them a bit more complicated than necessary.

Note that there's probably a few more simplifications and improvements to be done here. Follow-ups can be done in a separate PR, especially if they're about the messaging and suggestions themselves, which I didn't write.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request May 28, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#140367 (add `asm_cfg`: `#[cfg(...)]` within `asm!`)
 - rust-lang/rust#140894 (Make check-cfg diagnostics work in `#[doc(cfg(..))]`)
 - rust-lang/rust#141252 (gvn: bail out unavoidable non-ssa locals in repeat)
 - rust-lang/rust#141517 (rustdoc: use descriptive tooltip if doctest is conditionally ignored)
 - rust-lang/rust#141551 (Make two transmute-related MIR lints into HIR lint)
 - rust-lang/rust#141591 (ci: fix llvm test coverage)
 - rust-lang/rust#141647 (Bump master `stage0` compiler)
 - rust-lang/rust#141659 (Add `Result::map_or_default` and `Option::map_or_default`)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request May 30, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang#140367 (add `asm_cfg`: `#[cfg(...)]` within `asm!`)
 - rust-lang#140894 (Make check-cfg diagnostics work in `#[doc(cfg(..))]`)
 - rust-lang#141252 (gvn: bail out unavoidable non-ssa locals in repeat)
 - rust-lang#141517 (rustdoc: use descriptive tooltip if doctest is conditionally ignored)
 - rust-lang#141551 (Make two transmute-related MIR lints into HIR lint)
 - rust-lang#141591 (ci: fix llvm test coverage)
 - rust-lang#141647 (Bump master `stage0` compiler)
 - rust-lang#141659 (Add `Result::map_or_default` and `Option::map_or_default`)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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