@@ -50,7 +50,36 @@ pub struct Feature {
5050
5151pub type Features = HashMap < String , Feature > ;
5252
53- pub fn check ( path : & Path , bad : & mut bool , verbose : bool ) {
53+ pub struct CollectedFeatures {
54+ pub lib : Features ,
55+ pub lang : Features ,
56+ }
57+
58+ // Currently only used for unstable book generation
59+ pub fn collect_lib_features ( base_src_path : & Path ) -> Features {
60+ let mut lib_features = Features :: new ( ) ;
61+
62+ // This library feature is defined in the `compiler_builtins` crate, which
63+ // has been moved out-of-tree. Now it can no longer be auto-discovered by
64+ // `tidy`, because we need to filter out its (submodule) directory. Manually
65+ // add it to the set of known library features so we can still generate docs.
66+ lib_features. insert ( "compiler_builtins_lib" . to_owned ( ) , Feature {
67+ level : Status :: Unstable ,
68+ since : None ,
69+ has_gate_test : false ,
70+ tracking_issue : None ,
71+ } ) ;
72+
73+ map_lib_features ( base_src_path,
74+ & mut |res, _, _| {
75+ if let Ok ( ( name, feature) ) = res {
76+ lib_features. insert ( name. to_owned ( ) , feature) ;
77+ }
78+ } ) ;
79+ lib_features
80+ }
81+
82+ pub fn check ( path : & Path , bad : & mut bool , verbose : bool ) -> CollectedFeatures {
5483 let mut features = collect_lang_features ( path, bad) ;
5584 assert ! ( !features. is_empty( ) ) ;
5685
@@ -125,7 +154,7 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
125154 }
126155
127156 if * bad {
128- return ;
157+ return CollectedFeatures { lib : lib_features , lang : features } ;
129158 }
130159
131160 if verbose {
@@ -140,6 +169,8 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
140169 } else {
141170 println ! ( "* {} features" , features. len( ) ) ;
142171 }
172+
173+ CollectedFeatures { lib : lib_features, lang : features }
143174}
144175
145176fn format_features < ' a > ( features : & ' a Features , family : & ' a str ) -> impl Iterator < Item = String > + ' a {
@@ -303,32 +334,6 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
303334 . collect ( )
304335}
305336
306- pub fn collect_lib_features ( base_src_path : & Path ) -> Features {
307- let mut lib_features = Features :: new ( ) ;
308-
309- // This library feature is defined in the `compiler_builtins` crate, which
310- // has been moved out-of-tree. Now it can no longer be auto-discovered by
311- // `tidy`, because we need to filter out its (submodule) directory. Manually
312- // add it to the set of known library features so we can still generate docs.
313- lib_features. insert ( "compiler_builtins_lib" . to_owned ( ) , Feature {
314- level : Status :: Unstable ,
315- since : None ,
316- has_gate_test : false ,
317- tracking_issue : None ,
318- } ) ;
319-
320- map_lib_features ( base_src_path,
321- & mut |res, _, _| {
322- if let Ok ( ( name, feature) ) = res {
323- if lib_features. contains_key ( name) {
324- return ;
325- }
326- lib_features. insert ( name. to_owned ( ) , feature) ;
327- }
328- } ) ;
329- lib_features
330- }
331-
332337fn get_and_check_lib_features ( base_src_path : & Path ,
333338 bad : & mut bool ,
334339 lang_features : & Features ) -> Features {
0 commit comments