@@ -50,7 +50,6 @@ use std::io::{self, Write};
50
50
use std:: path:: { Path , PathBuf } ;
51
51
use syntax:: { ast, diagnostics, visit} ;
52
52
use syntax:: attr:: { self , AttrMetaMethods } ;
53
- use syntax:: fold:: Folder ;
54
53
use syntax:: parse:: { self , PResult , token} ;
55
54
use syntax:: util:: node_count:: NodeCounter ;
56
55
use syntax;
@@ -695,6 +694,19 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
695
694
sess. diagnostic ( ) )
696
695
} ) ;
697
696
697
+ let resolver_arenas = Resolver :: arenas ( ) ;
698
+ let mut resolver = Resolver :: new ( sess, make_glob_map, & resolver_arenas) ;
699
+
700
+ let krate = time ( sess. time_passes ( ) , "assigning node ids" , || resolver. assign_node_ids ( krate) ) ;
701
+
702
+ if sess. opts . debugging_opts . input_stats {
703
+ println ! ( "Post-expansion node count: {}" , count_nodes( & krate) ) ;
704
+ }
705
+
706
+ if sess. opts . debugging_opts . ast_json {
707
+ println ! ( "{}" , json:: as_json( & krate) ) ;
708
+ }
709
+
698
710
time ( time_passes,
699
711
"checking for inline asm in case the target doesn't support it" ,
700
712
|| no_asm:: check_crate ( sess, & krate) ) ;
@@ -710,15 +722,6 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
710
722
} )
711
723
} ) ?;
712
724
713
- if sess. opts . debugging_opts . input_stats {
714
- println ! ( "Post-expansion node count: {}" , count_nodes( & krate) ) ;
715
- }
716
-
717
- krate = assign_node_ids ( sess, krate) ;
718
-
719
- let resolver_arenas = Resolver :: arenas ( ) ;
720
- let mut resolver = Resolver :: new ( sess, make_glob_map, & resolver_arenas) ;
721
-
722
725
// Collect defintions for def ids.
723
726
time ( sess. time_passes ( ) , "collecting defs" , || resolver. definitions . collect ( & krate) ) ;
724
727
@@ -783,53 +786,6 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
783
786
} )
784
787
}
785
788
786
- pub fn assign_node_ids ( sess : & Session , krate : ast:: Crate ) -> ast:: Crate {
787
- use syntax:: ptr:: P ;
788
- use syntax:: util:: move_map:: MoveMap ;
789
-
790
- struct NodeIdAssigner < ' a > {
791
- sess : & ' a Session ,
792
- }
793
-
794
- impl < ' a > Folder for NodeIdAssigner < ' a > {
795
- fn new_id ( & mut self , old_id : ast:: NodeId ) -> ast:: NodeId {
796
- assert_eq ! ( old_id, ast:: DUMMY_NODE_ID ) ;
797
- self . sess . next_node_id ( )
798
- }
799
-
800
- fn fold_block ( & mut self , block : P < ast:: Block > ) -> P < ast:: Block > {
801
- block. map ( |mut block| {
802
- block. id = self . new_id ( block. id ) ;
803
-
804
- let stmt = block. stmts . pop ( ) ;
805
- block. stmts = block. stmts . move_flat_map ( |s| self . fold_stmt ( s) . into_iter ( ) ) ;
806
- if let Some ( ast:: Stmt { node : ast:: StmtKind :: Expr ( expr) , span, .. } ) = stmt {
807
- let expr = self . fold_expr ( expr) ;
808
- block. stmts . push ( ast:: Stmt {
809
- id : expr. id ,
810
- node : ast:: StmtKind :: Expr ( expr) ,
811
- span : span,
812
- } ) ;
813
- } else if let Some ( stmt) = stmt {
814
- block. stmts . extend ( self . fold_stmt ( stmt) ) ;
815
- }
816
-
817
- block
818
- } )
819
- }
820
- }
821
-
822
- let krate = time ( sess. time_passes ( ) ,
823
- "assigning node ids" ,
824
- || NodeIdAssigner { sess : sess } . fold_crate ( krate) ) ;
825
-
826
- if sess. opts . debugging_opts . ast_json {
827
- println ! ( "{}" , json:: as_json( & krate) ) ;
828
- }
829
-
830
- krate
831
- }
832
-
833
789
/// Run the resolution, typechecking, region checking and other
834
790
/// miscellaneous analysis passes on the crate. Return various
835
791
/// structures carrying the results of the analysis.
0 commit comments