forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#137632 - RalfJung:rustdoc-target-features, r=workingjubilee rustdoc: when merging target features, keep the highest stability This addresses rust-lang#137366. (Not closing since we might consider a backport.) rustdoc wants to pretend that it runs for all targets at once and has all target features, so `tcx.rust_target_features()` will actually be all the target features. For target features that exist on multiple targets, the stability info for one of the targets will be picked (first or last in the list, I guess). All the code consuming that query has to be aware that the data is basically nonsense when running in rustdoc, but the logic checking for unstable or forbidden `#[target_feature]` attributes was not aware of that. This PR makes the `tcx.rust_target_features()` info in rustdoc slightly less nonsensical (and decidedly less random) by having the "most stable" target feature take precedent. That deals with rust-lang#137366 (a conflict between a stable and a "forbidden" target feature of the same name for different targets), and also deals with the situation (that we did not seem to have yet) of a conflict between a stable and an unstable target feature of the same name. Note that if there are two unstable target features of the same name, rustdoc might still require the "wrong" nightly feature to be enabled -- but this can only possibly affect unstable code so I guess we can wait until that actually happens, and then someone will have to rewrite this entire thing to be less hacky.
- Loading branch information
Showing
2 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! This is a regression test for <https://github.com/rust-lang/rust/issues/137366>, ensuring | ||
//! that we can use the `neon` target feature on ARM32 targets in rustdoc despite there | ||
//! being a "forbidden" feature of the same name for aarch64, and rustdoc merging the | ||
//! target features of all targets. | ||
//@ check-pass | ||
//@ revisions: arm aarch64 | ||
//@[arm] compile-flags: --target armv7-unknown-linux-gnueabihf | ||
//@[arm] needs-llvm-components: arm | ||
//@[aarch64] compile-flags: --target aarch64-unknown-none-softfloat | ||
//@[aarch64] needs-llvm-components: aarch64 | ||
|
||
#![crate_type = "lib"] | ||
#![feature(no_core, lang_items)] | ||
#![feature(arm_target_feature)] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
pub trait Sized {} | ||
|
||
// `fp-armv8` is "forbidden" on aarch64 as we tie it to `neon`. | ||
#[target_feature(enable = "fp-armv8")] | ||
pub fn fun1() {} | ||
|
||
// This would usually be rejected as it changes the ABI. | ||
// But we disable that check in rustdoc since we are building "for all targets" and the | ||
// check can't really handle that. | ||
#[target_feature(enable = "soft-float")] | ||
pub fn fun2() {} |