Skip to content

Commit 6956bbf

Browse files
whitelist every target feature for rustdoc
1 parent a04b88d commit 6956bbf

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/librustc_trans/attributes.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,17 @@ fn cstr(s: &'static str) -> &CStr {
148148
pub fn provide(providers: &mut Providers) {
149149
providers.target_features_whitelist = |tcx, cnum| {
150150
assert_eq!(cnum, LOCAL_CRATE);
151-
Lrc::new(llvm_util::target_feature_whitelist(tcx.sess)
152-
.iter()
153-
.map(|c| c.to_string())
154-
.collect())
151+
if tcx.sess.opts.actually_rustdoc {
152+
// rustdoc needs to be able to document functions that use all the features, so
153+
// whitelist them all
154+
Lrc::new(llvm_util::all_known_features()
155+
.map(|c| c.to_string())
156+
.collect())
157+
} else {
158+
Lrc::new(llvm_util::target_feature_whitelist(tcx.sess)
159+
.iter()
160+
.map(|c| c.to_string())
161+
.collect())
162+
}
155163
};
156164
}

src/librustc_trans/llvm_util.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ const POWERPC_WHITELIST: &'static [&'static str] = &["altivec",
107107

108108
const MIPS_WHITELIST: &'static [&'static str] = &["fp64", "msa"];
109109

110+
/// When rustdoc is running, provide a list of all known features so that all their respective
111+
/// primtives may be documented.
112+
///
113+
/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this
114+
/// iterator!
115+
pub fn all_known_features() -> impl Iterator<Item=&'static str> {
116+
ARM_WHITELIST.iter().cloned()
117+
.chain(AARCH64_WHITELIST.iter().cloned())
118+
.chain(X86_WHITELIST.iter().cloned())
119+
.chain(HEXAGON_WHITELIST.iter().cloned())
120+
.chain(POWERPC_WHITELIST.iter().cloned())
121+
.chain(MIPS_WHITELIST.iter().cloned())
122+
}
123+
110124
pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
111125
let arch = if sess.target.target.arch == "x86_64" {
112126
"x86"

0 commit comments

Comments
 (0)