pub enum Stability<Toggleability> {
Stable {
allow_toggle: Toggleability,
},
Unstable {
nightly_feature: Symbol,
allow_toggle: Toggleability,
},
Forbidden {
reason: &'static str,
},
}
Expand description
Stability information for target features.
Toggleability
is the type storing whether (un)stable features can be toggled:
this is initially a function since it can depend on Target
, but for stable hashing
it needs to be something hashable to we have to make the type generic.
Variants§
Stable
This target feature is stable, it can be used in #[target_feature]
and
#[cfg(target_feature)]
.
Fields
allow_toggle: Toggleability
When enabling/disabling the feature via -Ctarget-feature
or #[target_feature]
,
determine if that is allowed.
Unstable
This target feature is unstable. It is only present in #[cfg(target_feature)]
on
nightly and using it in #[target_feature]
requires enabling the given nightly feature.
Fields
nightly_feature: Symbol
This must be a language feature, or else rustc will ICE when reporting a missing feature gate!
allow_toggle: Toggleability
See Stable::allow_toggle
comment above.
Forbidden
This feature can not be set via -Ctarget-feature
or #[target_feature]
, it can only be
set in the target spec. It is never set in cfg(target_feature)
. Used in
particular for features that change the floating-point ABI.
Implementations§
Source§impl<Toggleability> Stability<Toggleability>
impl<Toggleability> Stability<Toggleability>
Sourcepub fn in_cfg(&self) -> bool
pub fn in_cfg(&self) -> bool
Returns whether the feature can be used in cfg(target_feature)
ever.
(It might still be nightly-only even if this returns true
, so make sure to also check
requires_nightly
.)
Sourcepub fn requires_nightly(&self) -> Option<Symbol>
pub fn requires_nightly(&self) -> Option<Symbol>
Returns the nightly feature that is required to toggle this target feature via
#[target_feature]
/-Ctarget-feature
or to test it via cfg(target_feature)
.
(For cfg
we only care whether the feature is nightly or not, we don’t require
the feature gate to actually be enabled when using a nightly compiler.)
Before calling this, ensure the feature is even permitted for this use:
- for
#[target_feature]
/-Ctarget-feature
, checkallow_toggle()
- for
cfg(target_feature)
, checkin_cfg
Source§impl Stability<fn(_: &Target, _: bool) -> Result<(), &'static str>>
impl Stability<fn(_: &Target, _: bool) -> Result<(), &'static str>>
pub fn compute_toggleability(&self, target: &Target) -> StabilityComputed
pub fn toggle_allowed( &self, target: &Target, enable: bool, ) -> Result<(), &'static str>
Trait Implementations§
Source§impl<CTX, Toggleability: HashStable<CTX>> HashStable<CTX> for Stability<Toggleability>
impl<CTX, Toggleability: HashStable<CTX>> HashStable<CTX> for Stability<Toggleability>
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
Auto Trait Implementations§
impl<Toggleability> DynSend for Stability<Toggleability>where
Toggleability: DynSend,
impl<Toggleability> DynSync for Stability<Toggleability>where
Toggleability: DynSync,
impl<Toggleability> Freeze for Stability<Toggleability>where
Toggleability: Freeze,
impl<Toggleability> RefUnwindSafe for Stability<Toggleability>where
Toggleability: RefUnwindSafe,
impl<Toggleability> Send for Stability<Toggleability>where
Toggleability: Send,
impl<Toggleability> Sync for Stability<Toggleability>where
Toggleability: Sync,
impl<Toggleability> Unpin for Stability<Toggleability>where
Toggleability: Unpin,
impl<Toggleability> UnwindSafe for Stability<Toggleability>where
Toggleability: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.