@@ -50,7 +50,36 @@ pub struct Feature {
50
50
51
51
pub type Features = HashMap < String , Feature > ;
52
52
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 {
54
83
let mut features = collect_lang_features ( path, bad) ;
55
84
assert ! ( !features. is_empty( ) ) ;
56
85
@@ -125,7 +154,7 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
125
154
}
126
155
127
156
if * bad {
128
- return ;
157
+ return CollectedFeatures { lib : lib_features , lang : features } ;
129
158
}
130
159
131
160
if verbose {
@@ -140,6 +169,8 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
140
169
} else {
141
170
println ! ( "* {} features" , features. len( ) ) ;
142
171
}
172
+
173
+ CollectedFeatures { lib : lib_features, lang : features }
143
174
}
144
175
145
176
fn 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 {
303
334
. collect ( )
304
335
}
305
336
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
-
332
337
fn get_and_check_lib_features ( base_src_path : & Path ,
333
338
bad : & mut bool ,
334
339
lang_features : & Features ) -> Features {
0 commit comments