about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-06-16 23:10:50 -0700
committerGitHub <noreply@github.com>2017-06-16 23:10:50 -0700
commit6062bf7aca1927bc0e64854c54b466fffa73f07a (patch)
tree28977e6f54b5ad5108879014133241135ebbe416
parent881ea1ef0435c8c042ebf893346ade4534568738 (diff)
parentc6afde6c46d167c9c75389b887f1d2498aeef3e4 (diff)
downloadrust-6062bf7aca1927bc0e64854c54b466fffa73f07a.tar.gz
rust-6062bf7aca1927bc0e64854c54b466fffa73f07a.zip
Rollup merge of #42705 - est31:master, r=alexcrichton
Introduce tidy lint to check for inconsistent tracking issues

This PR
* Refactors the collect_lib_features function to work in a
      non-checking mode (no bad pointer needed, and list of
      lang features).
* Introduces checking whether unstable/stable tags for a
      given feature have inconsistent tracking issues, as in,
      multiple tracking issues per feature.
* Fixes such inconsistencies throughout the codebase.
-rw-r--r--src/liballoc/rc.rs4
-rw-r--r--src/libcore/hash/mod.rs2
-rw-r--r--src/libcore/str/mod.rs2
-rw-r--r--src/libfmt_macros/lib.rs2
-rw-r--r--src/librustc_trans/lib.rs1
-rw-r--r--src/libstd/lib.rs2
-rw-r--r--src/libstd/rand/mod.rs2
-rw-r--r--src/libstd_unicode/char.rs8
-rw-r--r--src/tools/tidy/src/features.rs93
-rw-r--r--src/tools/tidy/src/unstable_book.rs2
-rw-r--r--src/tools/unstable-book-gen/src/main.rs3
11 files changed, 78 insertions, 43 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 1f3388ad2c2..21a56ff9899 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -428,7 +428,7 @@ impl Rc<str> {
     #[doc(hidden)]
     #[unstable(feature = "rustc_private",
                reason = "for internal use in rustc",
-               issue = "0")]
+               issue = "27812")]
     pub fn __from_str(value: &str) -> Rc<str> {
         unsafe {
             // Allocate enough space for `RcBox<str>`.
@@ -453,7 +453,7 @@ impl<T> Rc<[T]> {
     #[doc(hidden)]
     #[unstable(feature = "rustc_private",
                reason = "for internal use in rustc",
-               issue = "0")]
+               issue = "27812")]
     pub fn __from_array(value: Box<[T]>) -> Rc<[T]> {
         unsafe {
             let ptr: *mut RcBox<[T]> =
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs
index f68361e8522..3b304f4c479 100644
--- a/src/libcore/hash/mod.rs
+++ b/src/libcore/hash/mod.rs
@@ -99,7 +99,7 @@ use mem;
 #[allow(deprecated)]
 pub use self::sip::SipHasher;
 
-#[unstable(feature = "sip_hash_13", issue = "29754")]
+#[unstable(feature = "sip_hash_13", issue = "34767")]
 #[allow(deprecated)]
 pub use self::sip::{SipHasher13, SipHasher24};
 
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index c374f400974..624c3638df5 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -2085,7 +2085,7 @@ pub trait StrExt {
     fn is_char_boundary(&self, index: usize) -> bool;
     #[stable(feature = "core", since = "1.6.0")]
     fn as_bytes(&self) -> &[u8];
-    #[unstable(feature = "str_mut_extras", issue = "0")]
+    #[unstable(feature = "str_mut_extras", issue = "41119")]
     unsafe fn as_bytes_mut(&mut self) -> &mut [u8];
     #[stable(feature = "core", since = "1.6.0")]
     fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs
index 641a42b0818..967bfb6c990 100644
--- a/src/libfmt_macros/lib.rs
+++ b/src/libfmt_macros/lib.rs
@@ -26,7 +26,7 @@
 #![deny(warnings)]
 
 #![cfg_attr(stage0, feature(staged_api))]
-#![feature(unicode)]
+#![feature(rustc_private)]
 
 pub use self::Piece::*;
 pub use self::Position::*;
diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs
index 71fb2e5fb20..4c7037c9ef2 100644
--- a/src/librustc_trans/lib.rs
+++ b/src/librustc_trans/lib.rs
@@ -33,7 +33,6 @@
 #![feature(quote)]
 #![feature(rustc_diagnostic_macros)]
 #![feature(slice_patterns)]
-#![feature(unicode)]
 #![feature(conservative_impl_trait)]
 #![feature(command_envs)]
 
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index f307fbb7c00..105f4026ec8 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -484,7 +484,7 @@ pub mod rt;
 // but it may be stabilized long-term. As a result we're exposing a hidden,
 // unstable module so we can get our build working.
 #[doc(hidden)]
-#[unstable(feature = "rand", issue = "0")]
+#[unstable(feature = "rand", issue = "27703")]
 pub mod __rand {
     pub use rand::{thread_rng, ThreadRng, Rng};
 }
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs
index 4f33d726398..8da070e7a49 100644
--- a/src/libstd/rand/mod.rs
+++ b/src/libstd/rand/mod.rs
@@ -56,7 +56,7 @@
 //!     between the two sources. (Also note that, on some systems e.g. FreeBSD, both `/dev/random`
 //!     and `/dev/urandom` may block once if the CSPRNG has not seeded yet.)
 
-#![unstable(feature = "rand", issue = "0")]
+#![unstable(feature = "rand", issue = "27703")]
 
 use cell::RefCell;
 use fmt;
diff --git a/src/libstd_unicode/char.rs b/src/libstd_unicode/char.rs
index 92e5369758b..eb36cbe3b1f 100644
--- a/src/libstd_unicode/char.rs
+++ b/src/libstd_unicode/char.rs
@@ -599,9 +599,9 @@ impl char {
     /// 'XID_Start' is a Unicode Derived Property specified in
     /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
     /// mostly similar to `ID_Start` but modified for closure under `NFKx`.
-    #[unstable(feature = "unicode",
+    #[unstable(feature = "rustc_private",
                reason = "mainly needed for compiler internals",
-               issue = "0")]
+               issue = "27812")]
     #[inline]
     pub fn is_xid_start(self) -> bool {
         derived_property::XID_Start(self)
@@ -613,9 +613,9 @@ impl char {
     /// 'XID_Continue' is a Unicode Derived Property specified in
     /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
     /// mostly similar to 'ID_Continue' but modified for closure under NFKx.
-    #[unstable(feature = "unicode",
+    #[unstable(feature = "rustc_private",
                reason = "mainly needed for compiler internals",
-               issue = "0")]
+               issue = "27812")]
     #[inline]
     pub fn is_xid_continue(self) -> bool {
         derived_property::XID_Continue(self)
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs
index 81db23ccceb..722fc2b317e 100644
--- a/src/tools/tidy/src/features.rs
+++ b/src/tools/tidy/src/features.rs
@@ -56,7 +56,7 @@ pub fn check(path: &Path, bad: &mut bool, quiet: bool) {
     let mut features = collect_lang_features(path);
     assert!(!features.is_empty());
 
-    let lib_features = collect_lib_features(path, bad, &features);
+    let lib_features = get_and_check_lib_features(path, bad, &features);
     assert!(!lib_features.is_empty());
 
     let mut contents = String::new();
@@ -217,10 +217,61 @@ pub fn collect_lang_features(base_src_path: &Path) -> Features {
         .collect()
 }
 
-pub fn collect_lib_features(base_src_path: &Path,
-                            bad: &mut bool,
-                            features: &Features) -> Features {
+pub fn collect_lib_features(base_src_path: &Path) -> Features {
     let mut lib_features = Features::new();
+    map_lib_features(base_src_path,
+                     &mut |res, _, _| {
+        match res {
+            Ok((name, feature)) => {
+                if lib_features.get(name).is_some() {
+                    return;
+                }
+                lib_features.insert(name.to_owned(), feature);
+            },
+            Err(_) => (),
+        }
+    });
+   lib_features
+}
+
+fn get_and_check_lib_features(base_src_path: &Path,
+                              bad: &mut bool,
+                              lang_features: &Features) -> Features {
+    let mut lib_features = Features::new();
+    map_lib_features(base_src_path,
+                     &mut |res, file, line| {
+            match res {
+                Ok((name, f)) => {
+                    let mut err = |msg: &str| {
+                        tidy_error!(bad, "{}:{}: {}", file.display(), line, msg);
+                    };
+                    if lang_features.contains_key(name) {
+                        err("duplicating a lang feature");
+                    }
+                    if let Some(ref s) = lib_features.get(name) {
+                        if s.level != f.level {
+                            err("different stability level than before");
+                        }
+                        if s.since != f.since {
+                            err("different `since` than before");
+                        }
+                        if s.tracking_issue != f.tracking_issue {
+                            err("different `tracking_issue` than before");
+                        }
+                    }
+                    lib_features.insert(name.to_owned(), f);
+                },
+                Err(msg) => {
+                    tidy_error!(bad, "{}:{}: {}", file.display(), line, msg);
+                },
+            }
+
+    });
+    lib_features
+}
+
+fn map_lib_features(base_src_path: &Path,
+                    mf: &mut FnMut(Result<(&str, Feature), &str>, &Path, usize)) {
     let mut contents = String::new();
     super::walk(base_src_path,
                 &mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
@@ -236,8 +287,11 @@ pub fn collect_lib_features(base_src_path: &Path,
 
         let mut becoming_feature: Option<(String, Feature)> = None;
         for (i, line) in contents.lines().enumerate() {
-            let mut err = |msg: &str| {
-                tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg);
+            macro_rules! err {
+                ($msg:expr) => {{
+                    mf(Err($msg), file, i + 1);
+                    continue;
+                }};
             };
             if let Some((ref name, ref mut f)) = becoming_feature {
                 if f.tracking_issue.is_none() {
@@ -245,7 +299,7 @@ pub fn collect_lib_features(base_src_path: &Path,
                     .map(|s| s.parse().unwrap());
                 }
                 if line.ends_with("]") {
-                    lib_features.insert(name.to_owned(), f.clone());
+                    mf(Ok((name, f.clone())), file, i + 1);
                 } else if !line.ends_with(",") && !line.ends_with("\\") {
                     // We need to bail here because we might have missed the
                     // end of a stability attribute above because the "]"
@@ -254,7 +308,7 @@ pub fn collect_lib_features(base_src_path: &Path,
                     // we continue parsing the file assuming the current stability
                     // attribute has not ended, and ignoring possible feature
                     // attributes in the process.
-                    err("malformed stability attribute");
+                    err!("malformed stability attribute");
                 } else {
                     continue;
                 }
@@ -269,33 +323,17 @@ pub fn collect_lib_features(base_src_path: &Path,
             };
             let feature_name = match find_attr_val(line, "feature") {
                 Some(name) => name,
-                None => {
-                    err("malformed stability attribute");
-                    continue;
-                }
+                None => err!("malformed stability attribute"),
             };
             let since = match find_attr_val(line, "since") {
                 Some(name) => name,
                 None if level == Status::Stable => {
-                    err("malformed stability attribute");
-                    continue;
+                    err!("malformed stability attribute");
                 }
                 None => "None",
             };
             let tracking_issue = find_attr_val(line, "issue").map(|s| s.parse().unwrap());
 
-            if features.contains_key(feature_name) {
-                err("duplicating a lang feature");
-            }
-            if let Some(ref s) = lib_features.get(feature_name) {
-                if s.level != level {
-                    err("different stability level than before");
-                }
-                if s.since != since {
-                    err("different `since` than before");
-                }
-                continue;
-            }
             let feature = Feature {
                 level,
                 since: since.to_owned(),
@@ -303,11 +341,10 @@ pub fn collect_lib_features(base_src_path: &Path,
                 tracking_issue,
             };
             if line.contains("]") {
-                lib_features.insert(feature_name.to_owned(), feature);
+                mf(Ok((feature_name, feature)), file, i + 1);
             } else {
                 becoming_feature = Some((feature_name.to_owned(), feature));
             }
         }
     });
-    lib_features
 }
diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs
index fd3ffc685d9..c8bfe42aa03 100644
--- a/src/tools/tidy/src/unstable_book.rs
+++ b/src/tools/tidy/src/unstable_book.rs
@@ -87,7 +87,7 @@ pub fn check(path: &path::Path, bad: &mut bool) {
     // Library features
 
     let lang_features = collect_lang_features(path);
-    let lib_features = collect_lib_features(path, bad, &lang_features);
+    let lib_features = collect_lib_features(path);
 
     let unstable_lib_feature_names = collect_unstable_feature_names(&lib_features);
     let unstable_book_lib_features_section_file_names =
diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs
index adec73d4a69..71063968ff2 100644
--- a/src/tools/unstable-book-gen/src/main.rs
+++ b/src/tools/unstable-book-gen/src/main.rs
@@ -129,8 +129,7 @@ fn main() {
     let dest_path = Path::new(&dest_path_str).join("src");
 
     let lang_features = collect_lang_features(src_path);
-    let mut bad = false;
-    let lib_features = collect_lib_features(src_path, &mut bad, &lang_features);
+    let lib_features = collect_lib_features(src_path);
 
     let doc_src_path = src_path.join(PATH_STR);