@@ -126,8 +126,8 @@ crate trait InferCtxtExt<'tcx> {
126
126
scope_span : & Option < Span > ,
127
127
expr : Option < hir:: HirId > ,
128
128
snippet : String ,
129
- first_generator : DefId ,
130
- last_generator : Option < DefId > ,
129
+ inner_generator : DefId ,
130
+ outer_generator : Option < DefId > ,
131
131
trait_ref : ty:: TraitRef < ' _ > ,
132
132
target_ty : Ty < ' tcx > ,
133
133
tables : & ty:: TypeckTables < ' _ > ,
@@ -1003,16 +1003,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1003
1003
// - `BindingObligation` with `impl_send (Send requirement)
1004
1004
//
1005
1005
// The first obligation in the chain is the most useful and has the generator that captured
1006
- // the type. The last generator has information about where the bound was introduced. At
1007
- // least one generator should be present for this diagnostic to be modified.
1006
+ // the type. The last generator (`outer_generator` below) has information about where the
1007
+ // bound was introduced. At least one generator should be present for this diagnostic to be
1008
+ // modified.
1008
1009
let ( mut trait_ref, mut target_ty) = match obligation. predicate {
1009
1010
ty:: Predicate :: Trait ( p, _) => {
1010
1011
( Some ( p. skip_binder ( ) . trait_ref ) , Some ( p. skip_binder ( ) . self_ty ( ) ) )
1011
1012
}
1012
1013
_ => ( None , None ) ,
1013
1014
} ;
1014
1015
let mut generator = None ;
1015
- let mut last_generator = None ;
1016
+ let mut outer_generator = None ;
1016
1017
let mut next_code = Some ( & obligation. cause . code ) ;
1017
1018
while let Some ( code) = next_code {
1018
1019
debug ! ( "maybe_note_obligation_cause_for_async_await: code={:?}" , code) ;
@@ -1029,7 +1030,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1029
1030
match ty. kind {
1030
1031
ty:: Generator ( did, ..) => {
1031
1032
generator = generator. or ( Some ( did) ) ;
1032
- last_generator = Some ( did) ;
1033
+ outer_generator = Some ( did) ;
1033
1034
}
1034
1035
ty:: GeneratorWitness ( ..) => { }
1035
1036
_ if generator. is_none ( ) => {
@@ -1133,7 +1134,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1133
1134
* expr,
1134
1135
snippet,
1135
1136
generator_did,
1136
- last_generator ,
1137
+ outer_generator ,
1137
1138
trait_ref,
1138
1139
target_ty,
1139
1140
tables,
@@ -1155,8 +1156,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1155
1156
scope_span : & Option < Span > ,
1156
1157
expr : Option < hir:: HirId > ,
1157
1158
snippet : String ,
1158
- first_generator : DefId ,
1159
- last_generator : Option < DefId > ,
1159
+ inner_generator : DefId ,
1160
+ outer_generator : Option < DefId > ,
1160
1161
trait_ref : ty:: TraitRef < ' _ > ,
1161
1162
target_ty : Ty < ' tcx > ,
1162
1163
tables : & ty:: TypeckTables < ' _ > ,
@@ -1167,14 +1168,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1167
1168
1168
1169
let is_async_fn = self
1169
1170
. tcx
1170
- . parent ( first_generator )
1171
+ . parent ( inner_generator )
1171
1172
. map ( |parent_did| self . tcx . asyncness ( parent_did) )
1172
1173
. map ( |parent_asyncness| parent_asyncness == hir:: IsAsync :: Async )
1173
1174
. unwrap_or ( false ) ;
1174
1175
let is_async_move = self
1175
1176
. tcx
1176
1177
. hir ( )
1177
- . as_local_hir_id ( first_generator )
1178
+ . as_local_hir_id ( inner_generator )
1178
1179
. and_then ( |hir_id| self . tcx . hir ( ) . maybe_body_owned_by ( hir_id) )
1179
1180
. map ( |body_id| self . tcx . hir ( ) . body ( body_id) )
1180
1181
. and_then ( |body| body. generator_kind ( ) )
@@ -1203,7 +1204,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1203
1204
let original_span = err. span . primary_span ( ) . unwrap ( ) ;
1204
1205
let mut span = MultiSpan :: from_span ( original_span) ;
1205
1206
1206
- let message = if let Some ( name) = last_generator
1207
+ let message = if let Some ( name) = outer_generator
1207
1208
. and_then ( |generator_did| self . tcx . parent ( generator_did) )
1208
1209
. and_then ( |parent_did| hir. as_local_hir_id ( parent_did) )
1209
1210
. and_then ( |parent_hir_id| hir. opt_name ( parent_hir_id) )
0 commit comments