@@ -399,14 +399,15 @@ pub fn prepare_target(cx: &mut Context<'_, '_>, unit: &Unit, force: bool) -> Car
399
399
}
400
400
401
401
let dirty_reason = match compare {
402
- Ok ( _ ) => {
402
+ Ok ( None ) => {
403
403
if force {
404
404
Some ( DirtyReason :: Forced )
405
405
} else {
406
406
return Ok ( Job :: new_fresh ( ) ) ;
407
407
}
408
408
}
409
- Err ( e) => e. downcast :: < DirtyReason > ( ) . ok ( ) ,
409
+ Ok ( reason) => reason,
410
+ Err ( _) => None ,
410
411
} ;
411
412
412
413
// Clear out the old fingerprint file if it exists. This protects when
@@ -853,64 +854,64 @@ impl Fingerprint {
853
854
/// The purpose of this is exclusively to produce a diagnostic message
854
855
/// indicating why we're recompiling something. This function always returns
855
856
/// an error, it will never return success.
856
- fn compare ( & self , old : & Fingerprint ) -> Result < ( ) , DirtyReason > {
857
+ fn compare ( & self , old : & Fingerprint ) -> DirtyReason {
857
858
if self . rustc != old. rustc {
858
- Err ( DirtyReason :: RustcChanged ) ?
859
+ return DirtyReason :: RustcChanged
859
860
}
860
861
if self . features != old. features {
861
- Err ( DirtyReason :: FeaturesChanged {
862
+ return DirtyReason :: FeaturesChanged {
862
863
old : old. features . clone ( ) ,
863
864
new : self . features . clone ( ) ,
864
- } ) ?
865
+ }
865
866
}
866
867
if self . target != old. target {
867
- Err ( DirtyReason :: TargetConfigurationChanged ) ?
868
+ return DirtyReason :: TargetConfigurationChanged ;
868
869
}
869
870
if self . path != old. path {
870
- Err ( DirtyReason :: PathToSourceChanged ) ?
871
+ return DirtyReason :: PathToSourceChanged ;
871
872
}
872
873
if self . profile != old. profile {
873
- Err ( DirtyReason :: ProfileConfigurationChanged ) ?
874
+ return DirtyReason :: ProfileConfigurationChanged ;
874
875
}
875
876
if self . rustflags != old. rustflags {
876
- Err ( DirtyReason :: RustflagsChanged {
877
+ return DirtyReason :: RustflagsChanged {
877
878
old : old. rustflags . clone ( ) ,
878
879
new : self . rustflags . clone ( ) ,
879
- } ) ?
880
+ } ;
880
881
}
881
882
if self . metadata != old. metadata {
882
- Err ( DirtyReason :: MetadataChanged ) ?
883
+ return DirtyReason :: MetadataChanged ;
883
884
}
884
885
if self . config != old. config {
885
- Err ( DirtyReason :: ConfigSettingsChanged ) ?
886
+ return DirtyReason :: ConfigSettingsChanged ;
886
887
}
887
888
if self . compile_kind != old. compile_kind {
888
- Err ( DirtyReason :: CompileKindChanged ) ?
889
+ return DirtyReason :: CompileKindChanged ;
889
890
}
890
891
let my_local = self . local . lock ( ) . unwrap ( ) ;
891
892
let old_local = old. local . lock ( ) . unwrap ( ) ;
892
893
if my_local. len ( ) != old_local. len ( ) {
893
- Err ( DirtyReason :: LocalLengthsChanged ) ?
894
+ return DirtyReason :: LocalLengthsChanged ;
894
895
}
895
896
for ( new, old) in my_local. iter ( ) . zip ( old_local. iter ( ) ) {
896
897
match ( new, old) {
897
898
( LocalFingerprint :: Precalculated ( a) , LocalFingerprint :: Precalculated ( b) ) => {
898
899
if a != b {
899
- Err ( DirtyReason :: PrecalculatedComponentsChanged {
900
+ return DirtyReason :: PrecalculatedComponentsChanged {
900
901
old : b. to_string ( ) ,
901
902
new : a. to_string ( ) ,
902
- } ) ?
903
+ } ;
903
904
}
904
905
}
905
906
(
906
907
LocalFingerprint :: CheckDepInfo { dep_info : adep } ,
907
908
LocalFingerprint :: CheckDepInfo { dep_info : bdep } ,
908
909
) => {
909
910
if adep != bdep {
910
- Err ( DirtyReason :: DepInfoOutputChanged {
911
+ return DirtyReason :: DepInfoOutputChanged {
911
912
old : bdep. clone ( ) ,
912
913
new : adep. clone ( ) ,
913
- } ) ?
914
+ } ;
914
915
}
915
916
}
916
917
(
@@ -924,16 +925,16 @@ impl Fingerprint {
924
925
} ,
925
926
) => {
926
927
if aout != bout {
927
- Err ( DirtyReason :: RerunIfChangedOutputFileChanged {
928
+ return DirtyReason :: RerunIfChangedOutputFileChanged {
928
929
old : bout. clone ( ) ,
929
930
new : aout. clone ( ) ,
930
- } ) ?
931
+ } ;
931
932
}
932
933
if apaths != bpaths {
933
- Err ( DirtyReason :: RerunIfChangedOutputPathsChanged {
934
+ return DirtyReason :: RerunIfChangedOutputPathsChanged {
934
935
old : bpaths. clone ( ) ,
935
936
new : apaths. clone ( ) ,
936
- } ) ?
937
+ } ;
937
938
}
938
939
}
939
940
(
@@ -947,59 +948,59 @@ impl Fingerprint {
947
948
} ,
948
949
) => {
949
950
if * akey != * bkey {
950
- Err ( DirtyReason :: EnvVarsChanged {
951
+ return DirtyReason :: EnvVarsChanged {
951
952
old : bkey. clone ( ) ,
952
953
new : akey. clone ( ) ,
953
- } ) ?
954
+ } ;
954
955
}
955
956
if * avalue != * bvalue {
956
- Err ( DirtyReason :: EnvVarChanged {
957
+ return DirtyReason :: EnvVarChanged {
957
958
name : akey. clone ( ) ,
958
959
old_value : bvalue. clone ( ) ,
959
960
new_value : avalue. clone ( ) ,
960
- } ) ?
961
+ } ;
961
962
}
962
963
}
963
- ( a, b) => Err ( DirtyReason :: LocalFingerprintTypeChanged {
964
+ ( a, b) => return DirtyReason :: LocalFingerprintTypeChanged {
964
965
old : b. kind ( ) ,
965
966
new : a. kind ( ) ,
966
- } ) ? ,
967
+ } ,
967
968
}
968
969
}
969
970
970
971
if self . deps . len ( ) != old. deps . len ( ) {
971
- Err ( DirtyReason :: NumberOfDependenciesChanged {
972
+ return DirtyReason :: NumberOfDependenciesChanged {
972
973
old : old. deps . len ( ) ,
973
974
new : self . deps . len ( ) ,
974
- } ) ?
975
+ } ;
975
976
}
976
977
for ( a, b) in self . deps . iter ( ) . zip ( old. deps . iter ( ) ) {
977
978
if a. name != b. name {
978
- Err ( DirtyReason :: UnitDependencyNameChanged {
979
+ return DirtyReason :: UnitDependencyNameChanged {
979
980
old : b. name . clone ( ) ,
980
981
new : a. name . clone ( ) ,
981
- } ) ?
982
+ } ;
982
983
}
983
984
984
985
if a. fingerprint . hash_u64 ( ) != b. fingerprint . hash_u64 ( ) {
985
- Err ( DirtyReason :: UnitDependencyInfoChanged {
986
+ return DirtyReason :: UnitDependencyInfoChanged {
986
987
new_name : a. name . clone ( ) ,
987
988
new_fingerprint : a. fingerprint . hash_u64 ( ) ,
988
989
old_name : b. name . clone ( ) ,
989
990
old_fingerprint : b. fingerprint . hash_u64 ( ) ,
990
- } ) ?
991
+ } ;
991
992
}
992
993
}
993
994
994
995
if !self . fs_status . up_to_date ( ) {
995
- Err ( DirtyReason :: FsStatusOutdated ( self . fs_status . clone ( ) ) ) ?
996
+ return DirtyReason :: FsStatusOutdated ( self . fs_status . clone ( ) ) ;
996
997
}
997
998
998
999
// This typically means some filesystem modifications happened or
999
1000
// something transitive was odd. In general we should strive to provide
1000
1001
// a better error message than this, so if you see this message a lot it
1001
1002
// likely means this method needs to be updated!
1002
- Err ( DirtyReason :: NothingObvious )
1003
+ DirtyReason :: NothingObvious
1003
1004
}
1004
1005
1005
1006
/// Dynamically inspect the local filesystem to update the `fs_status` field
@@ -1667,7 +1668,7 @@ fn compare_old_fingerprint(
1667
1668
loc : & Path ,
1668
1669
new_fingerprint : & Fingerprint ,
1669
1670
mtime_on_use : bool ,
1670
- ) -> CargoResult < ( ) > {
1671
+ ) -> CargoResult < Option < DirtyReason > > {
1671
1672
let old_fingerprint_short = paths:: read ( loc) ?;
1672
1673
1673
1674
if mtime_on_use {
@@ -1680,7 +1681,7 @@ fn compare_old_fingerprint(
1680
1681
let new_hash = new_fingerprint. hash_u64 ( ) ;
1681
1682
1682
1683
if util:: to_hex ( new_hash) == old_fingerprint_short && new_fingerprint. fs_status . up_to_date ( ) {
1683
- return Ok ( ( ) ) ;
1684
+ return Ok ( None ) ;
1684
1685
}
1685
1686
1686
1687
let old_fingerprint_json = paths:: read ( & loc. with_extension ( "json" ) ) ?;
@@ -1693,23 +1694,28 @@ fn compare_old_fingerprint(
1693
1694
old_fingerprint_short
1694
1695
) ;
1695
1696
}
1696
- let result = new_fingerprint. compare ( & old_fingerprint) ;
1697
- match result {
1698
- Ok ( _) => panic ! ( "compare should not return Ok" ) ,
1699
- Err ( e) => Err ( e. into ( ) ) ,
1700
- }
1697
+
1698
+ Ok ( Some ( new_fingerprint. compare ( & old_fingerprint) ) )
1701
1699
}
1702
1700
1703
- fn log_compare ( unit : & Unit , compare : & CargoResult < ( ) > ) {
1704
- let ce = match compare {
1705
- Ok ( ..) => return ,
1706
- Err ( e) => e,
1707
- } ;
1708
- info ! (
1709
- "fingerprint error for {}/{:?}/{:?}" ,
1710
- unit. pkg, unit. mode, unit. target,
1711
- ) ;
1712
- info ! ( " err: {:?}" , ce) ;
1701
+ fn log_compare ( unit : & Unit , compare : & CargoResult < Option < DirtyReason > > ) {
1702
+ match compare {
1703
+ Ok ( None ) => { } ,
1704
+ Ok ( Some ( reason) ) => {
1705
+ info ! (
1706
+ "fingerprint dirty for {}/{:?}/{:?}" ,
1707
+ unit. pkg, unit. mode, unit. target,
1708
+ ) ;
1709
+ info ! ( " dirty: {reason:?}" ) ;
1710
+ } ,
1711
+ Err ( e) => {
1712
+ info ! (
1713
+ "fingerprint error for {}/{:?}/{:?}" ,
1714
+ unit. pkg, unit. mode, unit. target,
1715
+ ) ;
1716
+ info ! ( " err: {e:?}" ) ;
1717
+ } ,
1718
+ }
1713
1719
}
1714
1720
1715
1721
/// Parses Cargo's internal `EncodedDepInfo` structure that was previously
0 commit comments