@@ -66,7 +66,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
6666 seg,
6767 ParamMode :: Optional ,
6868 ParenthesizedGenericArgs :: Err ,
69- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
69+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
7070 ) ) ;
7171 let receiver = self . lower_expr ( receiver) ;
7272 let args =
@@ -89,14 +89,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
8989 }
9090 ExprKind :: Cast ( ref expr, ref ty) => {
9191 let expr = self . lower_expr ( expr) ;
92- let ty = self
93- . lower_ty ( ty, & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
92+ let ty =
93+ self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
9494 hir:: ExprKind :: Cast ( expr, ty)
9595 }
9696 ExprKind :: Type ( ref expr, ref ty) => {
9797 let expr = self . lower_expr ( expr) ;
98- let ty = self
99- . lower_ty ( ty, & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
98+ let ty =
99+ self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
100100 hir:: ExprKind :: Type ( expr, ty)
101101 }
102102 ExprKind :: AddrOf ( k, m, ref ohs) => {
@@ -225,7 +225,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
225225 qself,
226226 path,
227227 ParamMode :: Optional ,
228- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
228+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
229229 ) ;
230230 hir:: ExprKind :: Path ( qpath)
231231 }
@@ -259,7 +259,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
259259 & se. qself ,
260260 & se. path ,
261261 ParamMode :: Optional ,
262- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
262+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
263263 ) ) ,
264264 self . arena
265265 . alloc_from_iter ( se. fields . iter ( ) . map ( |x| self . lower_expr_field ( x) ) ) ,
@@ -556,14 +556,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
556556 async_gen_kind : hir:: AsyncGeneratorKind ,
557557 body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
558558 ) -> hir:: ExprKind < ' hir > {
559- let output =
560- match ret_ty {
561- Some ( ty) => hir:: FnRetTy :: Return ( self . lower_ty (
562- & ty,
563- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: AsyncBlock ) ,
564- ) ) ,
565- None => hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ,
566- } ;
559+ let output = match ret_ty {
560+ Some ( ty) => hir:: FnRetTy :: Return (
561+ self . lower_ty ( & ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: AsyncBlock ) ) ,
562+ ) ,
563+ None => hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ,
564+ } ;
567565
568566 // Resume argument type. We let the compiler infer this to simplify the lowering. It is
569567 // fully constrained by `future::from_generator`.
@@ -855,22 +853,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
855853 ( body_id, generator_option)
856854 } ) ;
857855
858- self . lower_lifetime_binder ( closure_id, generic_params, |lctx , bound_generic_params| {
859- // Lower outside new scope to preserve `is_in_loop_condition`.
860- let fn_decl = lctx . lower_fn_decl ( decl, None , fn_decl_span, FnDeclKind :: Closure , None ) ;
861-
862- let c = lctx . arena . alloc ( hir:: Closure {
863- binder : binder_clause,
864- capture_clause,
865- bound_generic_params,
866- fn_decl,
867- body : body_id,
868- fn_decl_span : lctx . lower_span ( fn_decl_span) ,
869- movability : generator_option,
870- } ) ;
856+ let bound_generic_params = self . lower_lifetime_binder ( closure_id, generic_params) ;
857+ // Lower outside new scope to preserve `is_in_loop_condition`.
858+ let fn_decl = self . lower_fn_decl ( decl, None , fn_decl_span, FnDeclKind :: Closure , None ) ;
859+
860+ let c = self . arena . alloc ( hir:: Closure {
861+ binder : binder_clause,
862+ capture_clause,
863+ bound_generic_params,
864+ fn_decl,
865+ body : body_id,
866+ fn_decl_span : self . lower_span ( fn_decl_span) ,
867+ movability : generator_option,
868+ } ) ;
871869
872- hir:: ExprKind :: Closure ( c)
873- } )
870+ hir:: ExprKind :: Closure ( c)
874871 }
875872
876873 fn generator_movability_for_fn (
@@ -957,24 +954,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
957954 body_id
958955 } ) ;
959956
960- self . lower_lifetime_binder ( closure_id, generic_params, |lctx, bound_generic_params| {
961- // We need to lower the declaration outside the new scope, because we
962- // have to conserve the state of being inside a loop condition for the
963- // closure argument types.
964- let fn_decl =
965- lctx. lower_fn_decl ( & outer_decl, None , fn_decl_span, FnDeclKind :: Closure , None ) ;
966-
967- let c = lctx. arena . alloc ( hir:: Closure {
968- binder : binder_clause,
969- capture_clause,
970- bound_generic_params,
971- fn_decl,
972- body,
973- fn_decl_span : lctx. lower_span ( fn_decl_span) ,
974- movability : None ,
975- } ) ;
976- hir:: ExprKind :: Closure ( c)
977- } )
957+ let bound_generic_params = self . lower_lifetime_binder ( closure_id, generic_params) ;
958+ // We need to lower the declaration outside the new scope, because we
959+ // have to conserve the state of being inside a loop condition for the
960+ // closure argument types.
961+ let fn_decl =
962+ self . lower_fn_decl ( & outer_decl, None , fn_decl_span, FnDeclKind :: Closure , None ) ;
963+
964+ let c = self . arena . alloc ( hir:: Closure {
965+ binder : binder_clause,
966+ capture_clause,
967+ bound_generic_params,
968+ fn_decl,
969+ body,
970+ fn_decl_span : self . lower_span ( fn_decl_span) ,
971+ movability : None ,
972+ } ) ;
973+ hir:: ExprKind :: Closure ( c)
978974 }
979975
980976 /// Destructure the LHS of complex assignments.
@@ -1133,7 +1129,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11331129 qself,
11341130 path,
11351131 ParamMode :: Optional ,
1136- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1132+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
11371133 ) ;
11381134 // Destructure like a tuple struct.
11391135 let tuple_struct_pat = hir:: PatKind :: TupleStruct (
@@ -1152,7 +1148,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11521148 qself,
11531149 path,
11541150 ParamMode :: Optional ,
1155- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1151+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
11561152 ) ;
11571153 // Destructure like a unit struct.
11581154 let unit_struct_pat = hir:: PatKind :: Path ( qpath) ;
@@ -1176,7 +1172,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11761172 & se. qself ,
11771173 & se. path ,
11781174 ParamMode :: Optional ,
1179- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1175+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
11801176 ) ;
11811177 let fields_omitted = match & se. rest {
11821178 StructRest :: Base ( e) => {
0 commit comments