Skip to main content

UnifyConfig

Struct UnifyConfig 

Source
pub struct UnifyConfig {
Show 21 fields pub include_paths: bool, pub include_renamed: bool, pub pin_transitives: bool, pub transitive_host: TransitiveFeatureHost, pub exclude: Vec<String>, pub include: Vec<String>, pub max_backups: usize, pub msrv: bool, pub enforce_msrv_inheritance: bool, pub msrv_source: MsrvSource, pub prune_dead_features: bool, pub preserve_features: Vec<String>, pub strict_version_compat: bool, pub exact_pin_handling: ExactPinHandling, pub major_version_conflict: MajorVersionConflict, pub detect_unused: bool, pub remove_unused: bool, pub detect_undeclared_features: bool, pub fix_undeclared_features: bool, pub skip_undeclared_patterns: Vec<String>, pub sort_dependencies: bool,
}
Expand description

Unify configuration - controls workspace dependency unification behavior

Fields§

§include_paths: bool

Handle path dependencies? (default: true) If false, path dependencies are excluded from unification

§include_renamed: bool

Handle renamed dependencies (package = “…”)? (default: false) Renamed deps are tricky to unify correctly, opt-in only

§pin_transitives: bool

Pin transitive-only deps with fragmented features? (default: false) This is cargo-rail’s workspace-hack replacement When enabled, transitive deps with multiple feature sets are pinned in workspace.dependencies Only enable if your project uses cargo-hakari or a workspace-hack crate

§transitive_host: TransitiveFeatureHost

Where to put pinned transitive dev-deps? (default: “root”) Options: “root” or a path like “crates/foo”

§exclude: Vec<String>

Dependencies to exclude from unification (safety hatch)

§include: Vec<String>

Dependencies to force-include in unification (safety hatch)

§max_backups: usize

Maximum number of backups to keep (default: 3) Older backups are automatically cleaned up after successful unify operations

§msrv: bool

Compute and write MSRV to workspace manifest? (default: true) When enabled, cargo-rail computes the maximum rust-version from all resolved dependencies and writes it to [workspace.package].rust-version

§enforce_msrv_inheritance: bool

Enforce MSRV inheritance on workspace members (default: false)

When enabled, cargo rail unify ensures every workspace member’s Cargo.toml has package.rust-version = { workspace = true }, so that [workspace.package].rust-version is actually enforced across the workspace.

Note: this requires msrv = true and a workspace MSRV that exists or can be computed.

§msrv_source: MsrvSource

How to determine the final MSRV value (default: “max”)

  • “deps”: Use maximum from dependencies only (original behavior)
  • “workspace”: Preserve existing rust-version, warn if deps need higher
  • “max”: Take max(workspace, deps) - explicit workspace setting wins if higher
§prune_dead_features: bool

Prune features not referenced in source code? (default: true) When enabled, analyzes the resolved dependency graph to detect features that are declared but never enabled by any consumer across all targets. This produces the absolute leanest feature set for the workspace.

§preserve_features: Vec<String>

Features to preserve from dead feature pruning (glob patterns supported) Use this to keep features intended for future use or external consumers. Examples: [“future-api”, “unstable-”, “bench”]

§strict_version_compat: bool

Strict version compatibility checking (default: true) When true, version mismatches between member manifests and existing workspace.dependencies are reported as blocking errors. When false, they are warnings only.

§exact_pin_handling: ExactPinHandling

How to handle exact version pins like “=0.8.0” (default: “warn”)

  • “skip”: Exclude exact-pinned deps from unification
  • “preserve”: Keep the exact pin operator in workspace.dependencies
  • “warn”: Convert to caret but emit a warning
§major_version_conflict: MajorVersionConflict

How to handle major version conflicts (default: “warn”)

  • “warn”: Skip unification and emit a warning (both versions stay in graph)
  • “bump”: Force unify to highest resolved version (user accepts breakage risk)
§detect_unused: bool

Detect unused dependencies in workspace members (default: true) When enabled, compares declared deps against the resolved cargo graph to find deps that are declared but never actually used.

§remove_unused: bool

Automatically remove unused dependencies when applying (default: true) Requires detect_unused = true. When enabled, unused deps are removed from member Cargo.toml files during unify.

§detect_undeclared_features: bool

Detect undeclared feature dependencies (default: true) When enabled, compares resolved features against declared features in Cargo.toml to find crates that rely on Cargo’s feature unification to “borrow” features from other workspace members. After unification, standalone builds of these crates will fail. Reports as warnings to help fix before unification.

§fix_undeclared_features: bool

Auto-fix undeclared feature dependencies (default: true) When enabled (and detect_undeclared_features is true), automatically adds missing features to each crate’s Cargo.toml instead of just warning. This produces a cleaner graph where standalone builds work correctly.

§skip_undeclared_patterns: Vec<String>

Patterns for features to skip in undeclared feature detection (glob supported) Default: [“default”, “std”, “alloc”, “_backend”, “_impl”] These are features that are typically not actionable or are implementation details.

§sort_dependencies: bool

Sort dependencies alphabetically when writing Cargo.toml files (default: true) When false, preserves existing order and appends new deps at end.

Implementations§

Source§

impl UnifyConfig

Source

pub fn should_exclude(&self, dep_name: &str) -> bool

Check if a dependency should be excluded from unification

Source

pub fn should_include(&self, dep_name: &str) -> bool

Check if a dependency should be force-included in unification

Source

pub fn should_preserve_feature(&self, feature_name: &str) -> bool

Check if a feature should be preserved from dead feature pruning

Supports glob patterns (e.g., “unstable-”, “bench”)

Source

pub fn should_skip_undeclared_feature(&self, feature_name: &str) -> bool

Check if a feature should be skipped in undeclared feature detection

Supports glob patterns (e.g., “_backend”, “_impl”)

Source

pub fn validate(&self, workspace_root: &Path) -> Result<(), ConfigError>

Validate unify configuration against the workspace

Checks:

  • transitive_host path exists if configured as a path (not “root”)
  • transitive_host path contains a Cargo.toml (is a valid crate/workspace)

Trait Implementations§

Source§

impl Clone for UnifyConfig

Source§

fn clone(&self) -> UnifyConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnifyConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UnifyConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for UnifyConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for UnifyConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,