@@ -186,18 +186,23 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
186
186
Some ( hir_map:: NodeItem ( it) ) => {
187
187
match it. node {
188
188
hir:: ItemFn ( .., ref generics, _) => {
189
+ let mut error = false ;
189
190
if !generics. params . is_empty ( ) {
190
191
struct_span_err ! ( tcx. sess, generics. span, E0131 ,
191
- " main function is not allowed to have type parameters")
192
+ "` main` function is not allowed to have type parameters")
192
193
. span_label ( generics. span ,
193
- "main cannot have type parameters" )
194
+ "` main` cannot have type parameters" )
194
195
. emit ( ) ;
195
- return ;
196
+ error = true ;
197
+ }
198
+ if let Some ( sp) = generics. where_clause . span ( ) {
199
+ struct_span_err ! ( tcx. sess, sp, E0646 ,
200
+ "`main` function is not allowed to have a `where` clause" )
201
+ . span_label ( sp, "`main` cannot have a `where` clause" )
202
+ . emit ( ) ;
203
+ error = true ;
196
204
}
197
- if !generics. where_clause . predicates . is_empty ( ) {
198
- struct_span_err ! ( tcx. sess, main_span, E0646 ,
199
- "main function is not allowed to have a where clause" )
200
- . emit ( ) ;
205
+ if error {
201
206
return ;
202
207
}
203
208
}
@@ -251,19 +256,24 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
251
256
match tcx. hir . find ( start_id) {
252
257
Some ( hir_map:: NodeItem ( it) ) => {
253
258
match it. node {
254
- hir:: ItemFn ( .., ref ps, _) => {
255
- if !ps. params . is_empty ( ) {
256
- struct_span_err ! ( tcx. sess, ps. span, E0132 ,
259
+ hir:: ItemFn ( .., ref generics, _) => {
260
+ let mut error = false ;
261
+ if !generics. params . is_empty ( ) {
262
+ struct_span_err ! ( tcx. sess, generics. span, E0132 ,
257
263
"start function is not allowed to have type parameters" )
258
- . span_label ( ps . span ,
264
+ . span_label ( generics . span ,
259
265
"start function cannot have type parameters" )
260
266
. emit ( ) ;
261
- return ;
267
+ error = true ;
268
+ }
269
+ if let Some ( sp) = generics. where_clause . span ( ) {
270
+ struct_span_err ! ( tcx. sess, sp, E0647 ,
271
+ "start function is not allowed to have a `where` clause" )
272
+ . span_label ( sp, "start function cannot have a `where` clause" )
273
+ . emit ( ) ;
274
+ error = true ;
262
275
}
263
- if !ps. where_clause . predicates . is_empty ( ) {
264
- struct_span_err ! ( tcx. sess, start_span, E0647 ,
265
- "start function is not allowed to have a where clause" )
266
- . emit ( ) ;
276
+ if error {
267
277
return ;
268
278
}
269
279
}
0 commit comments