@@ -186,18 +186,23 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
186186 Some ( hir_map:: NodeItem ( it) ) => {
187187 match it. node {
188188 hir:: ItemFn ( .., ref generics, _) => {
189+ let mut error = false ;
189190 if !generics. params . is_empty ( ) {
190191 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")
192193 . span_label ( generics. span ,
193- "main cannot have type parameters" )
194+ "` main` cannot have type parameters" )
194195 . 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 ;
196204 }
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 {
201206 return ;
202207 }
203208 }
@@ -251,19 +256,24 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
251256 match tcx. hir . find ( start_id) {
252257 Some ( hir_map:: NodeItem ( it) ) => {
253258 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 ,
257263 "start function is not allowed to have type parameters" )
258- . span_label ( ps . span ,
264+ . span_label ( generics . span ,
259265 "start function cannot have type parameters" )
260266 . 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 ;
262275 }
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 {
267277 return ;
268278 }
269279 }
0 commit comments