@@ -276,11 +276,31 @@ pub struct CoroutineClosureArgs<'tcx> {
276276}
277277
278278pub struct CoroutineClosureArgsParts < ' tcx > {
279+ /// This is the args of the typeck root.
279280 pub parent_args : & ' tcx [ GenericArg < ' tcx > ] ,
281+ /// Represents the maximum calling capability of the closure.
280282 pub closure_kind_ty : Ty < ' tcx > ,
283+ /// Represents all of the relevant parts of the coroutine returned by this
284+ /// coroutine-closure. This signature parts type will have the general
285+ /// shape of `fn(tupled_inputs, resume_ty) -> (return_ty, yield_ty)`, where
286+ /// `resume_ty`, `return_ty`, and `yield_ty` are the respective types for the
287+ /// coroutine returned by the coroutine-closure.
288+ ///
289+ /// Use `coroutine_closure_sig` to break up this type rather than using it
290+ /// yourself.
281291 pub signature_parts_ty : Ty < ' tcx > ,
292+ /// The upvars captured by the closure. Remains an inference variable
293+ /// until the upvar analysis, which happens late in HIR typeck.
282294 pub tupled_upvars_ty : Ty < ' tcx > ,
295+ /// a function pointer that has the shape `for<'env> fn() -> (&'env T, ...)`.
296+ /// This allows us to represent the binder of the self-captures of the closure.
297+ ///
298+ /// For example, if the coroutine returned by the closure borrows `String`
299+ /// from the closure's upvars, this will be `for<'env> fn() -> (&'env String,)`,
300+ /// while the `tupled_upvars_ty`, representing the by-move version of the same
301+ /// captures, will be `(String,)`.
283302 pub coroutine_captures_by_ref_ty : Ty < ' tcx > ,
303+ /// Witness type returned by the generator produced by this coroutine-closure.
284304 pub coroutine_witness_ty : Ty < ' tcx > ,
285305}
286306
@@ -496,15 +516,27 @@ pub struct CoroutineArgs<'tcx> {
496516pub struct CoroutineArgsParts < ' tcx > {
497517 /// This is the args of the typeck root.
498518 pub parent_args : & ' tcx [ GenericArg < ' tcx > ] ,
499- // TODO: why
519+
520+ /// The coroutines returned by a coroutine-closure's `AsyncFnOnce`/`AsyncFnMut`
521+ /// implementations must be distinguished since the former takes the closure's
522+ /// upvars by move, and the latter takes the closure's upvars by ref.
523+ ///
524+ /// This field distinguishes these fields so that codegen can select the right
525+ /// body for the coroutine. This has the same type representation as the closure
526+ /// kind: `i8`/`i16`/`i32`.
527+ ///
528+ /// For regular coroutines, this field will always just be `()`.
500529 pub kind_ty : Ty < ' tcx > ,
530+
501531 pub resume_ty : Ty < ' tcx > ,
502532 pub yield_ty : Ty < ' tcx > ,
503533 pub return_ty : Ty < ' tcx > ,
534+
504535 /// The interior type of the coroutine.
505536 /// Represents all types that are stored in locals
506537 /// in the coroutine's body.
507538 pub witness : Ty < ' tcx > ,
539+
508540 /// The upvars captured by the closure. Remains an inference variable
509541 /// until the upvar analysis, which happens late in HIR typeck.
510542 pub tupled_upvars_ty : Ty < ' tcx > ,
@@ -556,7 +588,7 @@ impl<'tcx> CoroutineArgs<'tcx> {
556588 self . split ( ) . parent_args
557589 }
558590
559- // TODO:
591+ // Returns the kind of the coroutine. See docs on the `kind_ty` field.
560592 pub fn kind_ty ( self ) -> Ty < ' tcx > {
561593 self . split ( ) . kind_ty
562594 }
0 commit comments