Skip to content

Commit 9804de1

Browse files
committed
Add and fix more links.
1 parent 1ffa131 commit 9804de1

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/expressions/await-expr.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
>    [_Expression_] `.` `await`
66
77
Await expressions are legal only within `async` contexts, like an
8-
`async fn` or an `async` block. They operate on a future. Their effect
8+
[`async fn`] or an [`async` block]. They operate on a [future]. Their effect
99
is to suspend the current computation until the given future is ready
1010
to produce a value.
1111

1212
More specifically, an `<expr>.await` expression has the following effect.
1313

1414
1. Evaluate `<expr>` to a [future] `tmp`;
15-
2. Pin `tmp` using `Pin::new_unchecked`;
15+
2. Pin `tmp` using [`Pin::new_unchecked`];
1616
3. This pinned future is then polled by calling the [`Future::poll`] method and
17-
passing it the current task context (see below);
17+
passing it the current [task context](#task-context);
1818
3. If the call to `poll` returns [`Poll::Pending`], then the future
1919
returns `Poll::Pending`, suspending its state so that, when the
2020
surrounding async context is re-polled, execution returns to step
@@ -23,10 +23,13 @@ More specifically, an `<expr>.await` expression has the following effect.
2323
value contained in the [`Poll::Ready`] variant is used as the result
2424
of the `await` expression itself.
2525

26+
[`async fn`]: items/functions.html#async-functions
27+
[`async` block]: expressions/block-expr.html#async-blocks
2628
[future]: ../std/future/trait.Future.html
2729
[_Expression_]: expressions.html
2830
[`Future::poll`]: ../std/future/trait.Future.html#tymethod.poll
2931
[`Context`]: ../std/task/struct.Context.html
32+
[`Pin::new_unchecked`]: ../std/pin/struct.Pin.html#method.new_unchecked
3033
[`Poll::Pending`]: ../std/task/enum.Poll.html#variant.Pending
3134
[`Poll::Ready`]: ../std/task/enum.Poll.html#variant.Ready
3235

src/expressions/block-expr.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ the result value of the future.
9393
Executing an async block is similar to executing a closure expression:
9494
its immediate effect is to produce and return an anonymous type.
9595
Whereas closures return a type that implements one or more of the
96-
`std::ops::Fn` traits, however, the type returned for an async block
97-
implements the `std::future::Future` trait. The actual data format for
96+
[`std::ops::Fn`] traits, however, the type returned for an async block
97+
implements the [`std::future::Future`] trait. The actual data format for
9898
this type is unspecified.
9999

100100
> **Note:** The future type that rustc generates is roughly equivalent
@@ -103,6 +103,9 @@ this type is unspecified.
103103
104104
> **Edition differences**: Async blocks are only available in Rust 2018.
105105
106+
[`std::ops::Fn`]: ../std/ops/trait.Fn.html
107+
[`std::future::Future`]: ../std/future/trait.Future.html
108+
106109
### Capture modes
107110

108111
Async blocks capture variables from their environment using the same

src/items/functions.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ capture their arguments into a future. When polled, that future will
207207
execute the function's body.
208208

209209
An async function is roughly equivalent to a function
210-
that returns [`impl Future`] and with an [`async move` block] as its body:
210+
that returns [`impl Future`] and with an [`async move` block][async-blocks] as
211+
its body:
211212

212213
```rust,edition2018
213214
// Source
@@ -227,18 +228,18 @@ The actual desugaring is more complex:
227228
parameters from the `async fn` declaration. This can be seen in the
228229
desugared example above, which explicitly outlives, and hence
229230
captures, `'a`.
230-
- The [`async move` block] in the body captures all function
231+
- The [`async move` block][async-blocks] in the body captures all function
231232
parameters, including those that are unused or bound to a `_`
232233
pattern. This ensures that function parameters are dropped in the
233234
same order as they would be if the function were not async, except
234235
that the drop occurs when the returned future has been fully
235236
awaited.
236-
237-
For more information on the effect of async, see [`async` blocks][`async` block].
238237

239-
[`async move` block]: ../expressions/block-expr.html#async-blocks
240-
[`impl Future`]: ../types/impl-trait.html
241-
238+
For more information on the effect of async, see [`async` blocks][async-blocks].
239+
240+
[async-blocks]: expressions/block-expr.html#async-blocks
241+
[`impl Future`]: types/impl-trait.html
242+
242243
> **Edition differences**: Async functions are only available in Rust 2018.
243244
244245
## Attributes on functions

0 commit comments

Comments
 (0)