Collect features only once
This commit is contained in:
parent
ebbc662f07
commit
6c5c78d00c
3 changed files with 51 additions and 37 deletions
|
@ -50,7 +50,36 @@ pub struct Feature {
|
|||
|
||||
pub type Features = HashMap<String, Feature>;
|
||||
|
||||
pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
|
||||
pub struct CollectedFeatures {
|
||||
pub lib: Features,
|
||||
pub lang: Features,
|
||||
}
|
||||
|
||||
// Currently only used for unstable book generation
|
||||
pub fn collect_lib_features(base_src_path: &Path) -> Features {
|
||||
let mut lib_features = Features::new();
|
||||
|
||||
// This library feature is defined in the `compiler_builtins` crate, which
|
||||
// has been moved out-of-tree. Now it can no longer be auto-discovered by
|
||||
// `tidy`, because we need to filter out its (submodule) directory. Manually
|
||||
// add it to the set of known library features so we can still generate docs.
|
||||
lib_features.insert("compiler_builtins_lib".to_owned(), Feature {
|
||||
level: Status::Unstable,
|
||||
since: None,
|
||||
has_gate_test: false,
|
||||
tracking_issue: None,
|
||||
});
|
||||
|
||||
map_lib_features(base_src_path,
|
||||
&mut |res, _, _| {
|
||||
if let Ok((name, feature)) = res {
|
||||
lib_features.insert(name.to_owned(), feature);
|
||||
}
|
||||
});
|
||||
lib_features
|
||||
}
|
||||
|
||||
pub fn check(path: &Path, bad: &mut bool, verbose: bool) -> CollectedFeatures {
|
||||
let mut features = collect_lang_features(path, bad);
|
||||
assert!(!features.is_empty());
|
||||
|
||||
|
@ -125,7 +154,7 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
|
|||
}
|
||||
|
||||
if *bad {
|
||||
return;
|
||||
return CollectedFeatures { lib: lib_features, lang: features };
|
||||
}
|
||||
|
||||
if verbose {
|
||||
|
@ -140,6 +169,8 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
|
|||
} else {
|
||||
println!("* {} features", features.len());
|
||||
}
|
||||
|
||||
CollectedFeatures { lib: lib_features, lang: features }
|
||||
}
|
||||
|
||||
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 {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn collect_lib_features(base_src_path: &Path) -> Features {
|
||||
let mut lib_features = Features::new();
|
||||
|
||||
// This library feature is defined in the `compiler_builtins` crate, which
|
||||
// has been moved out-of-tree. Now it can no longer be auto-discovered by
|
||||
// `tidy`, because we need to filter out its (submodule) directory. Manually
|
||||
// add it to the set of known library features so we can still generate docs.
|
||||
lib_features.insert("compiler_builtins_lib".to_owned(), Feature {
|
||||
level: Status::Unstable,
|
||||
since: None,
|
||||
has_gate_test: false,
|
||||
tracking_issue: None,
|
||||
});
|
||||
|
||||
map_lib_features(base_src_path,
|
||||
&mut |res, _, _| {
|
||||
if let Ok((name, feature)) = res {
|
||||
if lib_features.contains_key(name) {
|
||||
return;
|
||||
}
|
||||
lib_features.insert(name.to_owned(), feature);
|
||||
}
|
||||
});
|
||||
lib_features
|
||||
}
|
||||
|
||||
fn get_and_check_lib_features(base_src_path: &Path,
|
||||
bad: &mut bool,
|
||||
lang_features: &Features) -> Features {
|
||||
|
|
|
@ -24,9 +24,9 @@ fn main() {
|
|||
style::check(&path, &mut bad);
|
||||
errors::check(&path, &mut bad);
|
||||
cargo::check(&path, &mut bad);
|
||||
features::check(&path, &mut bad, verbose);
|
||||
let collected = features::check(&path, &mut bad, verbose);
|
||||
pal::check(&path, &mut bad);
|
||||
unstable_book::check(&path, &mut bad);
|
||||
unstable_book::check(&path, collected, &mut bad);
|
||||
libcoretest::check(&path, &mut bad);
|
||||
if !args.iter().any(|s| *s == "--no-vendor") {
|
||||
deps::check(&path, &mut bad);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::BTreeSet;
|
||||
use std::fs;
|
||||
use std::path::{PathBuf, Path};
|
||||
use crate::features::{collect_lang_features, collect_lib_features, Features, Status};
|
||||
use crate::features::{CollectedFeatures, Features, Feature, Status};
|
||||
|
||||
pub const PATH_STR: &str = "doc/unstable-book";
|
||||
|
||||
|
@ -73,13 +73,22 @@ fn collect_unstable_book_lib_features_section_file_names(base_src_path: &Path) -
|
|||
collect_unstable_book_section_file_names(&unstable_book_lib_features_path(base_src_path))
|
||||
}
|
||||
|
||||
pub fn check(path: &Path, bad: &mut bool) {
|
||||
// Library features
|
||||
|
||||
let lang_features = collect_lang_features(path, bad);
|
||||
let lib_features = collect_lib_features(path).into_iter().filter(|&(ref name, _)| {
|
||||
pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
|
||||
let lang_features = features.lang;
|
||||
let mut lib_features = features.lib.into_iter().filter(|&(ref name, _)| {
|
||||
!lang_features.contains_key(name)
|
||||
}).collect();
|
||||
}).collect::<Features>();
|
||||
|
||||
// This library feature is defined in the `compiler_builtins` crate, which
|
||||
// has been moved out-of-tree. Now it can no longer be auto-discovered by
|
||||
// `tidy`, because we need to filter out its (submodule) directory. Manually
|
||||
// add it to the set of known library features so we can still generate docs.
|
||||
lib_features.insert("compiler_builtins_lib".to_owned(), Feature {
|
||||
level: Status::Unstable,
|
||||
since: None,
|
||||
has_gate_test: false,
|
||||
tracking_issue: None,
|
||||
});
|
||||
|
||||
// Library features
|
||||
let unstable_lib_feature_names = collect_unstable_feature_names(&lib_features);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue