@@ -5,14 +5,16 @@ use syn::Item;
55use crate :: BindgenOptions ;
66
77mod merge_extern_blocks;
8+ mod remove_alias;
89mod sort_semantically;
910
1011use merge_extern_blocks:: merge_extern_blocks;
12+ use remove_alias:: remove_alias;
1113use sort_semantically:: sort_semantically;
1214
1315struct PostProcessingPass {
1416 should_run : fn ( & BindgenOptions ) -> bool ,
15- run : fn ( & mut Vec < Item > ) ,
17+ run : fn ( & mut Vec < Item > , & BindgenOptions ) ,
1618}
1719
1820// TODO: This can be a const fn when mutable references are allowed in const
@@ -21,13 +23,19 @@ macro_rules! pass {
2123 ( $pass: ident) => {
2224 PostProcessingPass {
2325 should_run: |options| options. $pass,
24- run: |items| $pass( items) ,
26+ run: |items, options | $pass( items, options ) ,
2527 }
2628 } ;
2729}
2830
29- const PASSES : & [ PostProcessingPass ] =
30- & [ pass ! ( merge_extern_blocks) , pass ! ( sort_semantically) ] ;
31+ const PASSES : & [ PostProcessingPass ] = & [
32+ pass ! ( merge_extern_blocks) ,
33+ pass ! ( sort_semantically) ,
34+ PostProcessingPass {
35+ should_run : |options| !options. remove_alias . is_empty ( ) ,
36+ run : |items, options| remove_alias ( items, options) ,
37+ } ,
38+ ] ;
3139
3240pub ( crate ) fn postprocessing (
3341 items : Vec < TokenStream > ,
@@ -56,7 +64,7 @@ pub(crate) fn postprocessing(
5664
5765 for pass in PASSES {
5866 if ( pass. should_run ) ( options) {
59- ( pass. run ) ( & mut items) ;
67+ ( pass. run ) ( & mut items, options ) ;
6068 }
6169 }
6270
0 commit comments