@@ -92,24 +92,6 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
92
92
93
93
let mut error = false ;
94
94
let main_diagnostics_def_id = main_fn_diagnostics_def_id ( tcx, main_def_id, main_span) ;
95
- let main_fn_generics = tcx. generics_of ( main_def_id) ;
96
- let main_fn_predicates = tcx. predicates_of ( main_def_id) ;
97
- if main_fn_generics. count ( ) != 0 || !main_fnsig. bound_vars ( ) . is_empty ( ) {
98
- let generics_param_span = main_fn_generics_params_span ( tcx, main_def_id) ;
99
- tcx. sess . emit_err ( errors:: MainFunctionGenericParameters {
100
- span : generics_param_span. unwrap_or ( main_span) ,
101
- label_span : generics_param_span,
102
- } ) ;
103
- error = true ;
104
- } else if !main_fn_predicates. predicates . is_empty ( ) {
105
- // generics may bring in implicit predicates, so we skip this check if generics is present.
106
- let generics_where_clauses_span = main_fn_where_clauses_span ( tcx, main_def_id) ;
107
- tcx. sess . emit_err ( errors:: WhereClauseOnMain {
108
- span : generics_where_clauses_span. unwrap_or ( main_span) ,
109
- generics_span : generics_where_clauses_span,
110
- } ) ;
111
- error = true ;
112
- }
113
95
114
96
let main_asyncness = tcx. asyncness ( main_def_id) ;
115
97
if main_asyncness. is_async ( ) {
@@ -142,10 +124,6 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
142
124
if let Some ( term_did) = tcx. lang_items ( ) . termination ( ) {
143
125
let return_ty = main_fnsig. output ( ) ;
144
126
let return_ty_span = main_fn_return_type_span ( tcx, main_def_id) . unwrap_or ( main_span) ;
145
- if !return_ty. bound_vars ( ) . is_empty ( ) {
146
- tcx. sess . emit_err ( errors:: MainFunctionReturnTypeGeneric { span : return_ty_span } ) ;
147
- error = true ;
148
- }
149
127
let return_ty = return_ty. skip_binder ( ) ;
150
128
let infcx = tcx. infer_ctxt ( ) . build ( ) ;
151
129
let cause = traits:: ObligationCause :: new (
@@ -190,6 +168,23 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
190
168
main_def_id,
191
169
expected_sig,
192
170
) ;
171
+
172
+ let main_fn_generics = tcx. generics_of ( main_def_id) ;
173
+ let main_fn_predicates = tcx. predicates_of ( main_def_id) ;
174
+ if main_fn_generics. count ( ) != 0 || !main_fnsig. bound_vars ( ) . is_empty ( ) {
175
+ let generics_param_span = main_fn_generics_params_span ( tcx, main_def_id) ;
176
+ tcx. sess . emit_err ( errors:: MainFunctionGenericParameters {
177
+ span : generics_param_span. unwrap_or ( main_span) ,
178
+ label_span : generics_param_span,
179
+ } ) ;
180
+ } else if !main_fn_predicates. predicates . is_empty ( ) {
181
+ // generics may bring in implicit predicates, so we skip this check if generics is present.
182
+ let generics_where_clauses_span = main_fn_where_clauses_span ( tcx, main_def_id) ;
183
+ tcx. sess . emit_err ( errors:: WhereClauseOnMain {
184
+ span : generics_where_clauses_span. unwrap_or ( main_span) ,
185
+ generics_span : generics_where_clauses_span,
186
+ } ) ;
187
+ }
193
188
}
194
189
195
190
fn check_start_fn_ty ( tcx : TyCtxt < ' _ > , start_def_id : DefId ) {
0 commit comments