@@ -870,7 +870,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
870870 self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
871871
872872 // 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+ }
874877
875878 // Add each argument to the rib.
876879 let mut bindings_list = FxHashMap :: default ( ) ;
@@ -900,7 +903,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
900903 if let IsAsync :: Async { closure_id, .. } = asyncness {
901904 let rib_kind = ClosureRibKind ( * closure_id) ;
902905 self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
903- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
904906 }
905907
906908 match function_kind {
@@ -927,13 +929,17 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
927929
928930 // Leave the body of the async closure
929931 if asyncness. is_async ( ) {
930- self . label_ribs . pop ( ) ;
931932 self . ribs [ ValueNS ] . pop ( ) ;
932933 }
933934
934935 debug ! ( "(resolving function) leaving function" ) ;
935936
936- self . label_ribs . pop ( ) ;
937+ match rib_kind {
938+ ClosureRibKind ( _) => { }
939+ _ => {
940+ self . label_ribs . pop ( ) ;
941+ }
942+ }
937943 self . ribs [ ValueNS ] . pop ( ) ;
938944 }
939945
@@ -2500,6 +2506,9 @@ impl<'a> Resolver<'a> {
25002506 for rib in self . label_ribs . iter ( ) . rev ( ) {
25012507 match rib. kind {
25022508 NormalRibKind => { }
2509+ ClosureRibKind ( _) => {
2510+ span_bug ! ( ident. span, "rustc_resolve: `ClosureRibKind` in `label_ribs`" ) ;
2511+ }
25032512 // If an invocation of this macro created `ident`, give up on `ident`
25042513 // and switch to `ident`'s source from the macro definition.
25052514 MacroDefinition ( def) => {
@@ -4465,9 +4474,7 @@ impl<'a> Resolver<'a> {
44654474 ExprKind :: Async ( _, async_closure_id, ref block) => {
44664475 let rib_kind = ClosureRibKind ( async_closure_id) ;
44674476 self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
4468- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
44694477 self . visit_block ( & block) ;
4470- self . label_ribs . pop ( ) ;
44714478 self . ribs [ ValueNS ] . pop ( ) ;
44724479 }
44734480 // `async |x| ...` gets desugared to `|x| future_from_generator(|| ...)`, so we need to
@@ -4479,7 +4486,6 @@ impl<'a> Resolver<'a> {
44794486 ) => {
44804487 let rib_kind = ClosureRibKind ( expr. id ) ;
44814488 self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
4482- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
44834489 // Resolve arguments:
44844490 let mut bindings_list = FxHashMap :: default ( ) ;
44854491 for argument in & fn_decl. inputs {
@@ -4493,16 +4499,13 @@ impl<'a> Resolver<'a> {
44934499 {
44944500 let rib_kind = ClosureRibKind ( inner_closure_id) ;
44954501 self . ribs [ ValueNS ] . push ( Rib :: new ( rib_kind) ) ;
4496- self . label_ribs . push ( Rib :: new ( rib_kind) ) ;
44974502 // No need to resolve arguments: the inner closure has none.
44984503 // Resolve the return type:
44994504 visit:: walk_fn_ret_ty ( self , & fn_decl. output ) ;
45004505 // Resolve the body
45014506 self . visit_expr ( body) ;
4502- self . label_ribs . pop ( ) ;
45034507 self . ribs [ ValueNS ] . pop ( ) ;
45044508 }
4505- self . label_ribs . pop ( ) ;
45064509 self . ribs [ ValueNS ] . pop ( ) ;
45074510 }
45084511 _ => {
0 commit comments