1
+ use crate :: { FnDeclKind , ImplTraitPosition } ;
2
+
1
3
use super :: { ImplTraitContext , LoweringContext , ParamMode , ParenthesizedGenericArgs } ;
2
4
3
5
use rustc_ast:: attr;
@@ -53,7 +55,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
53
55
ParamMode :: Optional ,
54
56
0 ,
55
57
ParenthesizedGenericArgs :: Err ,
56
- ImplTraitContext :: disallowed ( ) ,
58
+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
57
59
) ) ;
58
60
let args = self . lower_exprs ( args) ;
59
61
hir:: ExprKind :: MethodCall ( hir_seg, args, self . lower_span ( span) )
@@ -74,12 +76,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
74
76
}
75
77
ExprKind :: Cast ( ref expr, ref ty) => {
76
78
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 ) ) ;
78
81
hir:: ExprKind :: Cast ( expr, ty)
79
82
}
80
83
ExprKind :: Type ( ref expr, ref ty) => {
81
84
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 ) ) ;
83
87
hir:: ExprKind :: Type ( expr, ty)
84
88
}
85
89
ExprKind :: AddrOf ( k, m, ref ohs) => {
@@ -203,7 +207,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
203
207
qself,
204
208
path,
205
209
ParamMode :: Optional ,
206
- ImplTraitContext :: disallowed ( ) ,
210
+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
207
211
) ;
208
212
hir:: ExprKind :: Path ( qpath)
209
213
}
@@ -239,7 +243,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
239
243
& se. qself ,
240
244
& se. path ,
241
245
ParamMode :: Optional ,
242
- ImplTraitContext :: disallowed ( ) ,
246
+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
243
247
) ) ,
244
248
self . arena
245
249
. alloc_from_iter ( se. fields . iter ( ) . map ( |x| self . lower_expr_field ( x) ) ) ,
@@ -538,7 +542,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
538
542
body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
539
543
) -> hir:: ExprKind < ' hir > {
540
544
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
+ ) ,
542
548
None => hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ,
543
549
} ;
544
550
@@ -827,7 +833,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
827
833
} ) ;
828
834
829
835
// 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 ) ;
831
837
832
838
hir:: ExprKind :: Closure (
833
839
capture_clause,
@@ -919,7 +925,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
919
925
// We need to lower the declaration outside the new scope, because we
920
926
// have to conserve the state of being inside a loop condition for the
921
927
// 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 ) ;
923
929
924
930
hir:: ExprKind :: Closure (
925
931
capture_clause,
@@ -1064,7 +1070,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1064
1070
qself,
1065
1071
path,
1066
1072
ParamMode :: Optional ,
1067
- ImplTraitContext :: disallowed ( ) ,
1073
+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1068
1074
) ;
1069
1075
// Destructure like a tuple struct.
1070
1076
let tuple_struct_pat =
@@ -1089,7 +1095,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1089
1095
& se. qself ,
1090
1096
& se. path ,
1091
1097
ParamMode :: Optional ,
1092
- ImplTraitContext :: disallowed ( ) ,
1098
+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1093
1099
) ;
1094
1100
let fields_omitted = match & se. rest {
1095
1101
StructRest :: Base ( e) => {
0 commit comments