Skip to content

Commit f460ee4

Browse files
author
The rustc-dev-guide Cronjob Bot
committed
Merge from rustc
2 parents 54b6c39 + 5fcc3ff commit f460ee4

File tree

4 files changed

+61
-29
lines changed

4 files changed

+61
-29
lines changed

Diff for: src/building/optimized-build.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,16 @@ like Python or LLVM.
109109

110110
Here is an example of how can `opt-dist` be used locally (outside of CI):
111111

112-
1. Build the tool with the following command:
112+
1. Enable metrics in your `bootstrap.toml` file, because `opt-dist` expects it to be enabled:
113+
```toml
114+
[build]
115+
metrics = true
116+
```
117+
2. Build the tool with the following command:
113118
```bash
114119
./x build tools/opt-dist
115120
```
116-
2. Run the tool with the `local` mode and provide necessary parameters:
121+
3. Run the tool with the `local` mode and provide necessary parameters:
117122
```bash
118123
./build/host/stage0-tools-bin/opt-dist local \
119124
--target-triple <target> \ # select target, e.g. "x86_64-unknown-linux-gnu"

Diff for: src/solve/opaque-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ For opaque types in the defining scope and in the implicit-negative coherence mo
3333
always done in two steps. Outside of the defining scope `normalizes-to` for opaques always
3434
returns `Err(NoSolution)`.
3535

36-
We start by trying to to assign the expected type as a hidden type.
36+
We start by trying to assign the expected type as a hidden type.
3737

3838
In the implicit-negative coherence mode, this currently always results in ambiguity without
3939
interacting with the opaque types storage. We could instead add allow 'defining' all opaque types,

Diff for: src/tests/directives.md

+15-9
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ for more details.
101101
| `normalize-stdout` | Normalize actual stdout with a rule `"<raw>" -> "<normalized>"` before comparing against snapshot | `ui`, `incremental` | `"<RAW>" -> "<NORMALIZED>"`, `<RAW>`/`<NORMALIZED>` is regex capture and replace syntax |
102102
| `dont-check-compiler-stderr` | Don't check actual compiler stderr vs stderr snapshot | `ui` | N/A |
103103
| `dont-check-compiler-stdout` | Don't check actual compiler stdout vs stdout snapshot | `ui` | N/A |
104+
| `dont-require-annotations` | Don't require line annotations for the given diagnostic kind (`//~ KIND`) to be exhaustive | `ui`, `incremental` | `ERROR`, `WARN`, `NOTE`, `HELP`, `SUGGESTION` |
104105
| `run-rustfix` | Apply all suggestions via `rustfix`, snapshot fixed output, and check fixed output builds | `ui` | N/A |
105106
| `rustfix-only-machine-applicable` | `run-rustfix` but only machine-applicable suggestions | `ui` | N/A |
106107
| `exec-env` | Env var to set when executing a test | `ui`, `crashes` | `<KEY>=<VALUE>` |
@@ -191,8 +192,13 @@ settings:
191192
specified atomic widths, e.g. the test with `//@ needs-target-has-atomic: 8,
192193
16, ptr` will only run if it supports the comma-separated list of atomic
193194
widths.
194-
- `needs-dynamic-linking` - ignores if target does not support dynamic linking
195+
- `needs-dynamic-linking` ignores if target does not support dynamic linking
195196
(which is orthogonal to it being unable to create `dylib` and `cdylib` crate types)
197+
- `needs-crate-type` — ignores if target platform does not support one or more
198+
of the comma-delimited list of specified crate types. For example,
199+
`//@ needs-crate-type: cdylib, proc-macro` will cause the test to be ignored
200+
on `wasm32-unknown-unknown` target because the target does not support the
201+
`proc-macro` crate type.
196202

197203
The following directives will check LLVM support:
198204

@@ -229,14 +235,14 @@ ignoring debuggers.
229235

230236
### Affecting how tests are built
231237

232-
| Directive | Explanation | Supported test suites | Possible values |
233-
|---------------------|----------------------------------------------------------------------------------------------|---------------------------|------------------------------------------------------------------------------|
234-
| `compile-flags` | Flags passed to `rustc` when building the test or aux file | All except for `run-make` | Any valid `rustc` flags, e.g. `-Awarnings -Dfoo`. Cannot be `-Cincremental`. |
235-
| `edition` | Alias for `compile-flags: --edition=xxx` | All except for `run-make` | Any valid `--edition` value |
236-
| `rustc-env` | Env var to set when running `rustc` | All except for `run-make` | `<KEY>=<VALUE>` |
237-
| `unset-rustc-env` | Env var to unset when running `rustc` | All except for `run-make` | Any env var name |
238-
| `incremental` | Proper incremental support for tests outside of incremental test suite | `ui`, `crashes` | N/A |
239-
| `no-prefer-dynamic` | Don't use `-C prefer-dynamic`, don't build as a dylib via a `--crate-type=dylib` preset flag | `ui`, `crashes` | N/A |
238+
| Directive | Explanation | Supported test suites | Possible values |
239+
|---------------------|----------------------------------------------------------------------------------------------|---------------------------|--------------------------------------------------------------------------------------------|
240+
| `compile-flags` | Flags passed to `rustc` when building the test or aux file | All except for `run-make` | Any valid `rustc` flags, e.g. `-Awarnings -Dfoo`. Cannot be `-Cincremental` or `--edition` |
241+
| `edition` | The edition used to build the test | All except for `run-make` | Any valid `--edition` value |
242+
| `rustc-env` | Env var to set when running `rustc` | All except for `run-make` | `<KEY>=<VALUE>` |
243+
| `unset-rustc-env` | Env var to unset when running `rustc` | All except for `run-make` | Any env var name |
244+
| `incremental` | Proper incremental support for tests outside of incremental test suite | `ui`, `crashes` | N/A |
245+
| `no-prefer-dynamic` | Don't use `-C prefer-dynamic`, don't build as a dylib via a `--crate-type=dylib` preset flag | `ui`, `crashes` | N/A |
240246

