Skip to content

Commit a08bcca

Browse files
authored
Merge pull request #2347 from rust-lang/rustc-pull
Rustc pull update
2 parents 1fdfd58 + 3a23ec2 commit a08bcca

File tree

10 files changed

+92
-60
lines changed

10 files changed

+92
-60
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
25a615bf829b9f6d6f22da537e3851043f92e5f2
1+
a7c39b68616668a45f0afd62849a1da7c8ad2516

src/appendix/glossary.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Term | Meaning
3131
<span id="generics">generics</span> | The list of generic parameters defined on an item. There are three kinds of generic parameters: Type, lifetime and const parameters.
3232
<span id="hir">HIR</span> | The _high-level [IR](#ir)_, created by lowering and desugaring the AST. ([see more](../hir.md))
3333
<span id="hir-id">`HirId`</span> | Identifies a particular node in the HIR by combining a def-id with an "intra-definition offset". See [the HIR chapter for more](../hir.md#identifiers-in-the-hir).
34-
<span id="hir-map">HIR map</span> | The HIR map, accessible via `tcx.hir()`, allows you to quickly navigate the HIR and convert between various forms of identifiers.
3534
<span id="ice">ICE</span> | Short for _internal compiler error_, this is when the compiler crashes.
3635
<span id="ich">ICH</span> | Short for _incremental compilation hash_, these are used as fingerprints for things such as HIR and crate metadata, to check if changes have been made. This is useful in incremental compilation to see if part of a crate has changed and should be recompiled.
3736
<span id="infcx">`infcx`</span> | The type inference context (`InferCtxt`). (see `rustc_middle::infer`)

src/building/optimized-build.md

Lines changed: 7 additions & 2 deletions
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"

src/compiler-debugging.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ Right below you can find elaborate explainers on a selected few.
301301

302302
Some compiler options for debugging specific features yield graphviz graphs -
303303
e.g. the `#[rustc_mir(borrowck_graphviz_postflow="suffix.dot")]` attribute
304-
dumps various borrow-checker dataflow graphs.
304+
on a function dumps various borrow-checker dataflow graphs in conjunction with
305+
`-Zdump-mir-dataflow`.
305306

306307
These all produce `.dot` files. To view these files, install graphviz (e.g.
307308
`apt-get install graphviz`) and then run the following commands:

src/hir.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ The HIR uses a bunch of different identifiers that coexist and serve different p
100100
a wrapper around a [`HirId`]. For more info about HIR bodies, please refer to the
101101
[HIR chapter][hir-bodies].
102102

103-
These identifiers can be converted into one another through the [HIR map][map].
103+
These identifiers can be converted into one another through the `TyCtxt`.
104104

105105
[`DefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html
106106
[`LocalDefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.LocalDefId.html
@@ -110,30 +110,24 @@ These identifiers can be converted into one another through the [HIR map][map].
110110
[`CrateNum`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.CrateNum.html
111111
[`DefIndex`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefIndex.html
112112
[`Body`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Body.html
113-
[hir-map]: ./hir.md#the-hir-map
114113
[hir-bodies]: ./hir.md#hir-bodies
115-
[map]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html
116114

117-
## The HIR Map
115+
## HIR Operations
118116

119117
Most of the time when you are working with the HIR, you will do so via
120-
the **HIR Map**, accessible in the tcx via [`tcx.hir()`] (and defined in
121-
the [`hir::map`] module). The [HIR map] contains a [number of methods] to
122-
convert between IDs of various kinds and to lookup data associated
123-
with a HIR node.
118+
`TyCtxt`. It contains a number of methods, defined in the `hir::map` module and
119+
mostly prefixed with `hir_`, to convert between IDs of various kinds and to
120+
lookup data associated with a HIR node.
124121

125-
[`tcx.hir()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir
126-
[`hir::map`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/index.html
127-
[HIR map]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html
128-
[number of methods]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#methods
122+
[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html
129123

130124
For example, if you have a [`LocalDefId`], and you would like to convert it
131-
to a [`HirId`], you can use [`tcx.hir().local_def_id_to_hir_id(def_id)`][local_def_id_to_hir_id].
125+
to a [`HirId`], you can use [`tcx.local_def_id_to_hir_id(def_id)`][local_def_id_to_hir_id].
132126
You need a `LocalDefId`, rather than a `DefId`, since only local items have HIR nodes.
133127

134-
[local_def_id_to_hir_id]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.local_def_id_to_hir_id
128+
[local_def_id_to_hir_id]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.local_def_id_to_hir_id
135129

136-
Similarly, you can use [`tcx.hir().find(n)`][find] to lookup the node for a
130+
Similarly, you can use [`tcx.hir_node(n)`][hir_node] to lookup the node for a
137131
[`HirId`]. This returns a `Option<Node<'hir>>`, where [`Node`] is an enum
138132
defined in the map. By matching on this, you can find out what sort of
139133
node the `HirId` referred to and also get a pointer to the data
@@ -142,26 +136,27 @@ that `n` must be some HIR expression, you can do
142136
[`tcx.hir_expect_expr(n)`][expect_expr], which will extract and return the
143137
[`&hir::Expr`][Expr], panicking if `n` is not in fact an expression.
144138

145-
[find]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.find
139+
[hir_node]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir_node
146140
[`Node`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.Node.html
147141
[expect_expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.expect_expr
148142
[Expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Expr.html
149143

150-
Finally, you can use the HIR map to find the parents of nodes, via
151-
calls like [`tcx.hir().get_parent(n)`][get_parent].
144+
Finally, you can find the parents of nodes, via
145+
calls like [`tcx.parent_hir_node(n)`][parent_hir_node].
146+
147+
[parent_hir_node]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.parent_hir_node
152148

153-
[get_parent]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.get_parent
154149

155150
## HIR Bodies
156151

157152
A [`rustc_hir::Body`] represents some kind of executable code, such as the body
158153
of a function/closure or the definition of a constant. Bodies are
159154
associated with an **owner**, which is typically some kind of item
160155
(e.g. an `fn()` or `const`), but could also be a closure expression
161-
(e.g. `|x, y| x + y`). You can use the HIR map to find the body
162-
associated with a given def-id ([`maybe_body_owned_by`]) or to find
163-
the owner of a body ([`body_owner_def_id`]).
156+
(e.g. `|x, y| x + y`). You can use the `TyCtxt` to find the body
157+
associated with a given def-id ([`hir_maybe_body_owned_by`]) or to find
158+
the owner of a body ([`hir_body_owner_def_id`]).
164159

165160
[`rustc_hir::Body`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Body.html
166-
[`maybe_body_owned_by`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.maybe_body_owned_by
167-
[`body_owner_def_id`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.body_owner_def_id
161+
[`hir_maybe_body_owned_by`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir_maybe_body_owned_by
162+
[`hir_body_owner_def_id`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.hir_body_owner_def_id

src/solve/opaque-types.md

Lines changed: 1 addition & 1 deletion
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,

src/tests/best-practices.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ See [compiletest directives] for a listing of directives.
175175
- For `ignore-*`/`needs-*`/`only-*` directives, unless extremely obvious,
176176
provide a brief remark on why the directive is needed. E.g. `"//@ ignore-wasi
177177
(wasi codegens the main symbol differently)"`.
178+
- When using `//@ ignore-auxiliary`, specify the corresponding main test files,
179+
e.g. ``//@ ignore-auxiliary (used by `./foo.rs`)``.
178180

179181
## FileCheck best practices
180182

src/tests/directives.md

Lines changed: 18 additions & 9 deletions
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>` |
@@ -123,6 +124,9 @@ means the test won't be compiled or run.
123124
* `ignore-X` where `X` is a target detail or other criteria on which to ignore the test (see below)
124125
* `only-X` is like `ignore-X`, but will *only* run the test on that target or
125126
stage
127+
* `ignore-auxiliary` is intended for files that *participate* in one or more other
128+
main test files but that `compiletest` should not try to build the file itself.
129+
Please backlink to which main test is actually using the auxiliary file.
126130
* `ignore-test` always ignores the test. This can be used to temporarily disable
127131
a test if it is currently not working, but you want to keep it in tree to
128132
re-enable it later.
@@ -191,8 +195,13 @@ settings:
191195
specified atomic widths, e.g. the test with `//@ needs-target-has-atomic: 8,
192196
16, ptr` will only run if it supports the comma-separated list of atomic
193197
widths.
194-
- `needs-dynamic-linking` - ignores if target does not support dynamic linking
198+
- `needs-dynamic-linking` ignores if target does not support dynamic linking
195199
(which is orthogonal to it being unable to create `dylib` and `cdylib` crate types)
200+
- `needs-crate-type` — ignores if target platform does not support one or more
201+
of the comma-delimited list of specified crate types. For example,
202+
`//@ needs-crate-type: cdylib, proc-macro` will cause the test to be ignored
203+
on `wasm32-unknown-unknown` target because the target does not support the
204+
`proc-macro` crate type.
196205

197206
The following directives will check LLVM support:
198207

@@ -229,14 +238,14 @@ ignoring debuggers.
229238

230239
### Affecting how tests are built
231240

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 |
241+
| Directive | Explanation | Supported test suites | Possible values |
242+
|---------------------|----------------------------------------------------------------------------------------------|---------------------------|--------------------------------------------------------------------------------------------|
243+
| `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` |
244+
| `edition` | The edition used to build the test | All except for `run-make` | Any valid `--edition` value |
245+
| `rustc-env` | Env var to set when running `rustc` | All except for `run-make` | `<KEY>=<VALUE>` |
246+
| `unset-rustc-env` | Env var to unset when running `rustc` | All except for `run-make` | Any env var name |
247+
| `incremental` | Proper incremental support for tests outside of incremental test suite | `ui`, `crashes` | N/A |
248+
| `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 |
240249

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

0 commit comments

Comments
 (0)