1+ use  crate :: { FnDeclKind ,  ImplTraitPosition } ; 
2+ 
13use  super :: { ImplTraitContext ,  LoweringContext ,  ParamMode ,  ParenthesizedGenericArgs } ; 
24
35use  rustc_ast:: attr; 
@@ -53,7 +55,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
5355                        ParamMode :: Optional , 
5456                        0 , 
5557                        ParenthesizedGenericArgs :: Err , 
56-                         ImplTraitContext :: disallowed ( ) , 
58+                         ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) , 
5759                    ) ) ; 
5860                    let  args = self . lower_exprs ( args) ; 
5961                    hir:: ExprKind :: MethodCall ( hir_seg,  args,  self . lower_span ( span) ) 
@@ -74,12 +76,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
7476                } 
7577                ExprKind :: Cast ( ref  expr,  ref  ty)  => { 
7678                    let  expr = self . lower_expr ( expr) ; 
77-                     let  ty = self . lower_ty ( ty,  ImplTraitContext :: disallowed ( ) ) ; 
79+                     let  ty =
80+                         self . lower_ty ( ty,  ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ; 
7881                    hir:: ExprKind :: Cast ( expr,  ty) 
7982                } 
8083                ExprKind :: Type ( ref  expr,  ref  ty)  => { 
8184                    let  expr = self . lower_expr ( expr) ; 
82-                     let  ty = self . lower_ty ( ty,  ImplTraitContext :: disallowed ( ) ) ; 
85+                     let  ty =
86+                         self . lower_ty ( ty,  ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ; 
8387                    hir:: ExprKind :: Type ( expr,  ty) 
8488                } 
8589                ExprKind :: AddrOf ( k,  m,  ref  ohs)  => { 
@@ -203,7 +207,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
203207                        qself, 
204208                        path, 
205209                        ParamMode :: Optional , 
206-                         ImplTraitContext :: disallowed ( ) , 
210+                         ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) , 
207211                    ) ; 
208212                    hir:: ExprKind :: Path ( qpath) 
209213                } 
@@ -239,7 +243,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
239243                            & se. qself , 
240244                            & se. path , 
241245                            ParamMode :: Optional , 
242-                             ImplTraitContext :: disallowed ( ) , 
246+                             ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) , 
243247                        ) ) , 
244248                        self . arena 
245249                            . alloc_from_iter ( se. fields . iter ( ) . map ( |x| self . lower_expr_field ( x) ) ) , 
@@ -538,7 +542,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
538542        body :  impl  FnOnce ( & mut  Self )  -> hir:: Expr < ' hir > , 
539543    )  -> hir:: ExprKind < ' hir >  { 
540544        let  output = match  ret_ty { 
541-             Some ( ty)  => hir:: FnRetTy :: Return ( self . lower_ty ( & ty,  ImplTraitContext :: disallowed ( ) ) ) , 
545+             Some ( ty)  => hir:: FnRetTy :: Return ( 
546+                 self . lower_ty ( & ty,  ImplTraitContext :: Disallowed ( ImplTraitPosition :: AsyncBlock ) ) , 
547+             ) , 
542548            None  => hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) , 
543549        } ; 
544550
@@ -827,7 +833,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
827833        } ) ; 
828834
829835        // Lower outside new scope to preserve `is_in_loop_condition`. 
830-         let  fn_decl = self . lower_fn_decl ( decl,  None ,  false ,  None ) ; 
836+         let  fn_decl = self . lower_fn_decl ( decl,  None ,  FnDeclKind :: Closure ,  None ) ; 
831837
832838        hir:: ExprKind :: Closure ( 
833839            capture_clause, 
@@ -919,7 +925,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
919925        // We need to lower the declaration outside the new scope, because we 
920926        // have to conserve the state of being inside a loop condition for the 
921927        // closure argument types. 
922-         let  fn_decl = self . lower_fn_decl ( & outer_decl,  None ,  false ,  None ) ; 
928+         let  fn_decl = self . lower_fn_decl ( & outer_decl,  None ,  FnDeclKind :: Closure ,  None ) ; 
923929
924930        hir:: ExprKind :: Closure ( 
925931            capture_clause, 
@@ -1064,7 +1070,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10641070                        qself, 
10651071                        path, 
10661072                        ParamMode :: Optional , 
1067-                         ImplTraitContext :: disallowed ( ) , 
1073+                         ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) , 
10681074                    ) ; 
10691075                    // Destructure like a tuple struct. 
10701076                    let  tuple_struct_pat =
@@ -1089,7 +1095,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10891095                    & se. qself , 
10901096                    & se. path , 
10911097                    ParamMode :: Optional , 
1092-                     ImplTraitContext :: disallowed ( ) , 
1098+                     ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) , 
10931099                ) ; 
10941100                let  fields_omitted = match  & se. rest  { 
10951101                    StructRest :: Base ( e)  => { 
0 commit comments