241247
<div class="warning">
242248
Tests (outside of `run-make`) that want to use incremental tests not in the

Diff for: src/tests/ui.md

+38-17
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ It should be preferred to using `error-pattern`, which is imprecise and non-exha
303303
### `error-pattern`
304304

305305
The `error-pattern` [directive](directives.md) can be used for runtime messages, which don't
306-
have a specific span, or for compile time messages if imprecise matching is required due to
307-
multi-line platform specific diagnostics.
306+
have a specific span, or in exceptional cases for compile time messages.
308307

309308
Let's think about this test:
310309

@@ -318,7 +317,7 @@ fn main() {
318317
```
319318

320319
We want to ensure this shows "index out of bounds" but we cannot use the `ERROR`
321-
annotation since the error doesn't have any span. Then it's time to use the
320+
annotation since the runtime error doesn't have any span. Then it's time to use the
322321
`error-pattern` directive:
323322

324323
```rust,ignore
@@ -331,29 +330,51 @@ fn main() {
331330
}
332331
```
333332

334-
But for strict testing, try to use the `ERROR` annotation as much as possible,
335-
including `//~?` annotations for diagnostics without span.
336-
For compile time diagnostics `error-pattern` should very rarely be necessary.
333+
Use of `error-pattern` is not recommended in general.
337334

338-
Per-line annotations (`//~`) are still checked in tests using `error-pattern`.
339-
To opt out of these checks, use `//@ compile-flags: --error-format=human`.
340-
Do that only in exceptional cases.
335+
For strict testing of compile time output, try to use the line annotations `//~` as much as
336+
possible, including `//~?` annotations for diagnostics without span.
341337

342-
### Error levels
338+
If the compile time output is target dependent or too verbose, use directive
339+
`//@ dont-require-annotations: <diagnostic-kind>` to make the line annotation checking
340+
non-exhaustive, some of the compiler messages can stay uncovered by annotations in this mode.
343341

344-
The error levels that you can have are:
342+
For checking runtime output `//@ check-run-results` may be preferable.
343+
344+
Only use `error-pattern` if none of the above works.
345+
346+
Line annotations `//~` are still checked in tests using `error-pattern`.
347+
In exceptional cases use `//@ compile-flags: --error-format=human` to opt out of these checks.
348+
349+
### Diagnostic kinds (error levels)
350+
351+
The diagnostic kinds that you can have are:
345352

346353
- `ERROR`
347-
- `WARN` or `WARNING`
354+
- `WARN` (or `WARNING`)
348355
- `NOTE`
349-
- `HELP` and `SUGGESTION`
350-
351-
You are allowed to not include a level, but you should include it at least for
352-
the primary message.
356+
- `HELP`
357+
- `SUGGESTION`
353358

354-
The `SUGGESTION` level is used for specifying what the expected replacement text
359+
The `SUGGESTION` kind is used for specifying what the expected replacement text
355360
should be for a diagnostic suggestion.
356361

362+
`ERROR` and `WARN` kinds are required to be exhaustively covered by line annotations
363+
`//~` by default.
364+
365+
Other kinds only need to be line-annotated if at least one annotation of that kind appears
366+
in the test file. For example, one `//~ NOTE` will also require all other `//~ NOTE`s in the file
367+
to be written out explicitly.
368+
369+
Use directive `//@ dont-require-annotations` to opt out of exhaustive annotations.
370+
E.g. use `//@ dont-require-annotations: NOTE` to annotate notes selectively.
371+
Avoid using this directive for `ERROR`s and `WARN`ings, unless there's a serious reason, like
372+
target-dependent compiler output.
373+
374+
Missing diagnostic kinds (`//~ message`) are currently accepted, but are being phased away.
375+
They will match any compiler output kind, but will not force exhaustive annotations for that kind.
376+
Prefer explicit kind and `//@ dont-require-annotations` to achieve the same effect.
377+
357378
UI tests use the `-A unused` flag by default to ignore all unused warnings, as
358379
unused warnings are usually not the focus of a test. However, simple code
359380
samples often have unused warnings. If the test is specifically testing an

0 commit comments

Comments
 (0)