diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2019-09-17 04:47:54 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2019-09-17 05:10:22 -0400 |
| commit | 2d8b10f63c394c99f2268de3132086bc72ee5a2b (patch) | |
| tree | f64d374826427d582a0fb25ab3ebca46a5e04d3b | |
| parent | 716b2bcfb36111ea8afb49d289ddfba2b62a7b8e (diff) | |
| download | rust-2d8b10f63c394c99f2268de3132086bc72ee5a2b.tar.gz rust-2d8b10f63c394c99f2268de3132086bc72ee5a2b.zip | |
adjust larger comment to include the body
| -rw-r--r-- | src/librustc/hir/lowering/item.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 9ac3a6bdc87..61be40a6b90 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -1099,8 +1099,7 @@ impl LoweringContext<'_> { // from: // // async fn foo(<pattern>: <ty>, <pattern>: <ty>, <pattern>: <ty>) { - // async move { - // } + // <body> // } // // into: @@ -1113,11 +1112,19 @@ impl LoweringContext<'_> { // let <pattern> = __arg1; // let __arg0 = __arg0; // let <pattern> = __arg0; + // drop-temps { <body> } // see comments later in fn for details // } // } // // If `<pattern>` is a simple ident, then it is lowered to a single // `let <pattern> = <pattern>;` statement as an optimization. + // + // Note that the body is embedded in `drop-temps`; an + // equivalent desugaring would be `return { <body> + // };`. The key point is that we wish to drop all the + // let-bound variables and temporaries created in the body + // (and its tail expression!) before we drop the + // parameters (c.f. rust-lang/rust#64512). for (index, parameter) in decl.inputs.iter().enumerate() { let parameter = this.lower_param(parameter); let span = parameter.pat.span; @@ -1231,7 +1238,7 @@ impl LoweringContext<'_> { ThinVec::new(), ); - // Create a block like + // As noted above, create the final block like // // ``` // { @@ -1240,13 +1247,6 @@ impl LoweringContext<'_> { // drop-temps { <user-body> } // } // ``` - // - // This construction is carefully calibrated to - // get the drop-order correct. In particular, the - // drop-temps ensures that any temporaries in the - // tail expression of `<user-body>` are dropped - // *before* the parameters are dropped (see - // rust-lang/rust#64512). let body = this.block_all( desugared_span, statements.into(), |
