@@ -188,7 +188,7 @@ impl ExprCollector<'_> {
188
188
param_list. self_param ( ) . filter ( |_| attr_enabled. next ( ) . unwrap_or ( false ) )
189
189
{
190
190
let ptr = AstPtr :: new ( & self_param) ;
191
- let binding_id = self . alloc_binding (
191
+ let binding_id: la_arena :: Idx < Binding > = self . alloc_binding (
192
192
name ! [ self ] ,
193
193
BindingAnnotation :: new (
194
194
self_param. mut_token ( ) . is_some ( ) && self_param. amp_token ( ) . is_none ( ) ,
@@ -745,16 +745,14 @@ impl ExprCollector<'_> {
745
745
/// }
746
746
/// ```
747
747
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 {
758
756
// Some of the needed lang items are missing, so we can't desugar
759
757
return self . alloc_expr ( Expr :: Missing , syntax_ptr) ;
760
758
} ;
@@ -787,8 +785,8 @@ impl ExprCollector<'_> {
787
785
} ) ,
788
786
} ;
789
787
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 ( ) ) ;
792
790
let iter_expr_mut = self . alloc_expr (
793
791
Expr :: Ref { expr : iter_expr, rawness : Rawness :: Ref , mutability : Mutability :: Mut } ,
794
792
syntax_ptr. clone ( ) ,
@@ -808,7 +806,9 @@ impl ExprCollector<'_> {
808
806
) ;
809
807
let loop_outer =
810
808
self . alloc_expr ( Expr :: Loop { body : loop_inner, label } , syntax_ptr. clone ( ) ) ;
809
+ let iter_binding = self . alloc_binding ( iter_name, BindingAnnotation :: Mutable ) ;
811
810
let iter_pat = self . alloc_pat_desugared ( Pat :: Bind { id : iter_binding, subpat : None } ) ;
811
+ self . add_definition_to_binding ( iter_binding, iter_pat) ;
812
812
self . alloc_expr (
813
813
Expr :: Match {
814
814
expr : iterator,
@@ -830,18 +830,14 @@ impl ExprCollector<'_> {
830
830
/// }
831
831
/// ```
832
832
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 {
845
841
// Some of the needed lang items are missing, so we can't desugar
846
842
return self . alloc_expr ( Expr :: Missing , syntax_ptr) ;
847
843
} ;
0 commit comments