@@ -1885,31 +1885,6 @@ impl Context {
1885
1885
"../" . repeat ( self . current . len ( ) )
1886
1886
}
1887
1887
1888
- /// Recurse in the directory structure and change the "root path" to make
1889
- /// sure it always points to the top (relatively).
1890
- fn recurse < T , F > ( & mut self , s : String , f : F ) -> T where
1891
- F : FnOnce ( & mut Context ) -> T ,
1892
- {
1893
- if s. is_empty ( ) {
1894
- panic ! ( "Unexpected empty destination: {:?}" , self . current) ;
1895
- }
1896
- let prev = self . dst . clone ( ) ;
1897
- self . dst . push ( & s) ;
1898
- self . current . push ( s) ;
1899
-
1900
- info ! ( "Recursing into {}" , self . dst. display( ) ) ;
1901
-
1902
- let ret = f ( self ) ;
1903
-
1904
- info ! ( "Recursed; leaving {}" , self . dst. display( ) ) ;
1905
-
1906
- // Go back to where we were at
1907
- self . dst = prev;
1908
- self . current . pop ( ) . unwrap ( ) ;
1909
-
1910
- ret
1911
- }
1912
-
1913
1888
/// Main method for rendering a crate.
1914
1889
///
1915
1890
/// This currently isn't parallelized, but it'd be pretty easy to add
@@ -2090,42 +2065,50 @@ impl Context {
2090
2065
// modules are special because they add a namespace. We also need to
2091
2066
// recurse into the items of the module as well.
2092
2067
let name = item. name . as_ref ( ) . unwrap ( ) . to_string ( ) ;
2093
- let mut item = Some ( item) ;
2094
- let scx = self . shared . clone ( ) ;
2095
- self . recurse ( name, |this| {
2096
- let item = item. take ( ) . unwrap ( ) ;
2097
-
2098
- let mut buf = Vec :: new ( ) ;
2099
- this. render_item ( & mut buf, & item, false ) . unwrap ( ) ;
2100
- // buf will be empty if the module is stripped and there is no redirect for it
2101
- if !buf. is_empty ( ) {
2102
- this. shared . ensure_dir ( & this. dst ) ?;
2103
- let joint_dst = this. dst . join ( "index.html" ) ;
2104
- scx. fs . write ( & joint_dst, buf) ?;
2105
- }
2068
+ let scx = & self . shared ;
2069
+ if name. is_empty ( ) {
2070
+ panic ! ( "Unexpected empty destination: {:?}" , self . current) ;
2071
+ }
2072
+ let prev = self . dst . clone ( ) ;
2073
+ self . dst . push ( & name) ;
2074
+ self . current . push ( name) ;
2106
2075
2107
- let m = match item. inner {
2108
- clean:: StrippedItem ( box clean:: ModuleItem ( m) ) |
2109
- clean:: ModuleItem ( m) => m,
2110
- _ => unreachable ! ( )
2111
- } ;
2076
+ info ! ( "Recursing into {}" , self . dst. display( ) ) ;
2112
2077
2113
- // Render sidebar-items.js used throughout this module.
2114
- if !this. render_redirect_pages {
2115
- let items = this. build_sidebar_items ( & m) ;
2116
- let js_dst = this. dst . join ( "sidebar-items.js" ) ;
2117
- let mut v = Vec :: new ( ) ;
2118
- try_err ! ( write!( & mut v, "initSidebarItems({});" ,
2119
- as_json( & items) ) , & js_dst) ;
2120
- scx. fs . write ( & js_dst, & v) ?;
2121
- }
2078
+ let mut buf = Vec :: new ( ) ;
2079
+ self . render_item ( & mut buf, & item, false ) . unwrap ( ) ;
2080
+ // buf will be empty if the module is stripped and there is no redirect for it
2081
+ if !buf. is_empty ( ) {
2082
+ self . shared . ensure_dir ( & self . dst ) ?;
2083
+ let joint_dst = self . dst . join ( "index.html" ) ;
2084
+ scx. fs . write ( & joint_dst, buf) ?;
2085
+ }
2122
2086
2123
- for item in m. items {
2124
- f ( this, item) ;
2125
- }
2087
+ let m = match item. inner {
2088
+ clean:: StrippedItem ( box clean:: ModuleItem ( m) ) |
2089
+ clean:: ModuleItem ( m) => m,
2090
+ _ => unreachable ! ( )
2091
+ } ;
2092
+
2093
+ // Render sidebar-items.js used throughout this module.
2094
+ if !self . render_redirect_pages {
2095
+ let items = self . build_sidebar_items ( & m) ;
2096
+ let js_dst = self . dst . join ( "sidebar-items.js" ) ;
2097
+ let mut v = Vec :: new ( ) ;
2098
+ try_err ! ( write!( & mut v, "initSidebarItems({});" ,
2099
+ as_json( & items) ) , & js_dst) ;
2100
+ scx. fs . write ( & js_dst, & v) ?;
2101
+ }
2102
+
2103
+ for item in m. items {
2104
+ f ( self , item) ;
2105
+ }
2106
+
2107
+ info ! ( "Recursed; leaving {}" , self . dst. display( ) ) ;
2126
2108
2127
- Ok ( ( ) )
2128
- } ) ?;
2109
+ // Go back to where we were at
2110
+ self . dst = prev;
2111
+ self . current . pop ( ) . unwrap ( ) ;
2129
2112
} else if item. name . is_some ( ) {
2130
2113
let mut buf = Vec :: new ( ) ;
2131
2114
self . render_item ( & mut buf, & item, true ) . unwrap ( ) ;
0 commit comments