Migrate compiletest to use `ui_test`-style `//@` directives
## Preface
There's an on-going effort to rewrite parts of or the entirety of compiletest
(<https://github.com/rust-lang/compiler-team/issues/536>). A step towards this involve migrating
compiletest tests to use the [`ui_test`](https://github.com/oli-obk/ui_test) framework, which
involves changing compiletest directives in `// <directive-name>` style to `ui_test`
`//@ <directive-name>` style (https://github.com/rust-lang/compiler-team/issues/512).
This PR aims to implement the directive-style change from `//` to `//`@`` for the remaining
non-"ui" test suite tests.
## Key Changes
1. All `tests/` tests now use `//`@`` directives.
2. Compiletest only accepts `//`@`` and issues an error if an old-style directive is detected.
3. `// ignore-tidy` and `// ignore-tidy-*` are considered tidy directives and are ignored by
compiletest header parsing.
## Diff Generation
The diff is generated by:
- Collecting directives from `tests/` via hijacking compiletest to emit successfully parsed
directive lines.
- Using a migration tool
(<https://github.com/jieyouxu/compiletest-ui_test-header-migration/tree/master>) to replace
`//` directives in compiletest tests with `//`@`.`
### Reproduction Steps
0. Delete the temporary file `$RUSTC_REPO_PATH/build/<target_triple>/test/__directive_lines.txt`,
if the collection script was previously ran.
1. Use the <https://github.com/jieyouxu/rust/tree/collect-test-directives> collect-test-directives
script, which outputs a temporary file recording headers occuring in each compiletest test.
- You need to checkout this branch: `git checkout collect-test-directives`.
- This needs to be rebased on latest master to ensure up-to-date test directives can be collected.
- You need to run `./x test` on each of the `test/*` subfolders once:
```bash
./x test tests/assembly/ --stage 1 --force-rerun
./x test tests/codegen/ --stage 1 --force-rerun
./x test tests/codegen-units/ --stage 1 --force-rerun
./x test tests/coverage/ --stage 1 --force-rerun
./x test tests/coverage-run-rustdoc/ --stage 1 --force-rerun
./x test tests/debuginfo/ --stage 1 --force-rerun
./x test tests/incremental/ --stage 1 --force-rerun
./x test tests/mir-opt/ --stage 1 --force-rerun
./x test tests/pretty/ --stage 1 --force-rerun
./x test tests/run-make/ --stage 1 --force-rerun
./x test tests/run-make-fulldeps/ --stage 1 --force-rerun
./x test tests/run-pass-valgrind/ --stage 1 --force-rerun
./x test tests/rustdoc/ --stage 1 --force-rerun
TARGET=<target-triple> ./x test tests/rustdoc-gui/ --stage 1 --force-rerun
./x test tests/rustdoc-js/ --stage 1 --force-rerun
./x test tests/rustdoc-js-std/ --stage 1 --force-rerun
./x test tests/rustdoc-json/ --stage 1 --force-rerun
./x test tests/rustdoc-ui/ --stage 1 --force-rerun
./x test tests/ui/ --stage 1 --force-rerun
./x test tests/ui-fulldeps/ --stage 1 --force-rerun
```
2. Checkout the `migrate-compiletest-directives` branch.
3. Run the migration tool <https://github.com/jieyouxu/compiletest-ui_test-header-migration>.
4. Check that the migration at least does not cause test failures if you change compiletest to
accept `//`@`` directives only. This is also required if the test outputs somehow need to be
blessed.
- `RUSTC_TEST_FAIL_FAST=1 ./x test tests/<secondary-directory> --stage 1 --bless`
5. Confirm that there is no difference after running the migration tool when you are on the
`migrate-compiletest-directives` branch.
## Follow Up Work
- [ ] Adjust rustc-dev-guide docs for compiletest directives (this time for all the other suites and modes). <https://github.com/rust-lang/rustc-dev-guide/pull/1895>.
Without doing so we use the same candidate cache entry
for `?0: Trait<?1>` and `?0: Trait<?0>`. These goals are different
and we must not use the same entry for them.
we don't track them when canonicalizing or when freshening,
resulting in instable caching in the old solver, and issues when
instantiating query responses in the new one.
Make `x test tests` work
Fixes#97314
This makes `x test tests` work, and be roughly equivalent to `x test tests/*`. The `--dry-run` output is identical, except for errors on the non-test items in `tests` and a couple of things being in a different order (where path != struct name).
This probably needs a test, but I'm not sure of the best way to do it.
Make intrinsic fallback bodies cross-crate inlineable
This change was prompted by the stage1 compiler spending 4% of its time when compiling the polymorphic-recursion MIR opt test in `unlikely`.
Intrinsic fallback bodies like `unlikely` should always be inlined, it's very silly if they are not. To do this, we enable the fallback bodies to be cross-crate inlineable. Not that this matters for our workloads since the compiler never actually _uses_ the "fallback bodies", it just uses whatever was cfg(bootstrap)ped, so I've also added `#[inline]` to those.
See the comments for more information.
r? oli-obk
Improve codegen diagnostic handling
Clarify the workings of the temporary `Diagnostic` type used to send diagnostics from codegen threads to the main thread.
r? `@estebank`
intrinsics::simd: add missing functions, avoid UB-triggering fast-math
Turns out stdarch declares a bunch more SIMD intrinsics that are still missing from libcore.
I hope I got the docs and in particular the safety requirements right for these "unordered" and "nanless" intrinsics.
Many of these are unused even in stdarch, but they are implemented in the codegen backend, so we may as well list them here.
r? `@Amanieu`
Cc `@calebzulawski` `@workingjubilee`
PR #119097 made the decision to make all `IntoDiagnostic` impls generic,
because this allowed a bunch of nice cleanups. But four hand-written
impls were unintentionally overlooked. This commit makes them generic.
`Rustc::emit_diagnostic` reconstructs a diagnostic passed in from the
macro machinery. Currently it uses the type `DiagnosticBuilder<'_,
ErrorGuaranteed>`, which is incorrect, because the diagnostic might be a
warning. And if it is a warning, because of the `ErrorGuaranteed` we end
up calling into `emit_producing_error_guaranteed` and the assertion
within that function (correctly) fails because the level is not an error
level.
The fix is simple: change the type to `DiagnosticBuilder<'_, ()>`. Using
`()` works no matter what the diagnostic level is, and we don't need an
`ErrorGuaranteed` here.
The panic was reported in #120576.
Remove useless `'static` bounds on `Box` allocator
#79327 added `'static` bounds to the allocator parameter for various `Box` + `Pin` APIs to ensure soundness. But it was a bit overzealous, some of the bounds aren't actually needed.
- Make it more closely match `rustc_errors::Diagnostic`, by making the
field names match, and adding `children`, which requires adding
`rustc_codegen_ssa:🔙:write::Subdiagnostic`.
- Check that we aren't missing important info when converting
diagnostics.
- Add better comments.
- Tweak `rustc_errors::Diagnostic::replace_args` so that we don't need
to do any cloning when converting diagnostics.
First, introduce a typedef `DiagnosticArgMap`.
Second, make the `args` field public, and remove the `args` getter and
`replace_args` setter. These were necessary previously because the getter
had a `#[allow(rustc::potential_query_instability)]` attribute, but that
was removed in #120931 when the args were changed from `FxHashMap` to
`FxIndexMap`. (All the other `Diagnostic` fields are public.)