11//! Unified manifest analysis for feature classification
22//!
3- //! This module handles ALL manifest parsing and analysis, replacing the duplicate
4- //! handling between manifest.rs and unify/manifest_parser.rs
3+ //! This module handles ALL manifest parsing and analysis
54
65use crate :: error:: { RailResult , ResultExt } ;
76use cargo_metadata:: DependencyKind as MetadataDepKind ;
@@ -11,11 +10,9 @@ use std::path::{Path, PathBuf};
1110use std:: sync:: Arc ;
1211use toml_edit:: { DocumentMut , Item , Value } ;
1312
14- // ============================================================================
1513// Core Types
16- // ============================================================================
1714
18- /// Unique identifier for a dependency
15+ /// Unique identifier for a dep
1916///
2017/// Uses `Arc<str>` for the name fields to avoid expensive clones in hot loops.
2118/// Cloning a DepKey is cheap (just Arc refcount bumps).
@@ -161,9 +158,7 @@ pub struct ParsedManifest {
161158 pub dependencies : HashMap < DepKey , DepUsage > ,
162159}
163160
164- // ============================================================================
165161// Parse Context
166- // ============================================================================
167162
168163/// Context for parsing dependency sections within a single manifest.
169164/// Bundles common parameters to reduce function argument count.
@@ -176,9 +171,7 @@ struct ParseContext<'a> {
176171 dependencies : & ' a mut HashMap < DepKey , DepUsage > ,
177172}
178173
179- // ============================================================================
180174// Main Analyzer
181- // ============================================================================
182175
183176/// Analyzes all workspace manifests for dependency usage patterns
184177pub struct ManifestAnalyzer {
@@ -616,7 +609,7 @@ impl ManifestAnalyzer {
616609
617610 /// Count how many crates use a package (aggregated across renamed and non-renamed deps)
618611 ///
619- /// Issue #6: When include_renamed = true, count all usages of the package
612+ /// When include_renamed = true, count all usages of the package
620613 /// Uses package_index for O(1) key lookup instead of O(n) scan.
621614 pub fn package_usage_count ( & self , package_name : & str ) -> usize {
622615 let Some ( dep_keys) = self . package_index . get ( package_name) else {
@@ -637,7 +630,7 @@ impl ManifestAnalyzer {
637630
638631 /// Get all dep keys that refer to a specific package (including renamed)
639632 ///
640- /// Issue #6: Used to find all renamed variants of a package
633+ /// Used to find all renamed variants of a package
641634 /// Uses package_index for O(1) lookup instead of O(n) scan.
642635 pub fn dep_keys_for_package ( & self , package_name : & str ) -> Vec < & DepKey > {
643636 self
@@ -649,7 +642,7 @@ impl ManifestAnalyzer {
649642
650643 /// Get aggregated usage sites for a package (all renamed and non-renamed usages)
651644 ///
652- /// Issue #6: Used when include_renamed = true to merge features across all usages
645+ /// Used when include_renamed = true to merge features across all usages
653646 /// Uses package_index for O(1) key lookup instead of O(n) scan.
654647 pub fn get_package_usage_sites ( & self , package_name : & str ) -> Vec < & DepUsage > {
655648 let Some ( dep_keys) = self . package_index . get ( package_name) else {
@@ -668,7 +661,7 @@ impl ManifestAnalyzer {
668661
669662 /// Compute union of features across all usages of a package (including renamed)
670663 ///
671- /// Issue #6: When include_renamed = true, aggregate features from all variants
664+ /// When include_renamed = true, aggregate features from all variants
672665 pub fn compute_package_union ( & self , package_name : & str ) -> BTreeSet < String > {
673666 let mut union = BTreeSet :: new ( ) ;
674667
@@ -683,7 +676,7 @@ impl ManifestAnalyzer {
683676
684677 /// Check if a package has mixed default-features across all usages (including renamed)
685678 ///
686- /// Issue #6: When include_renamed = true, check across all variants
679+ /// When include_renamed = true, check across all variants
687680 pub fn package_has_mixed_defaults ( & self , package_name : & str ) -> bool {
688681 let usages: Vec < _ > = self
689682 . get_package_usage_sites ( package_name)
@@ -701,7 +694,7 @@ impl ManifestAnalyzer {
701694
702695 /// Get default-features policy across all usages of a package (including renamed)
703696 ///
704- /// Issue #6: When include_renamed = true, use conservative policy across all variants
697+ /// When include_renamed = true, use conservative policy across all variants
705698 pub fn package_default_features_policy ( & self , package_name : & str ) -> Option < bool > {
706699 let usages: Vec < _ > = self
707700 . get_package_usage_sites ( package_name)
@@ -723,15 +716,13 @@ impl ManifestAnalyzer {
723716
724717 /// Get unique package names from all dependencies
725718 ///
726- /// Issue #6: Used to iterate by package rather than by dep key
719+ /// Used to iterate by package rather than by dep key
727720 pub fn unique_packages ( & self ) -> HashSet < Arc < str > > {
728721 self . usage_index . keys ( ) . map ( |k| Arc :: clone ( & k. name ) ) . collect ( )
729722 }
730723}
731724
732- // ============================================================================
733725// Workspace Dependencies Parser
734- // ============================================================================
735726
736727/// Information about an existing workspace dependency
737728#[ derive( Debug , Clone ) ]
@@ -843,9 +834,7 @@ fn parse_workspace_dep_entry(name: &str, value: &Item) -> ExistingWorkspaceDep {
843834 dep
844835}
845836
846- // ============================================================================
847837// Unit Tests
848- // ============================================================================
849838
850839#[ cfg( test) ]
851840mod tests {
0 commit comments