@@ -870,7 +870,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
870
870
self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
871
871
872
872
// Create a label rib for the function.
873
- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
873
+ match rib_kind {
874
+ ClosureRibKind ( _) => { }
875
+ _ => self . label_ribs . push ( Rib :: new ( rib_kind) ) ,
876
+ }
874
877
875
878
// Add each argument to the rib.
876
879
let mut bindings_list = FxHashMap :: default ( ) ;
@@ -900,7 +903,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
900
903
if let IsAsync :: Async { closure_id, .. } = asyncness {
901
904
let rib_kind = ClosureRibKind ( * closure_id) ;
902
905
self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
903
- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
904
906
}
905
907
906
908
match function_kind {
@@ -927,13 +929,17 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
927
929
928
930
// Leave the body of the async closure
929
931
if asyncness. is_async ( ) {
930
- self . label_ribs . pop ( ) ;
931
932
self . ribs [ ValueNS ] . pop ( ) ;
932
933
}
933
934
934
935
debug ! ( "(resolving function) leaving function" ) ;
935
936
936
- self . label_ribs . pop ( ) ;
937
+ match rib_kind {
938
+ ClosureRibKind ( _) => { }
939
+ _ => {
940
+ self . label_ribs . pop ( ) ;
941
+ }
942
+ }
937
943
self . ribs [ ValueNS ] . pop ( ) ;
938
944
}
939
945
@@ -2500,6 +2506,9 @@ impl<'a> Resolver<'a> {
2500
2506
for rib in self . label_ribs . iter ( ) . rev ( ) {
2501
2507
match rib. kind {
2502
2508
NormalRibKind => { }
2509
+ ClosureRibKind ( _) => {
2510
+ span_bug ! ( ident. span, "rustc_resolve: `ClosureRibKind` in `label_ribs`" ) ;
2511
+ }
2503
2512
// If an invocation of this macro created `ident`, give up on `ident`
2504
2513
// and switch to `ident`'s source from the macro definition.
2505
2514
MacroDefinition ( def) => {
@@ -4465,9 +4474,7 @@ impl<'a> Resolver<'a> {
4465
4474
ExprKind :: Async ( _, async_closure_id, ref block) => {
4466
4475
let rib_kind = ClosureRibKind ( async_closure_id) ;
4467
4476
self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
4468
- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
4469
4477
self . visit_block ( & block) ;
4470
- self . label_ribs . pop ( ) ;
4471
4478
self . ribs [ ValueNS ] . pop ( ) ;
4472
4479
}
4473
4480
// `async |x| ...` gets desugared to `|x| future_from_generator(|| ...)`, so we need to
@@ -4479,7 +4486,6 @@ impl<'a> Resolver<'a> {
4479
4486
) => {
4480
4487
let rib_kind = ClosureRibKind ( expr. id ) ;
4481
4488
self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
4482
- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
4483
4489
// Resolve arguments:
4484
4490
let mut bindings_list = FxHashMap :: default ( ) ;
4485
4491
for argument in & fn_decl. inputs {
@@ -4493,16 +4499,13 @@ impl<'a> Resolver<'a> {
4493
4499
{
4494
4500
let rib_kind = ClosureRibKind ( inner_closure_id) ;
4495
4501
self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
4496
- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
4497
4502
// No need to resolve arguments: the inner closure has none.
4498
4503
// Resolve the return type:
4499
4504
visit:: walk_fn_ret_ty ( self , & fn_decl. output ) ;
4500
4505
// Resolve the body
4501
4506
self . visit_expr ( body) ;
4502
- self . label_ribs . pop ( ) ;
4503
4507
self . ribs [ ValueNS ] . pop ( ) ;
4504
4508
}
4505
- self . label_ribs . pop ( ) ;
4506
4509
self . ribs [ ValueNS ] . pop ( ) ;
4507
4510
}
4508
4511
_ => {
0 commit comments