pub struct ParsedRustcArgs {Show 22 fields
pub crate_name: String,
pub crate_types: Vec<String>,
pub features: BTreeSet<String>,
pub cfgs: BTreeSet<String>,
pub emit: BTreeSet<String>,
pub json: BTreeSet<String>,
pub input_path: Option<PathBuf>,
pub target: Option<String>,
pub c_metadata: Option<String>,
pub out_dir: Option<PathBuf>,
pub extra_filename: String,
pub opt_level: Option<String>,
pub debuginfo: Option<String>,
pub panic_strategy: Option<String>,
pub debug_assertions: Option<bool>,
pub overflow_checks: Option<bool>,
pub strip: Option<String>,
pub native_search_paths: Vec<PathBuf>,
pub extern_crates: Vec<ParsedExternCrate>,
pub embed_metadata: Option<bool>,
pub embed_bitcode: bool,
pub has_custom_codegen: bool,
}Expand description
The subset of a rustc command line that determines cache identity and output layout.
Populated by ParsedRustcArgs::parse; fields are Option where the
corresponding flag may be absent.
Fields§
§crate_name: String--crate-name value; a parse without one fails.
crate_types: Vec<String>--crate-type list, split on ,.
features: BTreeSet<String>feature="…" values collected from --cfg flags.
cfgs: BTreeSet<String>Every other --cfg value: build-script cargo:rustc-cfg output and
--cfg flags from RUSTFLAGS. They select code at compile time, so
they are compile identity, kept separate from features because the
semantic tuple registries index on is features only.
emit: BTreeSet<String>--emit kinds, deduplicated.
json: BTreeSet<String>--json kinds, deduplicated.
input_path: Option<PathBuf>The .rs input file, when one was passed.
target: Option<String>--target triple, or None for an implicit host target.
c_metadata: Option<String>-C metadata value.
out_dir: Option<PathBuf>--out-dir directory.
extra_filename: String-C extra-filename suffix (empty when absent).
opt_level: Option<String>-C opt-level value.
debuginfo: Option<String>-C debuginfo value.
panic_strategy: Option<String>-C panic value.
debug_assertions: Option<bool>-C debug-assertions value.
overflow_checks: Option<bool>-C overflow-checks value.
strip: Option<String>-C strip value.
native_search_paths: Vec<PathBuf>-L native=… search paths.
extern_crates: Vec<ParsedExternCrate>--extern pairs, sorted by crate name then path.
embed_metadata: Option<bool>-Z embed-metadata value. Nightly cargo passes this flag on every
unit, so it is toolchain identity rather than custom codegen; it
changes the produced rlib, so it participates in the compile key.
embed_bitcode: boolWhether the produced object files carry LLVM bitcode. rustc embeds
bitcode unless -C embed-bitcode=no, the value cargo passes to every
unit that no LTO consumer needs bitcode from; a unit compiled with
bitcode is a different artifact, so this participates in the compile
key.
has_custom_codegen: boolWhether the invocation (or RUSTFLAGS / CARGO_ENCODED_RUSTFLAGS)
carries codegen flags stow does not model; such builds are never
served from the public cache.
Implementations§
Source§impl ParsedRustcArgs
impl ParsedRustcArgs
Sourcepub fn parse(args: &[OsString]) -> Result<Self, String>
pub fn parse(args: &[OsString]) -> Result<Self, String>
Parse a captured rustc argv into ParsedRustcArgs.
Recognizes the flags cargo passes for dependency compilations. Unknown
-C / -Z options set has_custom_codegen rather than failing, so
the invocation is still parsed — it just will not be cacheable.
§Errors
Returns an error when an argument is not valid UTF-8, a flag that
requires a value is the last argument, an --extern pair or codegen
boolean is malformed, or --crate-name is missing.
Sourcepub fn is_cacheable(&self) -> bool
pub fn is_cacheable(&self) -> bool
Whether this invocation may be served from the public cache.
Requires a restorable artifact, no custom codegen flags, and no
CARGO_PRIMARY_PACKAGE (workspace crates are never cached). The
profile is not a restriction: opt-level, debuginfo, assertions,
panic and strip are all part of the compile identity, so a unit
built under any profile is served exactly when the pool holds an
artifact built under the same one.
Sourcepub fn is_locally_cacheable(&self) -> bool
pub fn is_locally_cacheable(&self) -> bool
Whether this invocation’s outputs may be stored in the local artifact cache after a successful build.
The gate is deliberately narrower than Self::is_cacheable in one
direction and wider in another: the artifacts are self-produced, so
there is no profile restriction — dev and release outputs are worth
keeping because cross-worktree release rebuilds are exactly where a
local cache pays. What remains mandatory is a restorable artifact
shape, no custom codegen flags, and not being the workspace’s primary
package (CARGO_PRIMARY_PACKAGE): first-party code is never cached.
Sourcepub fn is_restorable_artifact(&self) -> bool
pub fn is_restorable_artifact(&self) -> bool
Whether the invocation produces an artifact stow can restore: an rlib
or dynamic library with both -C metadata and --out-dir present.
Sourcepub fn is_proc_macro(&self) -> bool
pub fn is_proc_macro(&self) -> bool
Whether any --crate-type is proc-macro.
Sourcepub fn produces_rlib(&self) -> bool
pub fn produces_rlib(&self) -> bool
Whether any --crate-type is lib or rlib.
Sourcepub fn produces_dynamic_library(&self) -> bool
pub fn produces_dynamic_library(&self) -> bool
Whether any --crate-type is proc-macro or dylib.
Sourcepub fn is_build_script(&self) -> bool
pub fn is_build_script(&self) -> bool
Whether this is the build_script_build binary cargo compiles for
build scripts.
Sourcepub fn requests_json_artifact_notifications(&self) -> bool
pub fn requests_json_artifact_notifications(&self) -> bool
Whether --json includes artifacts (cargo’s artifact-notification
channel the capture wrapper relies on).
Sourcepub fn output_rlib_path(&self) -> Option<PathBuf>
pub fn output_rlib_path(&self) -> Option<PathBuf>
Path of the emitted .rlib under --out-dir
(lib<name><extra-filename>.rlib), or None when the invocation does
not produce an rlib or has no --out-dir.
Sourcepub fn output_rmeta_path(&self) -> Option<PathBuf>
pub fn output_rmeta_path(&self) -> Option<PathBuf>
Path of the emitted .rmeta under --out-dir
(lib<name><extra-filename>.rmeta), or None without --out-dir.
Sourcepub fn output_dynamic_library_path(&self) -> Result<Option<PathBuf>, String>
pub fn output_dynamic_library_path(&self) -> Result<Option<PathBuf>, String>
Path of the emitted dynamic library under --out-dir, named per the
target’s binary format (lib*.so / lib*.dylib / *.dll).
Returns Ok(None) when the invocation produces no dynamic library.
§Errors
Returns an error when a dynamic library is produced but --out-dir is
absent, or when the --target triple is unparseable or has an
unsupported binary format.
Sourcepub fn output_dep_info_path(&self) -> Option<PathBuf>
pub fn output_dep_info_path(&self) -> Option<PathBuf>
Path of the emitted dep-info file under --out-dir
(<name><extra-filename>.d), or None without --out-dir.
Sourcepub fn output_binary_path(&self) -> Option<PathBuf>
pub fn output_binary_path(&self) -> Option<PathBuf>
Path of the emitted binary under --out-dir
(<name><extra-filename><exe-suffix>), or None when the invocation
is not a bin crate or has no --out-dir.
Sourcepub fn output_link_path(&self) -> Result<Option<PathBuf>, String>
pub fn output_link_path(&self) -> Result<Option<PathBuf>, String>
Path of the artifact a downstream crate would link against: the
.rlib, then the binary, then the dynamic library.
§Errors
Propagates Self::output_dynamic_library_path’s error when the
invocation produces a dynamic library without --out-dir or with an
unparseable target.
Sourcepub fn build_script_alias_path(&self) -> Option<PathBuf>
pub fn build_script_alias_path(&self) -> Option<PathBuf>
The build-script-build alias cargo creates next to the build script
binary, or None when this is not a build script or --out-dir is
absent.
Sourcepub fn profile(&self) -> Result<Profile, String>
pub fn profile(&self) -> Result<Profile, String>
The cargo profile this invocation compiles with, defaulting absent
flags to cargo’s debug values (opt-level=0, debug assertions and
overflow checks on, panic=unwind).
§Errors
Returns an error when -C debuginfo, -C panic or -C strip carry
values outside the set rustc documents.
Trait Implementations§
Source§impl Clone for ParsedRustcArgs
impl Clone for ParsedRustcArgs
Source§impl Debug for ParsedRustcArgs
impl Debug for ParsedRustcArgs
impl Eq for ParsedRustcArgs
Source§impl PartialEq for ParsedRustcArgs
impl PartialEq for ParsedRustcArgs
impl StructuralPartialEq for ParsedRustcArgs
Auto Trait Implementations§
impl Freeze for ParsedRustcArgs
impl RefUnwindSafe for ParsedRustcArgs
impl Send for ParsedRustcArgs
impl Sync for ParsedRustcArgs
impl Unpin for ParsedRustcArgs
impl UnsafeUnpin for ParsedRustcArgs
impl UnwindSafe for ParsedRustcArgs
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.