Auto merge of #136000 - matthiaskrgr:rollup-j6ge32r, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #135873 (coverage: Prepare for upcoming changes to counter creation)
 - #135926 (Implement `needs-subprocess` directive, and cleanup a bunch of tests to use `needs-{subprocess,threads}`)
 - #135950 (Tidy Python improvements)
 - #135956 (Make `Vec::pop_if` a bit more presentable)
 - #135966 ([AIX] Allow different sized load and store in `tests/assembly/powerpc64-struct-abi.rs`)
 - #135983 (Doc difference between extend and extend_from_slice)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-24 19:04:36 +00:00
commit 6442054ed1
2 changed files with 27 additions and 4 deletions

View File

@ -1,4 +1,4 @@
This file offers some tips on the coding conventions for rustc. This This file offers some tips on the coding conventions for rustc. This
chapter covers [formatting](#formatting), [coding for correctness](#cc), chapter covers [formatting](#formatting), [coding for correctness](#cc),
[using crates from crates.io](#cio), and some tips on [using crates from crates.io](#cio), and some tips on
[structuring your PR for easy review](#er). [structuring your PR for easy review](#er).
@ -25,6 +25,7 @@ pass the <!-- date-check: nov 2022 --> `--edition=2021` argument yourself when c
`rustfmt` directly. `rustfmt` directly.
[fmt]: https://github.com/rust-dev-tools/fmt-rfcs [fmt]: https://github.com/rust-dev-tools/fmt-rfcs
[`rustfmt`]:https://github.com/rust-lang/rustfmt [`rustfmt`]:https://github.com/rust-lang/rustfmt
## Formatting C++ code ## Formatting C++ code
@ -40,6 +41,26 @@ When modifying that code, use this command to format it:
This uses a pinned version of `clang-format`, to avoid relying on the local This uses a pinned version of `clang-format`, to avoid relying on the local
environment. environment.
## Formatting and linting Python code
The Rust repository contains quite a lof of Python code. We try to keep
it both linted and formatted by the [ruff][ruff] tool.
When modifying Python code, use this command to format it:
```sh
./x test tidy --extra-checks=py:fmt --bless
```
and the following command to run lints:
```sh
./x test tidy --extra-checks=py:lint
```
This uses a pinned version of `ruff`, to avoid relying on the local
environment.
[ruff]: https://github.com/astral-sh/ruff
<a id="copyright"></a> <a id="copyright"></a>
<!-- REUSE-IgnoreStart --> <!-- REUSE-IgnoreStart -->
@ -84,7 +105,7 @@ Using `_` in a match is convenient, but it means that when new
variants are added to the enum, they may not get handled correctly. variants are added to the enum, they may not get handled correctly.
Ask yourself: if a new variant were added to this enum, what's the Ask yourself: if a new variant were added to this enum, what's the
chance that it would want to use the `_` code, versus having some chance that it would want to use the `_` code, versus having some
other treatment? Unless the answer is "low", then prefer an other treatment? Unless the answer is "low", then prefer an
exhaustive match. (The same advice applies to `if let` and `while exhaustive match. (The same advice applies to `if let` and `while
let`, which are effectively tests for a single variant.) let`, which are effectively tests for a single variant.)
@ -124,7 +145,7 @@ See the [crates.io dependencies][crates] section.
# How to structure your PR # How to structure your PR
How you prepare the commits in your PR can make a big difference for the How you prepare the commits in your PR can make a big difference for the
reviewer. Here are some tips. reviewer. Here are some tips.
**Isolate "pure refactorings" into their own commit.** For example, if **Isolate "pure refactorings" into their own commit.** For example, if
you rename a method, then put that rename into its own commit, along you rename a method, then put that rename into its own commit, along
@ -165,4 +186,5 @@ to the compiler.
crate-related, often the spelling is changed to `krate`. crate-related, often the spelling is changed to `krate`.
[tcx]: ./ty.md [tcx]: ./ty.md
[crates]: ./crates-io.md [crates]: ./crates-io.md

View File

@ -94,7 +94,7 @@ for more details.
| Directive | Explanation | Supported test suites | Possible values | | Directive | Explanation | Supported test suites | Possible values |
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|-----------------------------------------------------------------------------------------| |-----------------------------------|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|-----------------------------------------------------------------------------------------|
| `check-run-results` | Check run test binary `run-{pass,fail}` output snapshot | `ui`, `crashes`, `incremental` if `run-pass` | N/A | | `check-run-results` | Check run test binary `run-{pass,fail}` output snapshot | `ui`, `crashes`, `incremental` if `run-pass` | N/A |
| `error-pattern` | Check that output contains a specific string | `ui`, `crashes`, `incremental` if `run-pass` | String | | `error-pattern` | Check that output contains a specific string | `ui`, `crashes`, `incremental` if `run-pass` | String |
| `regex-error-pattern` | Check that output contains a regex pattern | `ui`, `crashes`, `incremental` if `run-pass` | Regex | | `regex-error-pattern` | Check that output contains a regex pattern | `ui`, `crashes`, `incremental` if `run-pass` | Regex |
| `check-stdout` | Check `stdout` against `error-pattern`s from running test binary[^check_stdout] | `ui`, `crashes`, `incremental` | N/A | | `check-stdout` | Check `stdout` against `error-pattern`s from running test binary[^check_stdout] | `ui`, `crashes`, `incremental` | N/A |
| `normalize-stderr-32bit` | Normalize actual stderr (for 32-bit platforms) with a rule `"<raw>" -> "<normalized>"` before comparing against snapshot | `ui`, `incremental` | `"<RAW>" -> "<NORMALIZED>"`, `<RAW>`/`<NORMALIZED>` is regex capture and replace syntax | | `normalize-stderr-32bit` | Normalize actual stderr (for 32-bit platforms) with a rule `"<raw>" -> "<normalized>"` before comparing against snapshot | `ui`, `incremental` | `"<RAW>" -> "<NORMALIZED>"`, `<RAW>`/`<NORMALIZED>` is regex capture and replace syntax |
@ -176,6 +176,7 @@ settings:
- `needs-rust-lld` — ignores if the rust lld support is not enabled (`rust.lld = - `needs-rust-lld` — ignores if the rust lld support is not enabled (`rust.lld =
true` in `config.toml`) true` in `config.toml`)
- `needs-threads` — ignores if the target does not have threading support - `needs-threads` — ignores if the target does not have threading support
- `needs-subprocess` — ignores if the target does not have subprocess support
- `needs-symlink` — ignores if the target does not support symlinks. This can be - `needs-symlink` — ignores if the target does not support symlinks. This can be
the case on Windows if the developer did not enable privileged symlink the case on Windows if the developer did not enable privileged symlink
permissions. permissions.