diff options
| author | bors <bors@rust-lang.org> | 2019-12-22 07:01:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-22 07:01:50 +0000 |
| commit | 3982d3514efbb65b3efac6bb006b3fa496d16663 (patch) | |
| tree | 5fcfb7b8bd5ee606865be1abb448a4858f8c6770 /src/tools | |
| parent | 005cf38f7e66757b32b03ea35fedca372eb063e3 (diff) | |
| parent | ca528fcc046aca3e1cccb74a4bbebe855df3e3b6 (diff) | |
| download | rust-3982d3514efbb65b3efac6bb006b3fa496d16663.tar.gz rust-3982d3514efbb65b3efac6bb006b3fa496d16663.zip | |
Auto merge of #67505 - Centril:rollup-7win7ty, r=Centril
Rollup of 6 pull requests Successful merges: - #67148 ( Refactor type & bounds parsing thoroughly) - #67410 (Reenable static linking of libstdc++ on windows-gnu) - #67439 (Cleanup `lower_pattern_unadjusted` & Improve slice pat typeck) - #67480 (Require issue = "none" over issue = "0" in unstable attributes) - #67500 (Tweak non_shorthand_field_patterns' suggestion) - #67504 (Warn against relying on ?Sized being last) Failed merges: r? @ghost
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/tidy/src/features.rs | 18 | ||||
| -rw-r--r-- | src/tools/unstable-book-gen/src/main.rs | 15 |
2 files changed, 16 insertions, 17 deletions
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 4ea101296b7..82292a6912c 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -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, diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index fdb0b6d3e56..39e8d61edeb 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -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); } |
