Skip to content

Commit c1db850

Browse files
committed
Merge ref 'd087f112b7d1:/library/compiler-builtins' from https://github.com/rust-lang/rust
Pull recent changes from rust-lang/rust via Josh. Upstream ref: d087f112b7d1323446c7b39a8b616aee7fa56b3d Filtered ref: 2d43ce8ac022170e5383f7e5a188b55564b6566a
2 parents ec32bcf + 89ebba9 commit c1db850

24 files changed

+274
-289
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
99e7c15e81385b38a8186b51edc4577d5d7b5bdd
1+
14346303d760027e53214e705109a62c0f00b214

src/SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@
6363
- [Notification groups](notification-groups/about.md)
6464
- [Apple](notification-groups/apple.md)
6565
- [ARM](notification-groups/arm.md)
66-
- [Cleanup Crew](notification-groups/cleanup-crew.md)
6766
- [Emscripten](notification-groups/emscripten.md)
6867
- [Fuchsia](notification-groups/fuchsia.md)
69-
- [LLVM](notification-groups/llvm.md)
7068
- [RISC-V](notification-groups/risc-v.md)
7169
- [Rust for Linux](notification-groups/rust-for-linux.md)
7270
- [WASI](notification-groups/wasi.md)
@@ -101,6 +99,8 @@
10199
- [Rustdoc internals](./rustdoc-internals.md)
102100
- [Search](./rustdoc-internals/search.md)
103101
- [The `rustdoc` test suite](./rustdoc-internals/rustdoc-test-suite.md)
102+
- [The `rustdoc-gui` test suite](./rustdoc-internals/rustdoc-gui-test-suite.md)
103+
- [The `rustdoc-json` test suite](./rustdoc-internals/rustdoc-json-test-suite.md)
104104
- [Autodiff internals](./autodiff/internals.md)
105105
- [Installation](./autodiff/installation.md)
106106
- [How to debug](./autodiff/debugging.md)

src/autodiff/flags.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ LooseTypes // Risk incorrect derivatives instead of aborting when missing Type I
1616
```
1717

1818
<div class="warning">
19+
1920
`LooseTypes` is often helpful to get rid of Enzyme errors stating `Can not deduce type of <X>` and to be able to run some code. But please keep in mind that this flag absolutely has the chance to cause incorrect gradients. Even worse, the gradients might be correct for certain input values, but not for others. So please create issues about such bugs and only use this flag temporarily while you wait for your bug to be fixed.
21+
2022
</div>
2123

2224
### Benchmark flags

src/building/bootstrapping/debugging-bootstrap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Bootstrap will conditionally build `tracing` support and enable `tracing` output
5555

5656
Example basic usage[^just-trace]:
5757

58-
[^just-trace]: It is not recommend to use *just* `BOOTSTRAP_TRACING=TRACE` because that will dump *everything* at `TRACE` level, including logs intentionally gated behind custom targets as they are too verbose even for `TRACE` level by default.
58+
[^just-trace]: It is not recommended to use *just* `BOOTSTRAP_TRACING=TRACE` because that will dump *everything* at `TRACE` level, including logs intentionally gated behind custom targets as they are too verbose even for `TRACE` level by default.
5959

6060
```bash
6161
$ BOOTSTRAP_TRACING=bootstrap=TRACE ./x build library --stage 1

src/building/suggested.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ always overrides the inner ones.
5959

6060
## Configuring `rust-analyzer` for `rustc`
6161

62+
### Checking the "library" tree
63+
64+
Checking the "library" tree requires a stage1 compiler, which can be a heavy process on some computers.
65+
For this reason, bootstrap has a flag called `--skip-std-check-if-no-download-rustc` that skips checking the
66+
"library" tree if `rust.download-rustc` isn't available. If you want to avoid putting a heavy load on your computer
67+
with `rust-analyzer`, you can add the `--skip-std-check-if-no-download-rustc` flag to your `./x check` command in
68+
the `rust-analyzer` configuration.
69+
6270
### Project-local rust-analyzer setup
6371

6472
`rust-analyzer` can help you check and format your code whenever you save a

