about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-22 17:51:36 +0800
committerkennytm <kennytm@gmail.com>2018-03-22 22:43:50 +0800
commit3e95c71c18208c8e4ed7cf0bece80b6cb27587bc (patch)
treef387eb8f4fb1b07cfa1ffe124cac6a7a523c3911
parent346a46e9d65b62d43eda6de2a23620a38889a198 (diff)
parent2ba41e9d7943912dafe2f508c97d4083249d97a4 (diff)
downloadrust-3e95c71c18208c8e4ed7cf0bece80b6cb27587bc.tar.gz
rust-3e95c71c18208c8e4ed7cf0bece80b6cb27587bc.zip
Rollup merge of #49225 - QuietMisdreavus:all-the-features-all-the-time, r=alexcrichton
whitelist every target feature for rustdoc

When https://github.com/rust-lang-nursery/stdsimd/pull/367 was attempted to be upstreamed, it failed to document on non-x86 targets because it made every intrinsic visible, even the ones on foreign arches. This change makes it so that whenever rustdoc asks for the target feature whitelist, it gets a list of every feature known to every arch in `rustc_trans/llvm_util.rs`.

Before pushing, i temporarily updated the `stdsimd` submodule to include the `doc(cfg)` change, generated documentation for `aarch64-unknown-linux-gnu`, and it completed without a problem. The generated `core::arch` docs contained complete submodules for all main arches.
-rw-r--r--src/librustc_trans/attributes.rs16
-rw-r--r--src/librustc_trans/llvm_util.rs14
m---------src/stdsimd0
3 files changed, 26 insertions, 4 deletions
diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs
index d5ec8d1b552..040d9455334 100644
--- a/src/librustc_trans/attributes.rs
+++ b/src/librustc_trans/attributes.rs
@@ -148,9 +148,17 @@ fn cstr(s: &'static str) -> &CStr {
 pub fn provide(providers: &mut Providers) {
     providers.target_features_whitelist = |tcx, cnum| {
         assert_eq!(cnum, LOCAL_CRATE);
-        Lrc::new(llvm_util::target_feature_whitelist(tcx.sess)
-            .iter()
-            .map(|c| c.to_string())
-            .collect())
+        if tcx.sess.opts.actually_rustdoc {
+            // rustdoc needs to be able to document functions that use all the features, so
+            // whitelist them all
+            Lrc::new(llvm_util::all_known_features()
+                .map(|c| c.to_string())
+                .collect())
+        } else {
+            Lrc::new(llvm_util::target_feature_whitelist(tcx.sess)
+                .iter()
+                .map(|c| c.to_string())
+                .collect())
+        }
     };
 }
diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs
index dd8b44c96b9..5113b65a5c4 100644
--- a/src/librustc_trans/llvm_util.rs
+++ b/src/librustc_trans/llvm_util.rs
@@ -107,6 +107,20 @@ const POWERPC_WHITELIST: &'static [&'static str] = &["altivec",
 
 const MIPS_WHITELIST: &'static [&'static str] = &["fp64", "msa"];
 
+/// When rustdoc is running, provide a list of all known features so that all their respective
+/// primtives may be documented.
+///
+/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this
+/// iterator!
+pub fn all_known_features() -> impl Iterator<Item=&'static str> {
+    ARM_WHITELIST.iter().cloned()
+        .chain(AARCH64_WHITELIST.iter().cloned())
+        .chain(X86_WHITELIST.iter().cloned())
+        .chain(HEXAGON_WHITELIST.iter().cloned())
+        .chain(POWERPC_WHITELIST.iter().cloned())
+        .chain(MIPS_WHITELIST.iter().cloned())
+}
+
 pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
     let arch = if sess.target.target.arch == "x86_64" {
         "x86"
diff --git a/src/stdsimd b/src/stdsimd
-Subproject ab9356f2af650815d339d77306f0d09c44d531a
+Subproject bcb720e55861c38db47f2ebdf26b7198338cb39