Struct cargo::ops::cargo_compile::unit_generator::UnitGenerator

source ·
pub(super) struct UnitGenerator<'a, 'gctx> {
Show 13 fields pub ws: &'a Workspace<'gctx>, pub packages: &'a [&'a Package], pub filter: &'a CompileFilter, pub requested_kinds: &'a [CompileKind], pub explicit_host_kind: CompileKind, pub mode: CompileMode, pub resolve: &'a Resolve, pub workspace_resolve: &'a Option<Resolve>, pub resolved_features: &'a ResolvedFeatures, pub package_set: &'a PackageSet<'gctx>, pub profiles: &'a Profiles, pub interner: &'a UnitInterner, pub has_dev_units: HasDevUnits,
}
Expand description

The context needed for generating root units, which are packages the user has requested to compile.

To generate a full UnitGraph, generally you need to call generate_root_units first, and then provide the output to build_unit_dependencies.

Fields§

§ws: &'a Workspace<'gctx>§packages: &'a [&'a Package]§filter: &'a CompileFilter§requested_kinds: &'a [CompileKind]§explicit_host_kind: CompileKind§mode: CompileMode§resolve: &'a Resolve§workspace_resolve: &'a Option<Resolve>§resolved_features: &'a ResolvedFeatures§package_set: &'a PackageSet<'gctx>§profiles: &'a Profiles§interner: &'a UnitInterner§has_dev_units: HasDevUnits

Implementations§

source§

impl<'a> UnitGenerator<'a, '_>

source

fn new_units( &self, pkg: &Package, target: &Target, initial_target_mode: CompileMode ) -> Vec<Unit>

Helper for creating a list of Unit structures

source

fn filter_default_targets<'b>(&self, targets: &'b [Target]) -> Vec<&'b Target>

Given a list of all targets for a package, filters out only the targets that are automatically included when the user doesn’t specify any targets.

source

fn filter_targets( &self, predicate: impl Fn(&Target) -> bool, requires_features: bool, mode: CompileMode ) -> Vec<Proposal<'a>>

Filters the set of all possible targets based on the provided predicate.

source

fn find_named_targets( &self, target_name: &str, target_desc: &'static str, is_expected_kind: fn(_: &Target) -> bool, mode: CompileMode ) -> CargoResult<Vec<Proposal<'a>>>

Finds the targets for a specifically named target.

source

fn list_rule_targets( &self, rule: &FilterRule, target_desc: &'static str, is_expected_kind: fn(_: &Target) -> bool, mode: CompileMode ) -> CargoResult<Vec<Proposal<'a>>>

Returns a list of proposed targets based on command-line target selection flags.

source

fn create_proposals(&self) -> CargoResult<Vec<Proposal<'_>>>

Create a list of proposed targets given the context in UnitGenerator

source

fn create_docscrape_proposals( &self, doc_units: &[Unit] ) -> CargoResult<Vec<Proposal<'a>>>

Proposes targets from which to scrape examples for documentation

source

fn unmatched_target_filters(&self, units: &[Unit]) -> CargoResult<()>

Checks if the unit list is empty and the user has passed any combination of –tests, –examples, –benches or –bins, and we didn’t match on any targets. We want to emit a warning to make sure the user knows that this run is a no-op, and their code remains unchecked despite cargo not returning any errors

source

fn validate_required_features( &self, target_name: &str, required_features: &[String], summary: &Summary ) -> CargoResult<()>

Warns if a target’s required-features references a feature that doesn’t exist.

This is a warning because historically this was not validated, and it would cause too much breakage to make it an error.

source

fn proposals_to_units( &self, proposals: Vec<Proposal<'_>> ) -> CargoResult<Vec<Unit>>

Converts proposals to units based on each target’s required features.

source

pub fn generate_root_units(&self) -> CargoResult<Vec<Unit>>

Generates all the base units for the packages the user has requested to compile. Dependencies for these units are computed later in unit_dependencies.

source

pub fn generate_scrape_units( &self, doc_units: &[Unit] ) -> CargoResult<Vec<Unit>>

Generates units specifically for doc-scraping.

This requires a separate entrypoint from generate_root_units because it takes the documented units as input.

Auto Trait Implementations§

§

impl<'a, 'gctx> Freeze for UnitGenerator<'a, 'gctx>

§

impl<'a, 'gctx> !RefUnwindSafe for UnitGenerator<'a, 'gctx>

§

impl<'a, 'gctx> !Send for UnitGenerator<'a, 'gctx>

§

impl<'a, 'gctx> !Sync for UnitGenerator<'a, 'gctx>

§

impl<'a, 'gctx> Unpin for UnitGenerator<'a, 'gctx>

§

impl<'a, 'gctx> !UnwindSafe for UnitGenerator<'a, 'gctx>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 120 bytes