Skip to content

Commit 6442054

Browse files
committed
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
2 parents fb2f5df + 6bf536d commit 6442054

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/conventions.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This file offers some tips on the coding conventions for rustc. This
1+
This file offers some tips on the coding conventions for rustc. This
22
chapter covers [formatting](#formatting), [coding for correctness](#cc),
33
[using crates from crates.io](#cio), and some tips on
44
[structuring your PR for easy review](#er).
@@ -25,6 +25,7 @@ pass the <!-- date-check: nov 2022 --> `--edition=2021` argument yourself when c
2525
`rustfmt` directly.
2626

2727
[fmt]: https://github.com/rust-dev-tools/fmt-rfcs
28+
2829
[`rustfmt`]:https://github.com/rust-lang/rustfmt
2930

3031
## Formatting C++ code
@@ -40,6 +41,26 @@ When modifying that code, use this command to format it:
4041
This uses a pinned version of `clang-format`, to avoid relying on the local
4142
environment.
4243

44+
## Formatting and linting Python code
45+
46+
The Rust repository contains quite a lof of Python code. We try to keep
47+
it both linted and formatted by the [ruff][ruff] tool.
48+
49+
When modifying Python code, use this command to format it:
50+
```sh
51+
./x test tidy --extra-checks=py:fmt --bless
52+
```
53+
54+
and the following command to run lints:
55+
```sh
56+
./x test tidy --extra-checks=py:lint
57+
```
58+
59+
This uses a pinned version of `ruff`, to avoid relying on the local
60+
environment.
61+
62+
[ruff]: https://github.com/astral-sh/ruff
63+
4364
<a id="copyright"></a>
4465

4566
<!-- REUSE-IgnoreStart -->
@@ -84,7 +105,7 @@ Using `_` in a match is convenient, but it means that when new
84105
variants are added to the enum, they may not get handled correctly.
85106
Ask yourself: if a new variant were added to this enum, what's the
86107
chance that it would want to use the `_` code, versus having some
87-
other treatment? Unless the answer is "low", then prefer an
108+
other treatment? Unless the answer is "low", then prefer an
88109
exhaustive match. (The same advice applies to `if let` and `while
89110
let`, which are effectively tests for a single variant.)
90111

@@ -124,7 +145,7 @@ See the [crates.io dependencies][crates] section.
124145
# How to structure your PR
125146

126147
How you prepare the commits in your PR can make a big difference for the
127-
reviewer. Here are some tips.
148+
reviewer. Here are some tips.
128149

129150
**Isolate "pure refactorings" into their own commit.** For example, if
130151
you rename a method, then put that rename into its own commit, along
@@ -165,4 +186,5 @@ to the compiler.
165186
crate-related, often the spelling is changed to `krate`.
166187

167188
[tcx]: ./ty.md
189+
168190
[crates]: ./crates-io.md

src/tests/directives.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ for more details.
9494
| Directive | Explanation | Supported test suites | Possible values |
9595
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|-----------------------------------------------------------------------------------------|
9696
| `check-run-results` | Check run test binary `run-{pass,fail}` output snapshot | `ui`, `crashes`, `incremental` if `run-pass` | N/A |
97-
| `error-pattern` | Check that output contains a specific string | `ui`, `crashes`, `incremental` if `run-pass` | String |
97+
| `error-pattern` | Check that output contains a specific string | `ui`, `crashes`, `incremental` if `run-pass` | String |
9898
| `regex-error-pattern` | Check that output contains a regex pattern | `ui`, `crashes`, `incremental` if `run-pass` | Regex |
9999
| `check-stdout` | Check `stdout` against `error-pattern`s from running test binary[^check_stdout] | `ui`, `crashes`, `incremental` | N/A |
100100
| `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:
176176
- `needs-rust-lld` — ignores if the rust lld support is not enabled (`rust.lld =
177177
true` in `config.toml`)
178178
- `needs-threads` — ignores if the target does not have threading support
179+
- `needs-subprocess` — ignores if the target does not have subprocess support
179180
- `needs-symlink` — ignores if the target does not support symlinks. This can be
180181
the case on Windows if the developer did not enable privileged symlink
181182
permissions.

0 commit comments

Comments
 (0)