@@ -87,7 +87,10 @@ pub(crate) fn from_target_feature_attr(
8787 // But ensure the ABI does not forbid enabling this.
8888 // Here we do assume that LLVM doesn't add even more implied features
8989 // we don't know about, at least no features that would have ABI effects!
90- if abi_feature_constraints. incompatible . contains ( & name. as_str ( ) ) {
90+ // We skip this check in rustdoc, like we skip all target feature related checks.
91+ if !tcx. sess . opts . actually_rustdoc
92+ && abi_feature_constraints. incompatible . contains ( & name. as_str ( ) )
93+ {
9194 tcx. dcx ( ) . emit_err ( errors:: ForbiddenTargetFeatureAttr {
9295 span : item. span ( ) ,
9396 feature : name. as_str ( ) ,
@@ -142,8 +145,11 @@ pub(crate) fn provide(providers: &mut Providers) {
142145 rust_target_features : |tcx, cnum| {
143146 assert_eq ! ( cnum, LOCAL_CRATE ) ;
144147 if tcx. sess . opts . actually_rustdoc {
145- // rustdoc needs to be able to document functions that use all the features, so
146- // whitelist them all
148+ // HACK: rustdoc would like to pretend that we have all the target features, so we
149+ // have to merge all the lists into one. The result has a "random" stability
150+ // (depending on the order in which we consider features); all places that check
151+ // target stability are expected to check `actually_rustdoc` and do nothing when
152+ // that is set.
147153 rustc_target:: target_features:: all_rust_features ( )
148154 . map ( |( a, b) | ( a. to_string ( ) , b) )
149155 . collect ( )
0 commit comments