Commit 4e4d49d
committed
Auto merge of rust-lang#70831 - sfackler:shrink-future-stack, r=matthewjasper
Remove a stack frame from .await calls
The stack frames when `.await`ing one async fn from another currently look like this:
```
12: foo::b::{{closure}}
at src/main.rs:2
13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:66
14: core::future::poll_with_context
at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:84
15: foo::a::{{closure}}
at src/main.rs:6
```
Since the move away from using TLS to pass the Context around, it's now easy to remove frame 14 by removing poll_with_context in favor of calling Future::poll directly. This still leaves the `GenFuture` frame, but that seems significantly harder to deal with.
It also improves diagnostics a bit since they no longer talk about the private poll_with_context function.File tree
5 files changed
+40
-25
lines changed- src
- libcore/future
- librustc_ast_lowering
- librustc_span
- test/ui/async-await
- issues
5 files changed
+40
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 80 | + | |
| 81 | + | |
85 | 82 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | | - | |
| 559 | + | |
560 | 560 | | |
561 | | - | |
| 561 | + | |
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
603 | 603 | | |
604 | | - | |
| 604 | + | |
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
625 | | - | |
| 625 | + | |
626 | 626 | | |
627 | | - | |
628 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
629 | 634 | | |
630 | 635 | | |
631 | 636 | | |
| |||
1326 | 1331 | | |
1327 | 1332 | | |
1328 | 1333 | | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
1329 | 1343 | | |
1330 | 1344 | | |
1331 | 1345 | | |
1332 | 1346 | | |
1333 | 1347 | | |
1334 | 1348 | | |
1335 | | - | |
| 1349 | + | |
1336 | 1350 | | |
1337 | 1351 | | |
1338 | 1352 | | |
1339 | | - | |
| 1353 | + | |
1340 | 1354 | | |
1341 | 1355 | | |
1342 | 1356 | | |
1343 | 1357 | | |
1344 | | - | |
| 1358 | + | |
1345 | 1359 | | |
1346 | 1360 | | |
1347 | | - | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
1348 | 1371 | | |
1349 | 1372 | | |
1350 | 1373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
351 | 352 | | |
352 | 353 | | |
353 | 354 | | |
| |||
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
| 551 | + | |
550 | 552 | | |
551 | | - | |
552 | 553 | | |
553 | 554 | | |
554 | 555 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | 35 | | |
38 | | - | |
39 | | - | |
| 36 | + | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | 35 | | |
38 | | - | |
39 | | - | |
| 36 | + | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| |||
0 commit comments