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: boolHandle path dependencies? (default: true) If false, path dependencies are excluded from unification
include_renamed: boolHandle renamed dependencies (package = “…”)? (default: false) Renamed deps are tricky to unify correctly, opt-in only
pin_transitives: boolPin 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: TransitiveFeatureHostWhere 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: usizeMaximum number of backups to keep (default: 3) Older backups are automatically cleaned up after successful unify operations
msrv: boolCompute 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: boolEnforce 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: MsrvSourceHow 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: boolPrune 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: boolStrict 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: ExactPinHandlingHow 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: MajorVersionConflictHow 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: boolDetect 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: boolAutomatically 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: boolDetect 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: boolAuto-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: boolSort dependencies alphabetically when writing Cargo.toml files (default: true) When false, preserves existing order and appends new deps at end.
Implementations§
Source§impl UnifyConfig
impl UnifyConfig
Sourcepub fn should_exclude(&self, dep_name: &str) -> bool
pub fn should_exclude(&self, dep_name: &str) -> bool
Check if a dependency should be excluded from unification
Sourcepub fn should_include(&self, dep_name: &str) -> bool
pub fn should_include(&self, dep_name: &str) -> bool
Check if a dependency should be force-included in unification
Sourcepub fn should_preserve_feature(&self, feature_name: &str) -> bool
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”)
Sourcepub fn should_skip_undeclared_feature(&self, feature_name: &str) -> bool
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”)
Trait Implementations§
Source§impl Clone for UnifyConfig
impl Clone for UnifyConfig
Source§fn clone(&self) -> UnifyConfig
fn clone(&self) -> UnifyConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnifyConfig
impl Debug for UnifyConfig
Source§impl Default for UnifyConfig
impl Default for UnifyConfig
Source§impl<'de> Deserialize<'de> for UnifyConfig
impl<'de> Deserialize<'de> for UnifyConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for UnifyConfig
impl RefUnwindSafe for UnifyConfig
impl Send for UnifyConfig
impl Sync for UnifyConfig
impl Unpin for UnifyConfig
impl UnsafeUnpin for UnifyConfig
impl UnwindSafe for UnifyConfig
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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