src/coroutine-closures.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
# Async closures/"coroutine-closures"
2+
3+
<!-- toc -->
4+
15
Please read [RFC 3668](https://rust-lang.github.io/rfcs/3668-async-closures.html) to understand the general motivation of the feature. This is a very technical and somewhat "vertical" chapter; ideally we'd split this and sprinkle it across all the relevant chapters, but for the purposes of understanding async closures *holistically*, I've put this together all here in one chapter.
26

3-
# Coroutine-closures -- a technical deep dive
7+
## Coroutine-closures -- a technical deep dive
48

59
Coroutine-closures are a generalization of async closures, being special syntax for closure expressions which return a coroutine, notably one that is allowed to capture from the closure's upvars.
610

711
For now, the only usable kind of coroutine-closure is the async closure, and supporting async closures is the extent of this PR. We may eventually support `gen || {}`, etc., and most of the problems and curiosities described in this document apply to all coroutine-closures in general.
812

913
As a consequence of the code being somewhat general, this document may flip between calling them "async closures" and "coroutine-closures". The future that is returned by the async closure will generally be called the "coroutine" or the "child coroutine".
1014

11-
## HIR
15+
### HIR
1216

13-
Async closures (and in the future, other coroutine flavors such as `gen`) are represented in HIR as a `hir::Closure` whose closure-kind is `ClosureKind::CoroutineClosure(_)`[^k1], which wraps an async block, which is also represented in HIR as a `hir::Closure`) and whose closure-kind is `ClosureKind::Closure(CoroutineKind::Desugared(_, CoroutineSource::Closure))`[^k2].
17+
Async closures (and in the future, other coroutine flavors such as `gen`) are represented in HIR as a `hir::Closure`.
18+
The closure-kind of the `hir::Closure` is `ClosureKind::CoroutineClosure(_)`[^k1], which wraps an async block, which is also represented in HIR as a `hir::Closure`.
19+
The closure-kind of the async block is `ClosureKind::Closure(CoroutineKind::Desugared(_, CoroutineSource::Closure))`[^k2].
1420

1521
[^k1]: <https://github.com/rust-lang/rust/blob/5ca0e9fa9b2f92b463a0a2b0b34315e09c0b7236/compiler/rustc_ast_lowering/src/expr.rs#L1147>
1622

@@ -24,7 +30,7 @@ Like `async fn`, when lowering an async closure's body, we need to unconditional
2430

2531
[^l3]: <https://github.com/rust-lang/rust/blob/5ca0e9fa9b2f92b463a0a2b0b34315e09c0b7236/compiler/rustc_hir_typeck/src/upvar.rs#L250-L256>
2632

27-
## `rustc_middle::ty` Representation
33+
### `rustc_middle::ty` Representation
2834

2935
For the purposes of keeping the implementation mostly future-compatible (i.e. with gen `|| {}` and `async gen || {}`), most of this section calls async closures "coroutine-closures".
3036

@@ -72,7 +78,7 @@ To most easily construct the `Coroutine` that a coroutine-closure returns, you c
7278

7379
Most of the args to that function will be components that you can get out of the `CoroutineArgs`, except for the `goal_kind: ClosureKind` which controls which flavor of coroutine to return based off of the `ClosureKind` passed in -- i.e. it will prepare the by-ref coroutine if `ClosureKind::Fn | ClosureKind::FnMut`, and the by-move coroutine if `ClosureKind::FnOnce`.
7480

75-
## Trait Hierarchy
81+
### Trait Hierarchy
7682

