]> git.lizzy.rs Git - rust.git/commitdiff
whitelist every target feature for rustdoc
authorQuietMisdreavus <grey@quietmisdreavus.net>
Wed, 21 Mar 2018 00:36:30 +0000 (19:36 -0500)
committerQuietMisdreavus <grey@quietmisdreavus.net>
Wed, 21 Mar 2018 00:36:30 +0000 (19:36 -0500)
src/librustc_trans/attributes.rs
src/librustc_trans/llvm_util.rs

index d5ec8d1b5526256573cf69552de26dc754f878fd..040d9455334bc9ede85ff33901506f72683c1be3 100644 (file)
@@ -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())
+        }
     };
 }
index dd8b44c96b90c575639ef245f89dad39f8e6e6c3..5113b65a5c4700231f9e573711669abe549426ac 100644 (file)
@@ -107,6 +107,20 @@ unsafe fn configure_llvm(sess: &Session) {
 
 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"