about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-05-26 23:39:31 +0800
committerkennytm <kennytm@gmail.com>2018-05-27 14:22:35 +0800
commit509f414b4fcb4b14b295fd8596f72f677a5064bb (patch)
tree8cd259b139f726e1fc8929c59bb8f2e330181de4 /src/tools
parent1a6bda68cd9d5072f56783f22f7468c19289a020 (diff)
downloadrust-509f414b4fcb4b14b295fd8596f72f677a5064bb.tar.gz
rust-509f414b4fcb4b14b295fd8596f72f677a5064bb.zip
Ensure every unstable feature has a tracking issue.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/tidy/src/features.rs33
-rw-r--r--src/tools/tidy/src/unstable_book.rs2
-rw-r--r--src/tools/unstable-book-gen/src/main.rs2
3 files changed, 30 insertions, 7 deletions
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs
index 3156e93cc72..4c0db993809 100644
--- a/src/tools/tidy/src/features.rs
+++ b/src/tools/tidy/src/features.rs
@@ -81,7 +81,7 @@ impl Feature {
 pub type Features = HashMap<String, Feature>;
 
 pub fn check(path: &Path, bad: &mut bool, quiet: bool) {
-    let mut features = collect_lang_features(path);
+    let mut features = collect_lang_features(path, bad);
     assert!(!features.is_empty());
 
     let lib_features = get_and_check_lib_features(path, bad, &features);
@@ -214,14 +214,27 @@ fn test_filen_gate(filen_underscore: &str, features: &mut Features) -> bool {
     return false;
 }
 
-pub fn collect_lang_features(base_src_path: &Path) -> Features {
+pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
     let mut contents = String::new();
     let path = base_src_path.join("libsyntax/feature_gate.rs");
     t!(t!(File::open(path)).read_to_string(&mut contents));
 
-    contents.lines()
-        .filter_map(|line| {
-            let mut parts = line.trim().split(",");
+    // we allow rustc-internal features to omit a tracking issue.
+    // these features must be marked with `// rustc internal` in its own group.
+    let mut next_feature_is_rustc_internal = false;
+
+    contents.lines().zip(1..)
+        .filter_map(|(line, line_number)| {
+            let line = line.trim();
+            if line.starts_with("// rustc internal") {
+                next_feature_is_rustc_internal = true;
+                return None;
+            } else if line.is_empty() {
+                next_feature_is_rustc_internal = false;
+                return None;
+            }
+
+            let mut parts = line.split(',');
             let level = match parts.next().map(|l| l.trim().trim_left_matches('(')) {
                 Some("active") => Status::Unstable,
                 Some("removed") => Status::Removed,
@@ -232,8 +245,18 @@ pub fn collect_lang_features(base_src_path: &Path) -> Features {
             let since = parts.next().unwrap().trim().trim_matches('"');
             let issue_str = parts.next().unwrap().trim();
             let tracking_issue = if issue_str.starts_with("None") {
+                if level == Status::Unstable && !next_feature_is_rustc_internal {
+                    *bad = true;
+                    tidy_error!(
+                        bad,
+                        "libsyntax/feature_gate.rs:{}: no tracking issue for feature {}",
+                        line_number,
+                        name,
+                    );
+                }
                 None
             } else {
+                next_feature_is_rustc_internal = false;
                 let s = issue_str.split("(").nth(1).unwrap().split(")").nth(0).unwrap();
                 Some(s.parse().unwrap())
             };
diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs
index 6ffe78eab41..6b573908de9 100644
--- a/src/tools/tidy/src/unstable_book.rs
+++ b/src/tools/tidy/src/unstable_book.rs
@@ -86,7 +86,7 @@ pub fn check(path: &path::Path, bad: &mut bool) {
 
     // Library features
 
-    let lang_features = collect_lang_features(path);
+    let lang_features = collect_lang_features(path, bad);
     let lib_features = collect_lib_features(path).into_iter().filter(|&(ref name, _)| {
         !lang_features.contains_key(name)
     }).collect();
diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs
index f66144fde01..b97137d7d64 100644
--- a/src/tools/unstable-book-gen/src/main.rs
+++ b/src/tools/unstable-book-gen/src/main.rs
@@ -131,7 +131,7 @@ fn main() {
     let src_path = Path::new(&src_path_str);
     let dest_path = Path::new(&dest_path_str).join("src");
 
-    let lang_features = collect_lang_features(src_path);
+    let lang_features = collect_lang_features(src_path, &mut false);
     let lib_features = collect_lib_features(src_path).into_iter().filter(|&(ref name, _)| {
         !lang_features.contains_key(name)
     }).collect();