Rollup merge of #67480 - rossmacarthur:fix-41260-avoid-issue-0-part-2, r=Centril
Require issue = "none" over issue = "0" in unstable attributes These changes make the use of `issue = "none"` required in unstable attributes throughout the compiler. Notes: - #66299 is now in beta so `issue = "none"` is accepted. - The `tidy` tool now fails on `issue = "0"`. - Tests that used `issue = "0"` were changed to use `issue = "none"`, except for _one_ that asserts `issue = "0"` can still be used. - The compiler still allows `issue = "0"` because some submodules require it, this could be disallowed once these are updated. Resolves #41260 r? @varkor
This commit is contained in:
commit
eaeb1138c6
112 changed files with 384 additions and 385 deletions
|
|
@ -12,6 +12,7 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::fs;
|
||||
use std::num::NonZeroU32;
|
||||
use std::path::Path;
|
||||
|
||||
use regex::Regex;
|
||||
|
|
@ -48,7 +49,7 @@ pub struct Feature {
|
|||
pub level: Status,
|
||||
pub since: Option<Version>,
|
||||
pub has_gate_test: bool,
|
||||
pub tracking_issue: Option<u32>,
|
||||
pub tracking_issue: Option<NonZeroU32>,
|
||||
}
|
||||
|
||||
pub type Features = HashMap<String, Feature>;
|
||||
|
|
@ -396,6 +397,14 @@ fn map_lib_features(base_src_path: &Path,
|
|||
return;
|
||||
}
|
||||
|
||||
let handle_issue_none = |s| match s {
|
||||
"none" => None,
|
||||
issue => {
|
||||
let n = issue.parse().expect("issue number is not a valid integer");
|
||||
assert_ne!(n, 0, "\"none\" should be used when there is no issue, not \"0\"");
|
||||
NonZeroU32::new(n)
|
||||
}
|
||||
};
|
||||
let mut becoming_feature: Option<(&str, Feature)> = None;
|
||||
let mut iter_lines = contents.lines().enumerate().peekable();
|
||||
while let Some((i, line)) = iter_lines.next() {
|
||||
|
|
@ -407,8 +416,7 @@ fn map_lib_features(base_src_path: &Path,
|
|||
};
|
||||
if let Some((ref name, ref mut f)) = becoming_feature {
|
||||
if f.tracking_issue.is_none() {
|
||||
f.tracking_issue = find_attr_val(line, "issue")
|
||||
.map(|s| s.parse().unwrap());
|
||||
f.tracking_issue = find_attr_val(line, "issue").and_then(handle_issue_none);
|
||||
}
|
||||
if line.ends_with(']') {
|
||||
mf(Ok((name, f.clone())), file, i + 1);
|
||||
|
|
@ -439,7 +447,7 @@ fn map_lib_features(base_src_path: &Path,
|
|||
// FIXME(#57563): #57563 is now used as a common tracking issue,
|
||||
// although we would like to have specific tracking issues for each
|
||||
// `rustc_const_unstable` in the future.
|
||||
tracking_issue: Some(57563),
|
||||
tracking_issue: NonZeroU32::new(57563),
|
||||
};
|
||||
mf(Ok((feature_name, feature)), file, i + 1);
|
||||
continue;
|
||||
|
|
@ -467,7 +475,7 @@ fn map_lib_features(base_src_path: &Path,
|
|||
}
|
||||
None => None,
|
||||
};
|
||||
let tracking_issue = find_attr_val(line, "issue").map(|s| s.parse().unwrap());
|
||||
let tracking_issue = find_attr_val(line, "issue").and_then(handle_issue_none);
|
||||
|
||||
let feature = Feature {
|
||||
level,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#![deny(warnings)]
|
||||
|
||||
use tidy::features::{Feature, Features, collect_lib_features, collect_lang_features};
|
||||
use tidy::features::{Features, collect_lib_features, collect_lang_features};
|
||||
use tidy::unstable_book::{collect_unstable_feature_names, collect_unstable_book_section_file_names,
|
||||
PATH_STR, LANG_FEATURES_DIR, LIB_FEATURES_DIR};
|
||||
use std::collections::BTreeSet;
|
||||
|
|
@ -70,15 +70,6 @@ fn generate_summary(path: &Path, lang_features: &Features, lib_features: &Featur
|
|||
|
||||
}
|
||||
|
||||
fn has_valid_tracking_issue(f: &Feature) -> bool {
|
||||
if let Some(n) = f.tracking_issue {
|
||||
if n > 0 {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn generate_unstable_book_files(src :&Path, out: &Path, features :&Features) {
|
||||
let unstable_features = collect_unstable_feature_names(features);
|
||||
let unstable_section_file_names = collect_unstable_book_section_file_names(src);
|
||||
|
|
@ -89,10 +80,10 @@ fn generate_unstable_book_files(src :&Path, out: &Path, features :&Features) {
|
|||
let out_file_path = out.join(&file_name);
|
||||
let feature = &features[&feature_name_underscore];
|
||||
|
||||
if has_valid_tracking_issue(&feature) {
|
||||
if let Some(issue) = feature.tracking_issue {
|
||||
generate_stub_issue(&out_file_path,
|
||||
&feature_name_underscore,
|
||||
feature.tracking_issue.unwrap());
|
||||
issue.get());
|
||||
} else {
|
||||
generate_stub_no_issue(&out_file_path, &feature_name_underscore);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue