@@ -127,8 +127,8 @@ pub trait InferCtxtExt<'tcx> {
127
127
scope_span : & Option < Span > ,
128
128
expr : Option < hir:: HirId > ,
129
129
snippet : String ,
130
- first_generator : DefId ,
131
- last_generator : Option < DefId > ,
130
+ inner_generator : DefId ,
131
+ outer_generator : Option < DefId > ,
132
132
trait_ref : ty:: TraitRef < ' _ > ,
133
133
target_ty : Ty < ' tcx > ,
134
134
tables : & ty:: TypeckTables < ' _ > ,
@@ -1118,16 +1118,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1118
1118
// - `BindingObligation` with `impl_send (Send requirement)
1119
1119
//
1120
1120
// The first obligation in the chain is the most useful and has the generator that captured
1121
- // the type. The last generator has information about where the bound was introduced. At
1122
- // least one generator should be present for this diagnostic to be modified.
1121
+ // the type. The last generator (`outer_generator` below) has information about where the
1122
+ // bound was introduced. At least one generator should be present for this diagnostic to be
1123
+ // modified.
1123
1124
let ( mut trait_ref, mut target_ty) = match obligation. predicate {
1124
1125
ty:: Predicate :: Trait ( p, _) => {
1125
1126
( Some ( p. skip_binder ( ) . trait_ref ) , Some ( p. skip_binder ( ) . self_ty ( ) ) )
1126
1127
}
1127
1128
_ => ( None , None ) ,
1128
1129
} ;
1129
1130
let mut generator = None ;
1130
- let mut last_generator = None ;
1131
+ let mut outer_generator = None ;
1131
1132
let mut next_code = Some ( & obligation. cause . code ) ;
1132
1133
while let Some ( code) = next_code {
1133
1134
debug ! ( "maybe_note_obligation_cause_for_async_await: code={:?}" , code) ;
@@ -1144,7 +1145,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1144
1145
match ty. kind {
1145
1146
ty:: Generator ( did, ..) => {
1146
1147
generator = generator. or ( Some ( did) ) ;
1147
- last_generator = Some ( did) ;
1148
+ outer_generator = Some ( did) ;
1148
1149
}
1149
1150
ty:: GeneratorWitness ( ..) => { }
1150
1151
_ if generator. is_none ( ) => {
@@ -1248,7 +1249,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1248
1249
* expr,
1249
1250
snippet,
1250
1251
generator_did,
1251
- last_generator ,
1252
+ outer_generator ,
1252
1253
trait_ref,
1253
1254
target_ty,
1254
1255
tables,
@@ -1270,8 +1271,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1270
1271
scope_span : & Option < Span > ,
1271
1272
expr : Option < hir:: HirId > ,
1272
1273
snippet : String ,
1273
- first_generator : DefId ,
1274
- last_generator : Option < DefId > ,
1274
+ inner_generator : DefId ,
1275
+ outer_generator : Option < DefId > ,
1275
1276
trait_ref : ty:: TraitRef < ' _ > ,
1276
1277
target_ty : Ty < ' tcx > ,
1277
1278
tables : & ty:: TypeckTables < ' _ > ,
@@ -1282,14 +1283,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1282
1283
1283
1284
let is_async_fn = self
1284
1285
. tcx
1285
- . parent ( first_generator )
1286
+ . parent ( inner_generator )
1286
1287
. map ( |parent_did| self . tcx . asyncness ( parent_did) )
1287
1288
. map ( |parent_asyncness| parent_asyncness == hir:: IsAsync :: Async )
1288
1289
. unwrap_or ( false ) ;
1289
1290
let is_async_move = self
1290
1291
. tcx
1291
1292
. hir ( )
1292
- . as_local_hir_id ( first_generator )
1293
+ . as_local_hir_id ( inner_generator )
1293
1294
. and_then ( |hir_id| self . tcx . hir ( ) . maybe_body_owned_by ( hir_id) )
1294
1295
. map ( |body_id| self . tcx . hir ( ) . body ( body_id) )
1295
1296
. and_then ( |body| body. generator_kind ( ) )
@@ -1318,7 +1319,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1318
1319
let original_span = err. span . primary_span ( ) . unwrap ( ) ;
1319
1320
let mut span = MultiSpan :: from_span ( original_span) ;
1320
1321
1321
- let message = if let Some ( name) = last_generator
1322
+ let message = if let Some ( name) = outer_generator
1322
1323
. and_then ( |generator_did| self . tcx . parent ( generator_did) )
1323
1324
. and_then ( |parent_did| hir. as_local_hir_id ( parent_did) )
1324
1325
. and_then ( |parent_hir_id| hir. opt_name ( parent_hir_id) )
0 commit comments