7783
We introduce a parallel hierarchy of `Fn*` traits that are implemented for . The motivation for the introduction was covered in a blog post: [Async Closures](https://hackmd.io/@compiler-errors/async-closures).
7884

@@ -98,11 +104,11 @@ We mention above that "regular" callable types can implement `AsyncFn*`, but the
98104

99105
See the "follow-up: when do..." section below for an elaborated answer. The full answer describes a pretty interesting and hopefully thorough heuristic that is used to ensure that most async closures "just work".
100106

101-
## Tale of two bodies...
107+
### Tale of two bodies...
102108

103109
When async closures are called with `AsyncFn`/`AsyncFnMut`, they return a coroutine that borrows from the closure. However, when they are called via `AsyncFnOnce`, we consume that closure, and cannot return a coroutine that borrows from data that is now dropped.
104110

105-
To work around around this limitation, we synthesize a separate by-move MIR body for calling `AsyncFnOnce::call_once` on a coroutine-closure that can be called by-ref.
111+
To work around this limitation, we synthesize a separate by-move MIR body for calling `AsyncFnOnce::call_once` on a coroutine-closure that can be called by-ref.
106112

107113
This body operates identically to the "normal" coroutine returned from calling the coroutine-closure, except for the fact that it has a different set of upvars, since we must *move* the captures from the parent coroutine-closure into the child coroutine.
108114

@@ -120,7 +126,7 @@ Since we've synthesized a new def id, this query is also responsible for feeding
120126

121127
[^b3]: <https://github.com/rust-lang/rust/blob/5ca0e9fa9b2f92b463a0a2b0b34315e09c0b7236/compiler/rustc_mir_transform/src/lib.rs#L339-L342>
122128

123-
## Closure signature inference
129+
### Closure signature inference
124130

125131
The closure signature inference algorithm for async closures is a bit more complicated than the inference algorithm for "traditional" closures. Like closures, we iterate through all of the clauses that may be relevant (for the expectation type passed in)[^deduce1].
126132

@@ -173,7 +179,7 @@ s.as_bytes();
173179

174180
So *instead*, we use this alias (in this case, a projection: `AsyncFnKindHelper::Upvars<'env, ...>`) to delay the computation of the *tupled upvars* and give us something to put in its place, while still allowing us to return a `TyKind::Coroutine` (which is a rigid type) and we may successfully confirm the built-in traits we need (in our case, `Future`), since the `Future` implementation doesn't depend on the upvars at all.
175181

176-
## Upvar analysis
182+
### Upvar analysis
177183

178184
By and large, the upvar analysis for coroutine-closures and their child coroutines proceeds like normal upvar analysis. However, there are several interesting bits that happen to account for async closures' special natures:
179185

@@ -262,7 +268,7 @@ let c = async || {
262268

263269
If either of these cases apply, then we should capture the borrow with the lifetime of the parent coroutine-closure's env. Luckily, if this function is not correct, then the program is not unsound, since we still borrowck and validate the choices made from this function -- the only side-effect is that the user may receive unnecessary borrowck errors.
264270

265-
## Instance resolution
271+
### Instance resolution
266272

267273
If a coroutine-closure has a closure-kind of `FnOnce`, then its `AsyncFnOnce::call_once` and `FnOnce::call_once` implementations resolve to the coroutine-closure's body[^res1], and the `Future::poll` of the coroutine that gets returned resolves to the body of the child closure.
268274

@@ -282,7 +288,7 @@ This is represented by the `ConstructCoroutineInClosureShim`[^i1]. The `receiver
282288

283289
[^i3]: <https://github.com/rust-lang/rust/blob/07cbbdd69363da97075650e9be24b78af0bcdd23/compiler/rustc_middle/src/ty/instance.rs#L841>
284290

285-
## Borrow-checking
291+
### Borrow-checking
286292

287293
It turns out that borrow-checking async closures is pretty straightforward. After adding a new `DefiningTy::CoroutineClosure`[^bck1] variant, and teaching borrowck how to generate the signature of the coroutine-closure[^bck2], borrowck proceeds totally fine.
288294

src/getting-started.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ feel comfortable jumping straight into the large `rust-lang/rust` codebase.
158158
The following tasks are doable without much background knowledge but are
159159
incredibly helpful:
160160

161-
- [Cleanup crew][iceb]: find minimal reproductions of ICEs, bisect
162-
regressions, etc. This is a way of helping that saves a ton of time for
163-
others to fix an error later.
164161
- [Writing documentation][wd]: if you are feeling a bit more intrepid, you could try
165162
to read a part of the code and write doc comments for it. This will help you
166163
to learn some part of the compiler while also producing a useful artifact!
@@ -179,7 +176,6 @@ incredibly helpful:
179176
[users]: https://users.rust-lang.org/
180177
[so]: http://stackoverflow.com/questions/tagged/rust
181178
[community-library]: https://github.com/rust-lang/rfcs/labels/A-community-library
182-
[iceb]: ./notification-groups/cleanup-crew.md
183179
[wd]: ./contributing.md#writing-documentation
184180
[wg]: https://rust-lang.github.io/compiler-team/working-groups/
185181
[triage]: ./contributing.md#issue-triage

src/git.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ The most common cause is that you rebased after a change and ran `git add .` wit
142142
`x` to update the submodules. Alternatively, you might have run `cargo fmt` instead of `x fmt`
143143
and modified files in a submodule, then committed the changes.
144144

145-
To fix it, do the following things:
145+
To fix it, do the following things (if you changed a submodule other than cargo,
146+
replace `src/tools/cargo` with the path to that submodule):
146147

147148
1. See which commit has the accidental changes: `git log --stat -n1 src/tools/cargo`
148149
2. Revert the changes to that commit: `git checkout <my-commit>~ src/tools/cargo`. Type `~`

src/normalization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ Another problem was that it was not possible to normalize `ParamEnv`s correctly
265265

266266
Given a type such as `for<'a> fn(<?x as Trait<'a>::Assoc>)`, it is not possible to correctly handle this with the old solver's approach to normalization.
267267

268-
If we were to normalize it to `for<'a> fn(?y)` and register a goal to normalize `for<'a> <?x as Trait<'a>>::Assoc -> ?y`, this would result in errors in cases where `<?x as Trait<'a>>::Assoc` normalized to `&'a u32`. The inference variable `?y` would be in a lower [universe][universes] than the placeholders made when instantiating the `for<'a>` binder.
268+
If we were to normalize it to `for<'a> fn(?y)` and register a goal to normalize `for<'a> <?x as Trait<'a>>::Assoc -> ?y`, this would result in errors in cases where `<?x as Trait<'a>>::Assoc` normalized to `&'a u32`. The inference variable `?y` would be in a lower [universe] than the placeholders made when instantiating the `for<'a>` binder.
269269

270270
Leaving the alias unnormalized would also be wrong as the old solver expects all aliases to be rigid. This was a soundness bug before the new solver was stabilized in coherence: [relating projection substs is unsound during coherence](https://github.com/rust-lang/rust/issues/102048).
271271

272272
Ultimately this means that it is not always possible to ensure all aliases inside of a value are rigid.
273273

274-
[universes]: https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/placeholders_and_universes.html#what-is-a-universe
274+
[universe]: borrow_check/region_inference/placeholders_and_universes.md#what-is-a-universe
275275
[deeply_normalize]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/normalize/trait.NormalizeExt.html#tymethod.deeply_normalize
276276

277277
## Handling uses of diverging aliases

src/notification-groups/about.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ search for existing issues that haven't been claimed yet.
2121
Here's the list of the notification groups:
2222
- [Apple](./apple.md)
2323
- [ARM](./arm.md)
24-
- [Cleanup Crew](./cleanup-crew.md)
2524
- [Emscripten](./emscripten.md)
26-
- [LLVM Icebreakers](./llvm.md)
2725
- [RISC-V](./risc-v.md)
2826
- [WASI](./wasi.md)
2927
- [WebAssembly](./wasm.md)
@@ -64,9 +62,7 @@ Example PRs:
6462

6563
* [Example of adding yourself to the Apple group.](https://github.com/rust-lang/team/pull/1434)
6664
* [Example of adding yourself to the ARM group.](https://github.com/rust-lang/team/pull/358)
67-
* [Example of adding yourself to the Cleanup Crew.](https://github.com/rust-lang/team/pull/221)
6865
* [Example of adding yourself to the Emscripten group.](https://github.com/rust-lang/team/pull/1579)
69-
* [Example of adding yourself to the LLVM group.](https://github.com/rust-lang/team/pull/140)
7066
* [Example of adding yourself to the RISC-V group.](https://github.com/rust-lang/team/pull/394)
7167
* [Example of adding yourself to the WASI group.](https://github.com/rust-lang/team/pull/1580)
7268
* [Example of adding yourself to the WebAssembly group.](https://github.com/rust-lang/team/pull/1581)
@@ -81,9 +77,7 @@ group. For example:
8177
```text
8278
@rustbot ping apple
8379
@rustbot ping arm
84-
@rustbot ping cleanup-crew
8580
@rustbot ping emscripten
86-
@rustbot ping icebreakers-llvm
8781
@rustbot ping risc-v
8882
@rustbot ping wasi
8983
@rustbot ping wasm
@@ -92,12 +86,12 @@ group. For example:
9286

9387
To make some commands shorter and easier to remember, there are aliases,
9488
defined in the [`triagebot.toml`] file. For example, all of these commands
95-
are equivalent and will ping the Cleanup Crew:
89+
are equivalent and will ping the Apple group:
9690

9791
```text
98-
@rustbot ping cleanup
99-
@rustbot ping bisect
100-
@rustbot ping reduce
92+
@rustbot ping apple
93+
@rustbot ping macos
94+
@rustbot ping ios
10195
```
10296

10397
Keep in mind that these aliases are meant to make humans' life easier.

src/notification-groups/cleanup-crew.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)