Make two transmute-related MIR lints into HIR lint
Make `PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS` (rust-lang/rust#130540) and `UNNECESSARY_TRANSMUTES` (rust-lang/rust#136083) into "normal" HIR-based lints.
Funny enough this came up in the review of the latter (https://github.com/rust-lang/rust/pull/136083#issuecomment-2614301413), 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.
gvn: bail out unavoidable non-ssa locals in repeat
Fixes#141251.
We cannot transform `*elem` to `array[idx1]` in the following code, as `idx1` has already been modified.
```rust
mir! {
let array;
let elem;
{
array = [*val; 5];
elem = &array[idx1];
idx1 = idx2;
RET = *elem;
Return()
}
}
```
Perhaps I could transform it to `array[0]`, but I prefer the conservative approach.
r? mir-opt
Make check-cfg diagnostics work in `#[doc(cfg(..))]`
This PR makes it so that the check-cfg `unexpected_cfgs` lint, is correctly emitted in `rustdoc`'s `#[doc(cfg(..))]`.
This is achieved by adding a custom trait to `cfg_matches` (the method that emits the lint) which permits `rustc` and `rustdoc` to each have their way to emitting lints (via buffered lints/AST for `rustc` and via `TyCtxt`/HIR for `rustdoc`).
The reason this is required is because buffered lints operates on the AST but `rustdoc` uses the HIR and by the time `rustdoc` calls `cfg_matches` we are way passed the point where buffered lints have been drain and emitted.
Best reviewed commit by commit.
r? `@jieyouxu` (for the compiler part)
r? `@GuillaumeGomez` (for the rustdoc part)
tests: mark option-niche-eq as fixed on LLVM 21
Some combination of recent Rust changes (between 3d86494a0d and aa57e46e24 from what I can tell) and changes in LLVM 21 (not recently, as best I can tell) have caused this test to start showing the behavior we want, so it's time to move this test to a proper place and mark it as fixed on LLVM 21.
~~Probably "fixes" rust-lang/rust#49892, but I'll let others make that call.~~
Closesrust-lang/rust#49892 unless we want to break out a dedicated issue for `Option<bool>::eq` on LLVM 20 (seems low-value).
`@rustbot` label llvm-main
coverage: Revert "unused local file IDs" due to empty function names
The changes to coverage metadata generation in rust-lang/rust#140847 appear to be the most likely cause of the `function name is empty` errors reported in rust-lang/rust#141577.
If that guess is correct, great. If not, no big deal.
---
This reverts commit 3b22c21dd8, reversing changes made to 5f292eea6d.
r? ghost
Rename `{GenericArg,Term}::unpack()` to `kind()`
A well-deserved rename IMO.
r? `@oli-obk` or `@lcnr` (or anyone)
cc `@rust-lang/types,` but I'd be surprised if this is controversial.
Rollup of 17 pull requests
Successful merges:
- rust-lang/rust#140591 (Fix malformed suggestion for E0061 when method is a macro token in macro context)
- rust-lang/rust#141536 (Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics)
- rust-lang/rust#141552 (Pull out dedicated `cfg_version` syntax test from feature gate test)
- rust-lang/rust#141556 (bootstrap: translate Windows paths in a way that works for both Cygwin and MSYS2)
- rust-lang/rust#141563 (Remove out-of-date `noop_*` names.)
- rust-lang/rust#141568 (dist: make sure llvm-project submodule is present)
- rust-lang/rust#141580 (Use more detailed spans in dyn compat errors within bodies)
- rust-lang/rust#141582 (intrinsics, ScalarInt: minor cleanup)
- rust-lang/rust#141584 (Support `opaque_types_defined_by` for `SyntheticCoroutineBody`)
- rust-lang/rust#141587 (Add missing edition directives for async-await tests)
- rust-lang/rust#141594 (Add `generic_arg_infer` test)
- rust-lang/rust#141596 (rustc book: fix erratic sentence by making it more simple)
- rust-lang/rust#141599 (Remove an unnecessary use of `Box::into_inner`.)
- rust-lang/rust#141611 (Update mdbook to 0.4.51)
- rust-lang/rust#141616 (Remove spastorino from vacations)
- rust-lang/rust#141623 (use custom types to clarify arguments to `emit_ptr_va_arg`)
- rust-lang/rust#141635 (further dedup `WalkItemKind` for `mut_visit` and `visit`)
r? `@ghost`
`@rustbot` modify labels: rollup
Some combination of recent Rust changes (between 3d86494a0d and
aa57e46e24 from what I can tell) and changes in LLVM 21 (not recently,
as best I can tell) have caused this test to start showing the behavior
we want, so it's time to move this test to a proper place and mark it as
fixed on LLVM 21.
Add `generic_arg_infer` test
I think most of our existing tests around behaviour of repeat expr inferred counts fail by not having enough inference progress, rather than by having enough inference progress but the element not actually implementing `Copy`.
Support `opaque_types_defined_by` for `SyntheticCoroutineBody`
We create a synthetic MIR body for the `AsyncFnOnce` impl for async closures. That body goes through all passes that a regular body does, including promotion.
Promotion sometimes requires computing that the type of an rvalue is `Freeze`, which requires computing the typing env of a body. This requires calling `opaque_types_defined_by` on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.
While we could fix this by, for example, computing the typeck root of the body before calling a `TypingEnv` constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.
Fixesrust-lang/rust#141466
r? ```@lcnr``` or ```@oli-obk```
Use more detailed spans in dyn compat errors within bodies
Within bodies we can employ the full dyn compat check query instead of only doing the minimal hir ty lowerer one. This in turn gives us better spans and also silences many follow-up duplicate or bogus errors.
alternative to https://github.com/rust-lang/rust/pull/141439, tho I think I could turn the delayed bug from that one into a bug now instead of having an error code path.
r? `@compiler-errors`
cc `@fmease`
dist: make sure llvm-project submodule is present
Zero-config `x install` fails when bootstrap tries to copy files from the LLVM submodule because it's not properly initialized/handled. This diff handles that.
Fixes https://github.com/rust-lang/rust/issues/141393
Remove out-of-date `noop_*` names.
`mut_visit.rs` has a single function with a `noop_` prefix: `noop_filter_map_expr`. This commit renames as `walk_filter_map_expr` which is consistent with other functions in this file.
The commit also removes out-of-date comments that refer to `noop_*` methods.
r? `@petrochenkov`
bootstrap: translate Windows paths in a way that works for both Cygwin and MSYS2
Cygwin defaults to rooting Windows paths in /cygdrive/X, while MSYS2 configures them to be /X. Regardless of configuration, drives are always accessible as /proc/cygdrive/X, so use that.
If there are other shells on Windows that are supported and use /X style paths, perhaps something more complicated needs to be done.
r? `@jieyouxu`
`@Berrysoft` `@mati865`
Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics
This PR improves the `ambiguous_wide_pointer_comparisons` lint compare diagnostics: `cmp`/`partial_cmp`, but also the operators `<`/`>`/`>=`/`<=`, by:
1. removing the reference to `std::ptr::addr_eq` which only works for equality
2. and adding an `#[expect]` suggestion for keeping the current behavior
Fixesrust-lang/rust#141510
Fix CI for unrolled builds on the `try-perf` branch
That branch is essentially the same as the `try` branch, it also needs S3 permissions. While at it, I cleaned up secret loading a bit.
Long term, we should move rollup unrolling from rustc-perf to bors, so that we can have only a single try branch.
The AWS Terraform configuration will also have to be changed to provide the secrets (the `bors` environment) also for the `try-perf` branch.
r? `@marcoieni`
`mut_visit.rs` has a single function with a `noop_` prefix:
`noop_filter_map_expr`. This commit renames as `walk_filter_map_expr`
which is consistent with other functions in this file.
The commit also removes out-of-date comments that refer to `noop_*`
methods.
That branch is essentially the same as the `try` branch, it also needs S3 permissions.
Long term, we should move rollup unrolling from rustc-perf to bors, so that we can have only a single try branch.