@@ -188,7 +188,7 @@ impl ExprCollector<'_> {
188188 param_list. self_param ( ) . filter ( |_| attr_enabled. next ( ) . unwrap_or ( false ) )
189189 {
190190 let ptr = AstPtr :: new ( & self_param) ;
191- let binding_id = self . alloc_binding (
191+ let binding_id: la_arena :: Idx < Binding > = self . alloc_binding (
192192 name ! [ self ] ,
193193 BindingAnnotation :: new (
194194 self_param. mut_token ( ) . is_some ( ) && self_param. amp_token ( ) . is_none ( ) ,
@@ -745,16 +745,14 @@ impl ExprCollector<'_> {
745745 /// }
746746 /// ```
747747 fn collect_for_loop ( & mut self , syntax_ptr : AstPtr < ast:: Expr > , e : ast:: ForExpr ) -> ExprId {
748- let ( into_iter_fn, iter_next_fn, option_some, option_none) = ' if_chain: {
749- if let Some ( into_iter_fn) = LangItem :: IntoIterIntoIter . path ( self . db , self . krate ) {
750- if let Some ( iter_next_fn) = LangItem :: IteratorNext . path ( self . db , self . krate ) {
751- if let Some ( option_some) = LangItem :: OptionSome . path ( self . db , self . krate ) {
752- if let Some ( option_none) = LangItem :: OptionNone . path ( self . db , self . krate ) {
753- break ' if_chain ( into_iter_fn, iter_next_fn, option_some, option_none) ;
754- }
755- }
756- }
757- }
748+ let Some ( ( into_iter_fn, iter_next_fn, option_some, option_none) ) = ( || {
749+ Some ( (
750+ LangItem :: IntoIterIntoIter . path ( self . db , self . krate ) ?,
751+ LangItem :: IteratorNext . path ( self . db , self . krate ) ?,
752+ LangItem :: OptionSome . path ( self . db , self . krate ) ?,
753+ LangItem :: OptionNone . path ( self . db , self . krate ) ?,
754+ ) )
755+ } ) ( ) else {
758756 // Some of the needed lang items are missing, so we can't desugar
759757 return self . alloc_expr ( Expr :: Missing , syntax_ptr) ;
760758 } ;
@@ -787,8 +785,8 @@ impl ExprCollector<'_> {
787785 } ) ,
788786 } ;
789787 let iter_name = Name :: generate_new_name ( ) ;
790- let iter_binding = self . alloc_binding ( iter_name . clone ( ) , BindingAnnotation :: Mutable ) ;
791- let iter_expr = self . alloc_expr ( Expr :: Path ( Path :: from ( iter_name) ) , syntax_ptr. clone ( ) ) ;
788+ let iter_expr =
789+ self . alloc_expr ( Expr :: Path ( Path :: from ( iter_name. clone ( ) ) ) , syntax_ptr. clone ( ) ) ;
792790 let iter_expr_mut = self . alloc_expr (
793791 Expr :: Ref { expr : iter_expr, rawness : Rawness :: Ref , mutability : Mutability :: Mut } ,
794792 syntax_ptr. clone ( ) ,
@@ -808,7 +806,9 @@ impl ExprCollector<'_> {
808806 ) ;
809807 let loop_outer =
810808 self . alloc_expr ( Expr :: Loop { body : loop_inner, label } , syntax_ptr. clone ( ) ) ;
809+ let iter_binding = self . alloc_binding ( iter_name, BindingAnnotation :: Mutable ) ;
811810 let iter_pat = self . alloc_pat_desugared ( Pat :: Bind { id : iter_binding, subpat : None } ) ;
811+ self . add_definition_to_binding ( iter_binding, iter_pat) ;
812812 self . alloc_expr (
813813 Expr :: Match {
814814 expr : iterator,
@@ -830,18 +830,14 @@ impl ExprCollector<'_> {
830830 /// }
831831 /// ```
832832 fn collect_try_operator ( & mut self , syntax_ptr : AstPtr < ast:: Expr > , e : ast:: TryExpr ) -> ExprId {
833- let ( try_branch, cf_continue, cf_break, try_from_residual) = ' if_chain: {
834- if let Some ( try_branch) = LangItem :: TryTraitBranch . path ( self . db , self . krate ) {
835- if let Some ( cf_continue) = LangItem :: ControlFlowContinue . path ( self . db , self . krate ) {
836- if let Some ( cf_break) = LangItem :: ControlFlowBreak . path ( self . db , self . krate ) {
837- if let Some ( try_from_residual) =
838- LangItem :: TryTraitFromResidual . path ( self . db , self . krate )
839- {
840- break ' if_chain ( try_branch, cf_continue, cf_break, try_from_residual) ;
841- }
842- }
843- }
844- }
833+ let Some ( ( try_branch, cf_continue, cf_break, try_from_residual) ) = ( || {
834+ Some ( (
835+ LangItem :: TryTraitBranch . path ( self . db , self . krate ) ?,
836+ LangItem :: ControlFlowContinue . path ( self . db , self . krate ) ?,
837+ LangItem :: ControlFlowBreak . path ( self . db , self . krate ) ?,
838+ LangItem :: TryTraitFromResidual . path ( self . db , self . krate ) ?,
839+ ) )
840+ } ) ( ) else {
845841 // Some of the needed lang items are missing, so we can't desugar
846842 return self . alloc_expr ( Expr :: Missing , syntax_ptr) ;
847843 } ;
0 commit comments