mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Auto merge of #132880 - RalfJung:implied-features, r=workingjubilee
target_features: explain what exacty 'implied' means here
This commit is contained in:
commit
71042b4b20
@ -344,15 +344,23 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
|
|||||||
})
|
})
|
||||||
{
|
{
|
||||||
if enabled {
|
if enabled {
|
||||||
|
// Also add all transitively implied features.
|
||||||
features.extend(sess.target.implied_target_features(std::iter::once(feature)));
|
features.extend(sess.target.implied_target_features(std::iter::once(feature)));
|
||||||
} else {
|
} else {
|
||||||
|
// Remove transitively reverse-implied features.
|
||||||
|
|
||||||
// We don't care about the order in `features` since the only thing we use it for is the
|
// We don't care about the order in `features` since the only thing we use it for is the
|
||||||
// `features.contains` below.
|
// `features.contains` below.
|
||||||
#[allow(rustc::potential_query_instability)]
|
#[allow(rustc::potential_query_instability)]
|
||||||
features.retain(|f| {
|
features.retain(|f| {
|
||||||
// Keep a feature if it does not imply `feature`. Or, equivalently,
|
if sess.target.implied_target_features(std::iter::once(*f)).contains(&feature) {
|
||||||
// remove the reverse-dependencies of `feature`.
|
// If `f` if implies `feature`, then `!feature` implies `!f`, so we have to
|
||||||
!sess.target.implied_target_features(std::iter::once(*f)).contains(&feature)
|
// remove `f`. (This is the standard logical contraposition principle.)
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
// We can keep `f`.
|
||||||
|
true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,11 @@ impl Stability {
|
|||||||
//
|
//
|
||||||
// Stabilizing a target feature requires t-lang approval.
|
// Stabilizing a target feature requires t-lang approval.
|
||||||
|
|
||||||
|
// If feature A "implies" feature B, then:
|
||||||
|
// - when A gets enabled (via `-Ctarget-feature` or `#[target_feature]`), we also enable B
|
||||||
|
// - when B gets disabled (via `-Ctarget-feature`), we also disable A
|
||||||
|
//
|
||||||
|
// Both of these are also applied transitively.
|
||||||
type ImpliedFeatures = &'static [&'static str];
|
type ImpliedFeatures = &'static [&'static str];
|
||||||
|
|
||||||
const ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
const ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
||||||
|
Loading…
Reference in New Issue
Block a user