1- use crate :: utils:: { match_def_path, paths, qpath_res, span_lint} ;
1+ use crate :: utils:: { is_entrypoint_fn , match_def_path, paths, qpath_res, span_lint} ;
22use if_chain:: if_chain;
33use rustc:: hir:: { Expr , ExprKind , Item , ItemKind , Node } ;
44use rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
@@ -40,7 +40,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Exit {
4040 Some ( Node :: Item ( Item { ident, kind: ItemKind :: Fn ( ..) , ..} ) ) => {
4141 // If we found a function we check it's name if it is
4242 // `main` we emit a lint.
43- if ident. name. as_str( ) != "main" {
43+ let def_id = cx. tcx. hir( ) . local_def_id( parent) ;
44+ if !is_entrypoint_fn( cx, def_id) {
4445 span_lint( cx, EXIT , e. span, "usage of `process::exit`" ) ;
4546 }
4647 // We found any kind of function and can end our loop
@@ -49,7 +50,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Exit {
4950 // If we found anything but a funciton we continue with the
5051 // loop and go one parent up
5152 Some ( _) => {
52- cx. tcx. hir( ) . get_parent_item( parent) ;
53+ parent = cx. tcx. hir( ) . get_parent_item( parent) ;
5354 } ,
5455 // If we found nothing we break.
5556 None => break ,
0 commit comments