@@ -352,11 +352,31 @@ pub struct CoroutineClosureArgs<'tcx> {
352352}
353353
354354pub struct CoroutineClosureArgsParts < ' tcx > {
355+ /// This is the args of the typeck root.
355356 pub parent_args : & ' tcx [ GenericArg < ' tcx > ] ,
357+ /// Represents the maximum calling capability of the closure.
356358 pub closure_kind_ty : Ty < ' tcx > ,
359+ /// Represents all of the relevant parts of the coroutine returned by this
360+ /// coroutine-closure. This signature parts type will have the general
361+ /// shape of `fn(tupled_inputs, resume_ty) -> (return_ty, yield_ty)`, where
362+ /// `resume_ty`, `return_ty`, and `yield_ty` are the respective types for the
363+ /// coroutine returned by the coroutine-closure.
364+ ///
365+ /// Use `coroutine_closure_sig` to break up this type rather than using it
366+ /// yourself.
357367 pub signature_parts_ty : Ty < ' tcx > ,
368+ /// The upvars captured by the closure. Remains an inference variable
369+ /// until the upvar analysis, which happens late in HIR typeck.
358370 pub tupled_upvars_ty : Ty < ' tcx > ,
371+ /// a function pointer that has the shape `for<'env> fn() -> (&'env T, ...)`.
372+ /// This allows us to represent the binder of the self-captures of the closure.
373+ ///
374+ /// For example, if the coroutine returned by the closure borrows `String`
375+ /// from the closure's upvars, this will be `for<'env> fn() -> (&'env String,)`,
376+ /// while the `tupled_upvars_ty`, representing the by-move version of the same
377+ /// captures, will be `(String,)`.
359378 pub coroutine_captures_by_ref_ty : Ty < ' tcx > ,
379+ /// Witness type returned by the generator produced by this coroutine-closure.
360380 pub coroutine_witness_ty : Ty < ' tcx > ,
361381}
362382
@@ -572,15 +592,27 @@ pub struct CoroutineArgs<'tcx> {
572592pub struct CoroutineArgsParts < ' tcx > {
573593 /// This is the args of the typeck root.
574594 pub parent_args : & ' tcx [ GenericArg < ' tcx > ] ,
575- // TODO: why
595+
596+ /// The coroutines returned by a coroutine-closure's `AsyncFnOnce`/`AsyncFnMut`
597+ /// implementations must be distinguished since the former takes the closure's
598+ /// upvars by move, and the latter takes the closure's upvars by ref.
599+ ///
600+ /// This field distinguishes these fields so that codegen can select the right
601+ /// body for the coroutine. This has the same type representation as the closure
602+ /// kind: `i8`/`i16`/`i32`.
603+ ///
604+ /// For regular coroutines, this field will always just be `()`.
576605 pub kind_ty : Ty < ' tcx > ,
606+
577607 pub resume_ty : Ty < ' tcx > ,
578608 pub yield_ty : Ty < ' tcx > ,
579609 pub return_ty : Ty < ' tcx > ,
610+
580611 /// The interior type of the coroutine.
581612 /// Represents all types that are stored in locals
582613 /// in the coroutine's body.
583614 pub witness : Ty < ' tcx > ,
615+
584616 /// The upvars captured by the closure. Remains an inference variable
585617 /// until the upvar analysis, which happens late in HIR typeck.
586618 pub tupled_upvars_ty : Ty < ' tcx > ,
@@ -632,7 +664,7 @@ impl<'tcx> CoroutineArgs<'tcx> {
632664 self . split ( ) . parent_args
633665 }
634666
635- // TODO:
667+ // Returns the kind of the coroutine. See docs on the `kind_ty` field.
636668 pub fn kind_ty ( self ) -> Ty < ' tcx > {
637669 self . split ( ) . kind_ty
638670 }
0 commit comments