Skip to content

Commit 2d8b10f

Browse files
committed
adjust larger comment to include the body
1 parent 716b2bc commit 2d8b10f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/librustc/hir/lowering/item.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,7 @@ impl LoweringContext<'_> {
10991099
// from:
11001100
//
11011101
// async fn foo(<pattern>: <ty>, <pattern>: <ty>, <pattern>: <ty>) {
1102-
// async move {
1103-
// }
1102+
// <body>
11041103
// }
11051104
//
11061105
// into:
@@ -1113,11 +1112,19 @@ impl LoweringContext<'_> {
11131112
// let <pattern> = __arg1;
11141113
// let __arg0 = __arg0;
11151114
// let <pattern> = __arg0;
1115+
// drop-temps { <body> } // see comments later in fn for details
11161116
// }
11171117
// }
11181118
//
11191119
// If `<pattern>` is a simple ident, then it is lowered to a single
11201120
// `let <pattern> = <pattern>;` statement as an optimization.
1121+
//
1122+
// Note that the body is embedded in `drop-temps`; an
1123+
// equivalent desugaring would be `return { <body>
1124+
// };`. The key point is that we wish to drop all the
1125+
// let-bound variables and temporaries created in the body
1126+
// (and its tail expression!) before we drop the
1127+
// parameters (c.f. rust-lang/rust#64512).
11211128
for (index, parameter) in decl.inputs.iter().enumerate() {
11221129
let parameter = this.lower_param(parameter);
11231130
let span = parameter.pat.span;
@@ -1231,7 +1238,7 @@ impl LoweringContext<'_> {
12311238
ThinVec::new(),
12321239
);
12331240

1234-
// Create a block like
1241+
// As noted above, create the final block like
12351242
//
12361243
// ```
12371244
// {
@@ -1240,13 +1247,6 @@ impl LoweringContext<'_> {
12401247
// drop-temps { <user-body> }
12411248
// }
12421249
// ```
1243-
//
1244-
// This construction is carefully calibrated to
1245-
// get the drop-order correct. In particular, the
1246-
// drop-temps ensures that any temporaries in the
1247-
// tail expression of `<user-body>` are dropped
1248-
// *before* the parameters are dropped (see
1249-
// rust-lang/rust#64512).
12501250
let body = this.block_all(
12511251
desugared_span,
12521252
statements.into(),

0 commit comments

Comments
 (0)