@@ -244,18 +244,23 @@ impl<'tcx> MirSource<'tcx> {
244244 }
245245}
246246
247+ /// Additional information carried by a MIR body when it is lowered from a coroutine.
248+ /// This information is modified as it is lowered during the `StateTransform` MIR pass,
249+ /// so not all fields will be active at a given time. For example, the `yield_ty` is
250+ /// taken out of the field after yields are turned into returns, and the `coroutine_drop`
251+ /// body is only populated after the state transform pass.
247252#[ derive( Clone , TyEncodable , TyDecodable , Debug , HashStable , TypeFoldable , TypeVisitable ) ]
248253pub struct CoroutineInfo < ' tcx > {
249- /// The yield type of the function, if it is a coroutine .
254+ /// The yield type of the function. This field is removed after the state transform pass .
250255 pub yield_ty : Option < Ty < ' tcx > > ,
251256
252- /// The resume type of the function, if it is a coroutine .
257+ /// The resume type of the function. This field is removed after the state transform pass .
253258 pub resume_ty : Option < Ty < ' tcx > > ,
254259
255- /// Coroutine drop glue.
260+ /// Coroutine drop glue. This field is populated after the state transform pass.
256261 pub coroutine_drop : Option < Body < ' tcx > > ,
257262
258- /// The layout of a coroutine. Produced by the state transformation .
263+ /// The layout of a coroutine. This field is populated after the state transform pass .
259264 pub coroutine_layout : Option < CoroutineLayout < ' tcx > > ,
260265
261266 /// If this is a coroutine then record the type of source expression that caused this coroutine
@@ -303,6 +308,12 @@ pub struct Body<'tcx> {
303308 /// and used for debuginfo. Indexed by a `SourceScope`.
304309 pub source_scopes : IndexVec < SourceScope , SourceScopeData < ' tcx > > ,
305310
311+ /// Additional information carried by a MIR body when it is lowered from a coroutine.
312+ ///
313+ /// Note that the coroutine drop shim, any promoted consts, and other synthetic MIR
314+ /// bodies that come from processing a coroutine body are not typically coroutines
315+ /// themselves, and should probably set this to `None` to avoid carrying redundant
316+ /// information.
306317 pub coroutine : Option < Box < CoroutineInfo < ' tcx > > > ,
307318
308319 /// Declarations of locals.
0 commit comments