@@ -244,18 +244,23 @@ impl<'tcx> MirSource<'tcx> {
244
244
}
245
245
}
246
246
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.
247
252
#[ derive( Clone , TyEncodable , TyDecodable , Debug , HashStable , TypeFoldable , TypeVisitable ) ]
248
253
pub 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 .
250
255
pub yield_ty : Option < Ty < ' tcx > > ,
251
256
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 .
253
258
pub resume_ty : Option < Ty < ' tcx > > ,
254
259
255
- /// Coroutine drop glue.
260
+ /// Coroutine drop glue. This field is populated after the state transform pass.
256
261
pub coroutine_drop : Option < Body < ' tcx > > ,
257
262
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 .
259
264
pub coroutine_layout : Option < CoroutineLayout < ' tcx > > ,
260
265
261
266
/// If this is a coroutine then record the type of source expression that caused this coroutine
@@ -303,6 +308,12 @@ pub struct Body<'tcx> {
303
308
/// and used for debuginfo. Indexed by a `SourceScope`.
304
309
pub source_scopes : IndexVec < SourceScope , SourceScopeData < ' tcx > > ,
305
310
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.
306
317
pub coroutine : Option < Box < CoroutineInfo < ' tcx > > > ,
307
318
308
319
/// Declarations of locals.
0 commit comments