Inline `FnOnce`/`FnMut`/`Fn` shims once again
This PR fixes the argument checking for `extern "rust-call"` ABI functions with a spread arg, which do no expect their arguments to be exploded from a tuple like closures do.
Secondly, it removes the hack that prevented them from being inlined. This results in more work done by the compiler, but it does end up allowing us to inline functions we didn't before.
Fixes#137901
Rollup of 20 pull requests
Successful merges:
- #134063 (dec2flt: Clean up float parsing modules)
- #136581 (Retire the legacy `Makefile`-based `run-make` test infra)
- #136662 (Count char width at most once in `Formatter::pad`)
- #136764 (Make `ptr_cast_add_auto_to_object` lint into hard error)
- #136798 (Added documentation for flushing per #74348)
- #136865 (Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes)
- #136975 (Look for `python3` first on MacOS, not `py`)
- #136977 (Upload Datadog metrics with citool)
- #137240 (Slightly reformat `std::fs::remove_dir_all` error docs)
- #137298 (Check signature WF when lowering MIR body)
- #137463 ([illumos] attempt to use posix_spawn to spawn processes)
- #137477 (uefi: Add Service Binding Protocol abstraction)
- #137569 (Stabilize `string_extend_from_within`)
- #137633 (Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack)
- #137679 (Various coretests improvements)
- #137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`)
- #137728 (Remove unsizing coercions for tuples)
- #137731 (Resume one waiter at once in deadlock handler)
- #137875 (mir_build: Integrate "simplification" steps into match-pair-tree creation)
- #138028 (compiler: add `ExternAbi::is_rustic_abi`)
r? `@ghost`
`@rustbot` modify labels: rollup
compiler: add `ExternAbi::is_rustic_abi`
Various parts of the compiler were hand-rolling this extremely simple check that is nonetheless easy to get wrong as the compiler evolves over time. Discourage them from being so "original" again by replacing it with a single implementation on the type that represents these ABIs. This simplifies a surprising amount of code as a result.
Also fixes#132981, an ICE that emerged due to other checks being made stricter.
mir_build: Integrate "simplification" steps into match-pair-tree creation
The “simplification” step helps to prepare THIR patterns for lowering into MIR, and originally dates back to the earliest days of MIR in the compiler.
Over time, various intermediate data structures have been introduced (e.g. `MatchPair`, later renamed to `MatchPairTree`) that reduce the need for a separate simplification step, because some of the necessary simplifications can be built into the construction of those intermediate structures instead. This PR continues that process to its logical conclusion and removes the simplification step entirely, by integrating its remaining responsibilities into match-pair-tree creation: flattening “irrefutable” nodes, collecting bindings/ascriptions in flat lists, and sorting or-patterns after other subpatterns.
This has a few immediate benefits:
- We can remove `TestCase::Irrefutable`, which was not allowed to exist after simplification, and was much larger than other test-case variants.
- We can make `MatchPairTree::place` non-optional, because only irrefutable nodes could fail to have a place.
In the future, this should also help with some ideas I have for simplifying how `AscribeUserType` and `ExpandedConstant` nodes are handled, by representing them as side-data keyed by THIR pattern ID, so that they are no longer their own kinds of THIR pattern node.
Resume one waiter at once in deadlock handler
When multiple query loop errors occur in the code, only one waiter should be resumed at a time to avoid waking up multiple waiters at the same time and causing deadlock due to thread grabbing.
This fixes the UI failures in #132051
cc `@Zoxc` `@cjgillot` `@nnethercote` `@bjorn3` `@Kobzol`
Zulip discussion [here](https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fwg-parallel-rustc/topic/Deadlocks.20and.20Rayon)
Edit: We can't reproduce these bugs with the existing test suits, so we keep them until we merge #132051
UPDATES #129912
UPDATES #120757
UPDATES #129911
Various coretests improvements
The first commit is not yet strictly necessary as directly testing libcore works though useless work, but will be necessary once https://github.com/rust-lang/rust/pull/136642 migrates the liballoc tests into a separate package. The second commit fixes https://github.com/rust-lang/rust/issues/137478 and ensures that coretests actually gets tested on all CI job. The third commit fixes an error that didn't get caught because coretests doesn't run on the wasm32 CI job.
Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack
Consolidates the implied bounds computation mode into a single function, which deeply normalizes, and if it's in **compat** mode (for bevy), it extracts outlives bounds from the infcx.
Previously, we were using the implied bounds compat mode in two cases:
1. During WF, if it detects `ParamSet`
2. EVERYWHERE ELSE (lol) -- e.g. borrowck, predicate entailment, etc.
While I think this is fine, and the net effect was just that we emitted fewer diagnostics, it makes me uncomfortable that all crates were using the supposed "compat" code.
Fixes#137767
uefi: Add Service Binding Protocol abstraction
- Some UEFI protocols such as TCP4, TCP6, UDP4, UDP6, etc are managed by service binding protocol.
- A new instance of such protocols is created and destroyed using the corresponding service binding protocol.
- This PR adds abstractions to make using such protocols simpler using Rust Drop trait.
- The reason to add these abstractions in a seperate PR from TCP4 Protocol is to make review easier.
[EFI_SERVICE_BINDING_PROTCOL](https://uefi.org/specs/UEFI/2.11/11_Protocols_UEFI_Driver_Model.html#efi-service-binding-protocol)
cc ````@nicholasbishop````
[illumos] attempt to use posix_spawn to spawn processes
illumos has `posix_spawn`, and the very newest versions also have `_addchdir`, so use that. POSIX standardized this function so I also added a weak symbol lookup for the non `_np` version. (illumos has both.)
This probably also works on Solaris, but I don't have access to an installation to validate this so I decided to focus on illumos instead.
This is a nice ~4x performance improvement for process creation. My go-to as usual is nextest against the clap repo, which acts as a stress test for process creation -- with [this commit]:
```console
$ cargo nextest run -E 'not test(ui_tests) and not test(example_tests)'
before: Summary [ 1.747s] 879 tests run: 879 passed, 2 skipped
after: Summary [ 0.445s] 879 tests run: 879 passed, 2 skipped
```
[this commit]: fde45f9aea
Slightly reformat `std::fs::remove_dir_all` error docs
To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀
cc #137230.
Upload Datadog metrics with citool
This removes one Python script and also the installation of the `datadog-ci` JavaScript package, along with the corresponding package and lock file.
r? `@ghost`
Look for `python3` first on MacOS, not `py`
`py` is not installed by default *and* trying to run it results in a popup asking if you want to install it. `python3` is installed by default.
This hopefully should not be too disruptive to people on Windows, since they should be going through `x.ps1` instead anyway. Just in case, I've added a check for Cygwin and Msys (i'm not sure how else you'd get a bash shell on windows).
I've tested this on macOS, WSL, "git bash" (which appears to be MSYS), and MSVC with `bash -c ./x` (which runs in WSL, but differently than interactive bash 🙃). I haven't tested Cygwin, which is unsupported anyway, but the code tries to make it work.
Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes
Fixes#136510.
### Summary
- Whereas previously `$TEST_BUILD_DIR` is a normalization of `/path/to/build/test/<test_suite_name>/`, we now more deeply normalize. `$TEST_BUILD_DIR` now becomes a normalization of `/path/to/build/test/<test_suite_name>/<subdirs>/$name.$revision.$compare_mode.$debugger/` to normalize away path name differences when `--compare-mode` and/or `--debugger` are specified.
- We also centralize the normalization of long type name hashes
cf. https://github.com/rust-lang/rust/pull/136328#discussion_r1936760908.
### Review advice
- Best reviewed commit-by-commit.
- Split into 3 commits:
- **Commit 1**: compiletest changes to have `$TEST_BUILD_DIR` more deeply normalize.
- **Commit 2**: remove per-test hacks for long type path hash normalizations, and rebless tests *specifically* affected by that.
- **Commit 3**: rebless other tests that were changed as a side-effect of deeper `$TEST_BUILD_DIR` normalizations.
**Commit 2** is created via first finding tests that try to perform long type file hash normalizations on an ad hoc, per-test basis:
```
rg --no-ignore -l --no-ignore -F -e "long-type" tests/ui/**/*.rs
```
<details>
<summary>Tests with ad hoc long-type hash normalizations</summary>
```
tests/ui/type_length_limit.rs
tests/ui/traits/on_unimplemented_long_types.rs
tests/ui/regions/issue-102374.rs
tests/ui/recursion/recursion.rs
tests/ui/recursion/issue-83150.rs
tests/ui/recursion/issue-23122-2.rs
tests/ui/methods/inherent-bound-in-probe.rs
tests/ui/issues/issue-67552.rs
tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs
tests/ui/issues/issue-20413.rs
tests/ui/issues/issue-8727.rs
tests/ui/infinite/infinite-instantiation.rs
tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs
tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.rs
tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs
tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.rs
tests/ui/error-codes/E0275.rs
tests/ui/diagnostic-width/secondary-label-with-long-type.rs
tests/ui/diagnostic-width/long-e0277.rs
tests/ui/diagnostic-width/non-copy-type-moved.rs
tests/ui/diagnostic-width/long-E0308.rs
tests/ui/diagnostic-width/E0271.rs
tests/ui/diagnostic-width/binop.rs
```
</details>
These ad hoc normalizations were removed, and they are reblessed.
r? `````@lqd`````
Make `ptr_cast_add_auto_to_object` lint into hard error
In Rust 1.81, we added a FCW lint (including linting in dependencies) against pointer casts that add an auto trait to dyn bounds. This was part of work making casts of pointers involving trait objects stricter, and was part of the work needed to restabilize trait upcasting.
We considered just making this a hard error, but opted against it at that time due to breakage found by crater. This breakage was mostly due to the `anymap` crate which has been a persistent problem for us.
It's now a year later, and the fact that this is not yet a hard error is giving us pause about stabilizing arbitrary self types and `derive(CoercePointee)`. So let's see about making a hard error of this.
r? ghost
cc ```@adetaylor``` ```@Darksonn``` ```@BoxyUwU``` ```@RalfJung``` ```@compiler-errors``` ```@oli-obk``` ```@WaffleLapkin```
Related:
- https://github.com/rust-lang/rust/pull/135881
- https://github.com/rust-lang/rust/issues/136702
- https://github.com/rust-lang/rust/pull/136776
Tracking:
- https://github.com/rust-lang/rust/issues/127323
- https://github.com/rust-lang/rust/issues/44874
- https://github.com/rust-lang/rust/issues/123430
Count char width at most once in `Formatter::pad`
When both width and precision flags are specified, then `Formatter::pad` counts the character width twice. Instead, record the character width when truncating it to the precision, so it does not need to be recomputed. Simplify control flow so the cases are more clear.
Related:
- 6c9e708f4b (`fmt::Formatter::pad`: don't call chars().count() more than one time, 2021-09-01): Reduce counting chars from thrice to twice in worst case
- ede39aeb33 (feat: reinterpret `precision` field for strings, 2016-06-29): Change meaning of precision for strings
- b820748ff5 (Implement formatting arguments for strings and integers, 2013-08-10): Implement `Formatter::pad`
Retire the legacy `Makefile`-based `run-make` test infra
The final piece of [porting run-make tests to use Rust #121876](https://github.com/rust-lang/rust/issues/121876).
Closes#121876.
Closes#40713.
Closes#81791 (no longer using `wc`).
Closes#56475 (no longer a problem in current form of that test; we don't ignore the test on `aarch64-unknown-linux-gnu`).
### Summary
This PR removes the legacy `Makefile`-based `run-make` test infra which has served us well over the years. The legacy infra is no longer needed since we ported all of `Makefile`-based `run-make` tests to the new `rmake.rs` infra.
Additionally, this PR:
- Removes `tests/run-make/tools.mk` since no more `Makefile`-based tests remain.
- Updates `tests/run-make/README.md` and rustc-dev-guide docs to remove mention about `Makefile`-based `run-make` tests
- Update test suite requirements in rustc-dev-guide on Windows to no longer need MSYS2 (they should also now run successfully on native Windows MSVC).
- Update `triagebot.toml` to stop backlinking to #121876.
**Thanks to everyone who helped in this effort to modernize the `run-make` test infra and test suite!**
r? bootstrap
dec2flt: Clean up float parsing modules
This is the first portion of my work adding support for parsing and printing `f16`. Changes in `float.rs` replace the magic constants with expressions and add some use of generics to better support the new float types. Everything else is related to documentation or naming; there are no functional changes in this PR.
This can be reviewed by commit.
Make CrateItem::body() function return an option
When we initially created `CrateItem`, it would only represent items that contain a body.
That is no longer the case, for now, make this explicit by expanding the APIs to retrieve the item body.
This is related to https://github.com/rust-lang/project-stable-mir/issues/34
r? `@oli-obk`
Pretty-print `#[deprecated]` attribute in HIR.
Pretty-print `#[deprecated]` attribute in a form closer to how it might appear in Rust source code, rather than using a `Debug`-like representation.
Consider the following Rust code:
```rust
#[deprecated]
pub struct PlainDeprecated;
#[deprecated = "here's why this is deprecated"]
pub struct DirectNote;
#[deprecated(since = "1.2.3", note = "here's why this is deprecated")]
pub struct SinceAndNote;
```
Here's the previous output:
```
#[attr="Deprecation{deprecation: Deprecation{since: Unspecifiednote:
suggestion: }span: }")]
struct PlainDeprecated;
#[attr="Deprecation{deprecation: Deprecation{since: Unspecifiednote:
here's why this is deprecatedsuggestion: }span: }")]
struct DirectNote;
#[attr="Deprecation{deprecation: Deprecation{since: NonStandard(1.2.3)note:
here's why this is deprecatedsuggestion: }span: }")]
struct SinceAndNote;
```
Here's the new output:
```rust
#[deprecated]
struct PlainDeprecated;
#[deprecated = "here's why this is deprecated"]
struct DirectNote;
#[deprecated(since = "1.2.3", note = "here's why this is deprecated"]
struct SinceAndNote;
```
Also includes a test for `#[diagnostic::(..)]` attributes, though their behavior is not changed here. I already wrote the test, so I figured it probably won't hurt to have it.
Related to discussion in #137645.
r? `@jdonszelmann`
rustdoc search: increase strictness of typechecking
r? `@notriddle`
The signature of `makePrimitiveElement` is now more accurate.
I believe the intent of the code is that `name` cannot be null if `bindingName.name` is null, and I believe typescript is expressive enough to encode this, but I'm not quite sure how, or if this would be desirable.
I'm also introducing mapped types into `rustdoc.d.ts`, but I think it's worth it in order to avoid keeping two interfaces in sync.
I may add more commits onto this to remove more ``@ts-expect-error`` instances.
Remove unused `PpMode::needs_hir`
This method was added in #99360 to avoid an overzealous `span_delayed_bug` ICE in specific circumstances, but the only caller was subsequently removed in #136603, which presumably avoids the problem in a more principled way.