@@ -67,7 +67,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
67
67
local,
68
68
projection : [ proj_base @ .., ProjectionElem :: Field ( upvar_index, _) ] ,
69
69
} => {
70
- debug_assert ! ( is_closure_or_coroutine (
70
+ debug_assert ! ( is_closure_like (
71
71
Place :: ty_from( local, proj_base, self . body, self . infcx. tcx) . ty
72
72
) ) ;
73
73
@@ -126,9 +126,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
126
126
{
127
127
item_msg = access_place_desc;
128
128
debug_assert ! ( self . body. local_decls[ ty:: CAPTURE_STRUCT_LOCAL ] . ty. is_ref( ) ) ;
129
- debug_assert ! ( is_closure_or_coroutine(
130
- the_place_err. ty( self . body, self . infcx. tcx) . ty
131
- ) ) ;
129
+ debug_assert ! ( is_closure_like( the_place_err. ty( self . body, self . infcx. tcx) . ty) ) ;
132
130
133
131
reason = if self . is_upvar_field_projection ( access_place. as_ref ( ) ) . is_some ( ) {
134
132
", as it is a captured variable in a `Fn` closure" . to_string ( )
@@ -389,7 +387,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
389
387
local,
390
388
projection : [ proj_base @ .., ProjectionElem :: Field ( upvar_index, _) ] ,
391
389
} => {
392
- debug_assert ! ( is_closure_or_coroutine (
390
+ debug_assert ! ( is_closure_like (
393
391
Place :: ty_from( local, proj_base, self . body, self . infcx. tcx) . ty
394
392
) ) ;
395
393
@@ -1474,7 +1472,8 @@ fn suggest_ampmut<'tcx>(
1474
1472
}
1475
1473
}
1476
1474
1477
- fn is_closure_or_coroutine ( ty : Ty < ' _ > ) -> bool {
1475
+ /// If the type is a `Coroutine`, `Closure`, or `CoroutineClosure`
1476
+ fn is_closure_like ( ty : Ty < ' _ > ) -> bool {
1478
1477
ty. is_closure ( ) || ty. is_coroutine ( ) || ty. is_coroutine_closure ( )
1479
1478
}
1480
1479
0 commit comments