@@ -156,25 +156,30 @@ impl BuildStep {
156156 child. find_by_type ( r#type, result) ;
157157 }
158158 }
159- }
160-
161- /// Writes build steps into a nice indented table.
162- pub fn format_build_steps ( root : & BuildStep ) -> String {
163- use std:: fmt:: Write ;
164159
165- let mut substeps: Vec < ( u32 , & BuildStep ) > = Vec :: new ( ) ;
160+ /// Returns a Vec with all substeps, ordered by their hierarchical order.
161+ /// The first element of the tuple is the depth of a given step.
162+ fn linearize_steps ( & self ) -> Vec < ( u32 , & BuildStep ) > {
163+ let mut substeps: Vec < ( u32 , & BuildStep ) > = Vec :: new ( ) ;
166164
167- fn visit < ' a > ( step : & ' a BuildStep , level : u32 , substeps : & mut Vec < ( u32 , & ' a BuildStep ) > ) {
168- substeps. push ( ( level, step) ) ;
169- for child in & step. children {
170- visit ( child, level + 1 , substeps) ;
165+ fn visit < ' a > ( step : & ' a BuildStep , level : u32 , substeps : & mut Vec < ( u32 , & ' a BuildStep ) > ) {
166+ substeps. push ( ( level, step) ) ;
167+ for child in & step. children {
168+ visit ( child, level + 1 , substeps) ;
169+ }
171170 }
171+
172+ visit ( self , 0 , & mut substeps) ;
173+ substeps
172174 }
175+ }
173176
174- visit ( root, 0 , & mut substeps) ;
177+ /// Writes build steps into a nice indented table.
178+ pub fn format_build_steps ( root : & BuildStep ) -> String {
179+ use std:: fmt:: Write ;
175180
176181 let mut output = String :: new ( ) ;
177- for ( level, step) in substeps {
182+ for ( level, step) in root . linearize_steps ( ) {
178183 let label = format ! (
179184 "{}{}" ,
180185 "." . repeat( level as usize ) ,
0 commit comments