@@ -39,34 +39,37 @@ impl Transform for ConvertExits {
3939
4040 let mut exit_defs = HashMap :: new ( ) ;
4141 visit_nodes ( krate, |fi : & ForeignItem | {
42- if crate :: util:: contains_name ( & fi. attrs , sym:: no_mangle) {
43- if let ForeignItemKind :: Fn ( _) = fi. kind {
44- let def_id = cx. node_def_id ( fi. id ) ;
42+ if !crate :: util:: contains_name ( & fi. attrs , sym:: no_mangle) {
43+ return ;
44+ }
45+ let ForeignItemKind :: Fn ( _) = fi. kind else {
46+ return ;
47+ } ;
4548
46- // Ignore functions that are defined locally, either directly or as
47- // indirect `extern "C"` imports, since those have to be custom
48- // functions. We only want to translate calls to the foreign libc
49- // functions.
50- if local_no_mangle_names. contains ( & fi. ident . name ) {
51- return ;
52- }
53- if def_id. is_local ( ) {
54- match cx. hir_map ( ) . get_if_local ( def_id) {
55- Some ( Node :: ForeignItem ( _) ) => { }
56- _ => return ,
57- }
58- }
49+ let def_id = cx. node_def_id ( fi. id ) ;
5950
60- match & * fi. ident . as_str ( ) {
61- "abort" => {
62- exit_defs. insert ( def_id, "abort" ) ;
63- }
64- "exit" => {
65- exit_defs. insert ( def_id, "exit" ) ;
66- }
67- _ => { }
68- }
51+ // Ignore functions that are defined locally, either directly or as
52+ // indirect `extern "C"` imports, since those have to be custom
53+ // functions. We only want to translate calls to the foreign libc
54+ // functions.
55+ if local_no_mangle_names. contains ( & fi. ident . name ) {
56+ return ;
57+ }
58+ if def_id. is_local ( ) {
59+ match cx. hir_map ( ) . get_if_local ( def_id) {
60+ Some ( Node :: ForeignItem ( _) ) => { }
61+ _ => return ,
62+ }
63+ }
64+
65+ match & * fi. ident . as_str ( ) {
66+ "abort" => {
67+ exit_defs. insert ( def_id, "abort" ) ;
68+ }
69+ "exit" => {
70+ exit_defs. insert ( def_id, "exit" ) ;
6971 }
72+ _ => { }
7073 }
7174 } ) ;
7275
0 commit comments