@@ -50,7 +50,6 @@ use std::io::{self, Write};
5050use std:: path:: { Path , PathBuf } ;
5151use syntax:: { ast, diagnostics, visit} ;
5252use syntax:: attr:: { self , AttrMetaMethods } ;
53- use syntax:: fold:: Folder ;
5453use syntax:: parse:: { self , PResult , token} ;
5554use syntax:: util:: node_count:: NodeCounter ;
5655use syntax;
@@ -695,6 +694,19 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
695694 sess. diagnostic ( ) )
696695 } ) ;
697696
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+
698710 time ( time_passes,
699711 "checking for inline asm in case the target doesn't support it" ,
700712 || no_asm:: check_crate ( sess, & krate) ) ;
@@ -710,15 +722,6 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
710722 } )
711723 } ) ?;
712724
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-
722725 // Collect defintions for def ids.
723726 time ( sess. time_passes ( ) , "collecting defs" , || resolver. definitions . collect ( & krate) ) ;
724727
@@ -783,53 +786,6 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
783786 } )
784787}
785788
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-
833789/// Run the resolution, typechecking, region checking and other
834790/// miscellaneous analysis passes on the crate. Return various
835791/// structures carrying the results of the analysis.
0 commit comments