Skip to content

Commit

Permalink
fix permalinks
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors authored and jieyouxu committed Nov 2, 2024
1 parent 0dc7845 commit 7764847
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/coroutine-closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Well, first of all, all async closures implement `FnOnce` since they can always
For `Fn`/`FnMut`, the detailed answer involves answering a related question: is the coroutine-closure lending? Because if it is, then it cannot implement the non-lending `Fn`/`FnMut` traits.

Determining when the coroutine-closure must *lend* its upvars is implemented in the `should_reborrow_from_env_of_parent_coroutine_closure` helper function[^u1]. Specifically, this needs to happen in two places:
[^u1]: https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_typeck/src/upvar.rs#L1818-L1860
[^u1]: https://github.com/rust-lang/rust/blob/7c7bb7dc017545db732f5cffec684bbaeae0a9a0/compiler/rustc_hir_typeck/src/upvar.rs#L1818-L1860

1. Are we borrowing data owned by the parent closure? We can determine if that is the case by checking if the parent capture is by-move, EXCEPT if we apply a deref projection, which means we're reborrowing a reference that we captured by-move.

Expand Down Expand Up @@ -254,4 +254,4 @@ It turns out that borrow-checking async closures is pretty straightforward. Afte
One thing to note is that we don't borrow-check the synthetic body we make for by-move coroutines, since by construction (and the validity of the by-ref coroutine body it was derived from) it must be valid.

[^bck1]: https://github.com/rust-lang/rust/blob/705cfe0e966399e061d64dd3661bfbc57553ed87/compiler/rustc_borrowck/src/universal_regions.rs#L110-L115
[^bck2]: https://github.com/rust-lang/rust/blob/master/compiler/rustc_borrowck/src/universal_regions.rs#L743-L790
[^bck2]: https://github.com/rust-lang/rust/blob/7c7bb7dc017545db732f5cffec684bbaeae0a9a0/compiler/rustc_borrowck/src/universal_regions.rs#L743-L790

0 comments on commit 7764847

Please sign in to comment.