pub struct UnitFor { /* private fields */ }
Expand description
Flags used in creating Unit
s to indicate the purpose for the target, and
to ensure the target’s dependencies have the correct settings.
This means these are passed down from the root of the dependency tree to apply to most child dependencies.
Implementations§
source§impl UnitFor
impl UnitFor
sourcepub fn new_normal(root_compile_kind: CompileKind) -> UnitFor
pub fn new_normal(root_compile_kind: CompileKind) -> UnitFor
A unit for a normal target/dependency (i.e., not custom build, proc macro/plugin, or test/bench).
sourcepub fn new_host(host_features: bool, root_compile_kind: CompileKind) -> UnitFor
pub fn new_host(host_features: bool, root_compile_kind: CompileKind) -> UnitFor
A unit for a custom build script or proc-macro or its dependencies.
The host_features
parameter is whether or not this is for a build
dependency or proc-macro (something that requires being built “on the
host”). Build scripts for non-host units should use false
because
they want to use the features of the package they are running for.
sourcepub fn new_compiler(root_compile_kind: CompileKind) -> UnitFor
pub fn new_compiler(root_compile_kind: CompileKind) -> UnitFor
A unit for a compiler plugin or their dependencies.
sourcepub fn new_test(config: &Config, root_compile_kind: CompileKind) -> UnitFor
pub fn new_test(config: &Config, root_compile_kind: CompileKind) -> UnitFor
A unit for a test/bench target or their dependencies.
Note that config
is taken here for unstable CLI features to detect
whether panic=abort
is supported for tests. Historical versions of
rustc did not support this, but newer versions do with an unstable
compiler flag.
sourcepub fn new_host_test(config: &Config, root_compile_kind: CompileKind) -> UnitFor
pub fn new_host_test(config: &Config, root_compile_kind: CompileKind) -> UnitFor
This is a special case for unit tests of a proc-macro.
Proc-macro unit tests are forced to be run on the host.
sourcepub fn with_dependency(
self,
parent: &Unit,
dep_target: &Target,
root_compile_kind: CompileKind
) -> UnitFor
pub fn with_dependency( self, parent: &Unit, dep_target: &Target, root_compile_kind: CompileKind ) -> UnitFor
Returns a new copy updated based on the target dependency.
This is where the magic happens that the host/host_features settings transition in a sticky fashion. As the dependency graph is being built, once those flags are set, they stay set for the duration of that portion of tree.
pub fn for_custom_build(self) -> UnitFor
sourcepub fn is_for_host(&self) -> bool
pub fn is_for_host(&self) -> bool
Returns true
if this unit is for a build script or any of its
dependencies, or a proc macro or any of its dependencies.
pub fn is_for_host_features(&self) -> bool
Trait Implementations§
source§impl Ord for UnitFor
impl Ord for UnitFor
source§impl PartialEq for UnitFor
impl PartialEq for UnitFor
source§impl PartialOrd for UnitFor
impl PartialOrd for UnitFor
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for UnitFor
impl Eq for UnitFor
impl StructuralPartialEq for UnitFor
Auto Trait Implementations§
impl RefUnwindSafe for UnitFor
impl Send for UnitFor
impl Sync for UnitFor
impl Unpin for UnitFor
impl UnwindSafe for UnitFor
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.