Struct cargo::ops::cargo_compile::unit_generator::UnitGenerator
source · pub(super) struct UnitGenerator<'a, 'cfg> {Show 13 fields
pub ws: &'a Workspace<'cfg>,
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<'cfg>,
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<'cfg>
§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<'cfg>
§profiles: &'a Profiles
§interner: &'a UnitInterner
§has_dev_units: HasDevUnits
Implementations§
source§impl<'a> UnitGenerator<'a, '_>
impl<'a> UnitGenerator<'a, '_>
sourcefn new_units(
&self,
pkg: &Package,
target: &Target,
initial_target_mode: CompileMode
) -> Vec<Unit>
fn new_units( &self, pkg: &Package, target: &Target, initial_target_mode: CompileMode ) -> Vec<Unit>
Helper for creating a list of Unit
structures
sourcefn filter_default_targets<'b>(&self, targets: &'b [Target]) -> Vec<&'b Target>
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.
sourcefn filter_targets(
&self,
predicate: impl Fn(&Target) -> bool,
requires_features: bool,
mode: CompileMode
) -> Vec<Proposal<'a>>
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.
sourcefn find_named_targets(
&self,
target_name: &str,
target_desc: &'static str,
is_expected_kind: fn(_: &Target) -> bool,
mode: CompileMode
) -> CargoResult<Vec<Proposal<'a>>>
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.
sourcefn list_rule_targets(
&self,
rule: &FilterRule,
target_desc: &'static str,
is_expected_kind: fn(_: &Target) -> bool,
mode: CompileMode
) -> CargoResult<Vec<Proposal<'a>>>
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.
sourcefn create_proposals(&self) -> CargoResult<Vec<Proposal<'_>>>
fn create_proposals(&self) -> CargoResult<Vec<Proposal<'_>>>
Create a list of proposed targets given the context in UnitGenerator
sourcefn create_docscrape_proposals(
&self,
doc_units: &[Unit]
) -> CargoResult<Vec<Proposal<'a>>>
fn create_docscrape_proposals( &self, doc_units: &[Unit] ) -> CargoResult<Vec<Proposal<'a>>>
Proposes targets from which to scrape examples for documentation
sourcefn unmatched_target_filters(&self, units: &[Unit]) -> CargoResult<()>
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
sourcefn validate_required_features(
&self,
target_name: &str,
required_features: &[String],
summary: &Summary
) -> CargoResult<()>
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.
sourcefn proposals_to_units(
&self,
proposals: Vec<Proposal<'_>>
) -> CargoResult<Vec<Unit>>
fn proposals_to_units( &self, proposals: Vec<Proposal<'_>> ) -> CargoResult<Vec<Unit>>
Converts proposals to units based on each target’s required features.
sourcepub fn generate_root_units(&self) -> CargoResult<Vec<Unit>>
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
.
sourcepub fn generate_scrape_units(
&self,
doc_units: &[Unit]
) -> CargoResult<Vec<Unit>>
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, 'cfg> !RefUnwindSafe for UnitGenerator<'a, 'cfg>
impl<'a, 'cfg> !Send for UnitGenerator<'a, 'cfg>
impl<'a, 'cfg> !Sync for UnitGenerator<'a, 'cfg>
impl<'a, 'cfg> Unpin for UnitGenerator<'a, 'cfg>
impl<'a, 'cfg> !UnwindSafe for UnitGenerator<'a, 'cfg>
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> 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> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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