@@ -538,8 +538,8 @@ fn print_lockfile_generation(
538
538
vec ! [ ]
539
539
} ;
540
540
541
- let required_rust_version = report_required_rust_version ( resolve, change) ;
542
- let latest = report_latest ( & possibilities, change) ;
541
+ let required_rust_version = report_required_rust_version ( resolve, change, None ) ;
542
+ let latest = report_latest ( & possibilities, change, None ) ;
543
543
let note = required_rust_version. or ( latest) ;
544
544
545
545
if let Some ( note) = note {
@@ -601,8 +601,8 @@ fn print_lockfile_sync(
601
601
vec ! [ ]
602
602
} ;
603
603
604
- let required_rust_version = report_required_rust_version ( resolve, change) ;
605
- let latest = report_latest ( & possibilities, change) ;
604
+ let required_rust_version = report_required_rust_version ( resolve, change, None ) ;
605
+ let latest = report_latest ( & possibilities, change, None ) ;
606
606
let note = required_rust_version. or ( latest) . unwrap_or_default ( ) ;
607
607
608
608
ws. gctx ( ) . shell ( ) . status_with_color (
@@ -654,8 +654,8 @@ fn print_lockfile_updates(
654
654
PackageChangeKind :: Added
655
655
| PackageChangeKind :: Upgraded
656
656
| PackageChangeKind :: Downgraded => {
657
- let required_rust_version = report_required_rust_version ( resolve, change) ;
658
- let latest = report_latest ( & possibilities, change) ;
657
+ let required_rust_version = report_required_rust_version ( resolve, change, None ) ;
658
+ let latest = report_latest ( & possibilities, change, None ) ;
659
659
let note = required_rust_version. or ( latest) . unwrap_or_default ( ) ;
660
660
661
661
ws. gctx ( ) . shell ( ) . status_with_color (
@@ -672,14 +672,16 @@ fn print_lockfile_updates(
672
672
) ?;
673
673
}
674
674
PackageChangeKind :: Unchanged => {
675
- let required_rust_version = report_required_rust_version ( resolve, change) ;
676
- let latest = report_latest ( & possibilities, change) ;
675
+ let mut unchanged_stats = UpdateStats :: default ( ) ;
676
+ let required_rust_version =
677
+ report_required_rust_version ( resolve, change, Some ( & mut unchanged_stats) ) ;
678
+ let latest = report_latest ( & possibilities, change, Some ( & mut unchanged_stats) ) ;
677
679
let note = required_rust_version. as_deref ( ) . or ( latest. as_deref ( ) ) ;
678
680
681
+ if unchanged_stats. behind ( ) {
682
+ unchanged_behind += 1 ;
683
+ }
679
684
if let Some ( note) = note {
680
- if latest. is_some ( ) {
681
- unchanged_behind += 1 ;
682
- }
683
685
if ws. gctx ( ) . shell ( ) . verbosity ( ) == Verbosity :: Verbose {
684
686
ws. gctx ( ) . shell ( ) . status_with_color (
685
687
change. kind . status ( ) ,
@@ -748,7 +750,11 @@ fn required_rust_version(ws: &Workspace<'_>) -> Option<PartialVersion> {
748
750
}
749
751
}
750
752
751
- fn report_required_rust_version ( resolve : & Resolve , change : & PackageChange ) -> Option < String > {
753
+ fn report_required_rust_version (
754
+ resolve : & Resolve ,
755
+ change : & PackageChange ,
756
+ stats : Option < & mut UpdateStats > ,
757
+ ) -> Option < String > {
752
758
if change. package_id . source_id ( ) . is_path ( ) {
753
759
return None ;
754
760
}
@@ -759,13 +765,20 @@ fn report_required_rust_version(resolve: &Resolve, change: &PackageChange) -> Op
759
765
return None ;
760
766
}
761
767
768
+ if let Some ( stats) = stats {
769
+ stats. required_rust_version += 1 ;
770
+ }
762
771
let error = style:: ERROR ;
763
772
Some ( format ! (
764
773
" {error}(requires Rust {package_rust_version}){error:#}"
765
774
) )
766
775
}
767
776
768
- fn report_latest ( possibilities : & [ IndexSummary ] , change : & PackageChange ) -> Option < String > {
777
+ fn report_latest (
778
+ possibilities : & [ IndexSummary ] ,
779
+ change : & PackageChange ,
780
+ mut stats : Option < & mut UpdateStats > ,
781
+ ) -> Option < String > {
769
782
let package_id = change. package_id ;
770
783
if !package_id. source_id ( ) . is_registry ( ) {
771
784
return None ;
@@ -788,6 +801,11 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
788
801
} )
789
802
. filter ( |s| package_id. version ( ) != s. version ( ) && version_req. matches ( s. version ( ) ) )
790
803
. max_by_key ( |s| s. version ( ) ) ;
804
+ if let Some ( ref mut stats) = stats {
805
+ if compat_ver_compat_msrv_summary. is_some ( ) {
806
+ stats. compat_ver_compat_msrv += 1 ;
807
+ }
808
+ }
791
809
792
810
let incompat_ver_compat_msrv_summary = if !change. is_transitive . unwrap_or ( true ) {
793
811
possibilities
@@ -807,12 +825,22 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
807
825
} else {
808
826
None
809
827
} ;
828
+ if let Some ( stats) = stats. as_mut ( ) {
829
+ if incompat_ver_compat_msrv_summary. is_some ( ) {
830
+ stats. incompat_ver_compat_msrv += 1 ;
831
+ }
832
+ }
810
833
811
834
let compat_ver_summary = possibilities
812
835
. iter ( )
813
836
. map ( |s| s. as_summary ( ) )
814
837
. filter ( |s| package_id. version ( ) != s. version ( ) && version_req. matches ( s. version ( ) ) )
815
838
. max_by_key ( |s| s. version ( ) ) ;
839
+ if let Some ( stats) = stats. as_mut ( ) {
840
+ if compat_ver_summary. is_some ( ) {
841
+ stats. compat_ver += 1 ;
842
+ }
843
+ }
816
844
817
845
let incompat_ver_summary = if !change. is_transitive . unwrap_or ( true ) {
818
846
possibilities
@@ -823,6 +851,11 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
823
851
} else {
824
852
None
825
853
} ;
854
+ if let Some ( stats) = stats. as_mut ( ) {
855
+ if incompat_ver_summary. is_some ( ) {
856
+ stats. incompat_ver += 1 ;
857
+ }
858
+ }
826
859
827
860
if let Some ( summary) = compat_ver_compat_msrv_summary {
828
861
let warn = style:: WARN ;
@@ -857,6 +890,25 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
857
890
}
858
891
}
859
892
893
+ #[ derive( Default ) ]
894
+ struct UpdateStats {
895
+ required_rust_version : usize ,
896
+ compat_ver_compat_msrv : usize ,
897
+ incompat_ver_compat_msrv : usize ,
898
+ compat_ver : usize ,
899
+ incompat_ver : usize ,
900
+ }
901
+
902
+ impl UpdateStats {
903
+ fn behind ( & self ) -> bool {
904
+ self . compat_ver_compat_msrv
905
+ + self . incompat_ver_compat_msrv
906
+ + self . compat_ver
907
+ + self . incompat_ver
908
+ != 0
909
+ }
910
+ }
911
+
860
912
fn is_latest ( candidate : & semver:: Version , current : & semver:: Version ) -> bool {
861
913
current < candidate
862
914
// Only match pre-release if major.minor.patch are the same
0 commit comments