@@ -255,11 +255,7 @@ crate struct CrateLocator<'a> {
255
255
pub is_proc_macro : bool ,
256
256
257
257
// Mutable in-progress state or output.
258
- rejected_via_hash : Vec < CrateMismatch > ,
259
- rejected_via_triple : Vec < CrateMismatch > ,
260
- rejected_via_kind : Vec < CrateMismatch > ,
261
- rejected_via_version : Vec < CrateMismatch > ,
262
- rejected_via_filename : Vec < CrateMismatch > ,
258
+ crate_rejections : CrateRejections ,
263
259
}
264
260
265
261
#[ derive( Clone ) ]
@@ -343,20 +339,16 @@ impl<'a> CrateLocator<'a> {
343
339
sess. target_filesearch ( path_kind)
344
340
} ,
345
341
is_proc_macro : false ,
346
- rejected_via_hash : Vec :: new ( ) ,
347
- rejected_via_triple : Vec :: new ( ) ,
348
- rejected_via_kind : Vec :: new ( ) ,
349
- rejected_via_version : Vec :: new ( ) ,
350
- rejected_via_filename : Vec :: new ( ) ,
342
+ crate_rejections : CrateRejections :: default ( ) ,
351
343
}
352
344
}
353
345
354
346
crate fn reset ( & mut self ) {
355
- self . rejected_via_hash . clear ( ) ;
356
- self . rejected_via_triple . clear ( ) ;
357
- self . rejected_via_kind . clear ( ) ;
358
- self . rejected_via_version . clear ( ) ;
359
- self . rejected_via_filename . clear ( ) ;
347
+ self . crate_rejections . via_hash . clear ( ) ;
348
+ self . crate_rejections . via_triple . clear ( ) ;
349
+ self . crate_rejections . via_kind . clear ( ) ;
350
+ self . crate_rejections . via_version . clear ( ) ;
351
+ self . crate_rejections . via_filename . clear ( ) ;
360
352
}
361
353
362
354
crate fn maybe_load_library_crate ( & mut self ) -> Result < Option < Library > , CrateError > {
@@ -439,7 +431,7 @@ impl<'a> CrateLocator<'a> {
439
431
} ;
440
432
FileMatches
441
433
} ) ;
442
- self . rejected_via_kind . extend ( staticlibs) ;
434
+ self . crate_rejections . via_kind . extend ( staticlibs) ;
443
435
444
436
// We have now collected all known libraries into a set of candidates
445
437
// keyed of the filename hash listed. For each filename, we also have a
@@ -610,7 +602,8 @@ impl<'a> CrateLocator<'a> {
610
602
let found_version = metadata. get_rustc_version ( ) ;
611
603
if found_version != rustc_version {
612
604
info ! ( "Rejecting via version: expected {} got {}" , rustc_version, found_version) ;
613
- self . rejected_via_version
605
+ self . crate_rejections
606
+ . via_version
614
607
. push ( CrateMismatch { path : libpath. to_path_buf ( ) , got : found_version } ) ;
615
608
return None ;
616
609
}
@@ -632,7 +625,7 @@ impl<'a> CrateLocator<'a> {
632
625
633
626
if root. triple ( ) != & self . triple {
634
627
info ! ( "Rejecting via crate triple: expected {} got {}" , self . triple, root. triple( ) ) ;
635
- self . rejected_via_triple . push ( CrateMismatch {
628
+ self . crate_rejections . via_triple . push ( CrateMismatch {
636
629
path : libpath. to_path_buf ( ) ,
637
630
got : root. triple ( ) . to_string ( ) ,
638
631
} ) ;
@@ -643,7 +636,8 @@ impl<'a> CrateLocator<'a> {
643
636
if let Some ( expected_hash) = self . hash {
644
637
if hash != expected_hash {
645
638
info ! ( "Rejecting via hash: expected {} got {}" , expected_hash, hash) ;
646
- self . rejected_via_hash
639
+ self . crate_rejections
640
+ . via_hash
647
641
. push ( CrateMismatch { path : libpath. to_path_buf ( ) , got : hash. to_string ( ) } ) ;
648
642
return None ;
649
643
}
@@ -697,7 +691,8 @@ impl<'a> CrateLocator<'a> {
697
691
dylibs. insert ( loc_canon, PathKind :: ExternFlag ) ;
698
692
}
699
693
} else {
700
- self . rejected_via_filename
694
+ self . crate_rejections
695
+ . via_filename
701
696
. push ( CrateMismatch { path : loc. original ( ) . clone ( ) , got : String :: new ( ) } ) ;
702
697
}
703
698
}
@@ -713,11 +708,7 @@ impl<'a> CrateLocator<'a> {
713
708
triple : self . triple ,
714
709
dll_prefix : self . target . dll_prefix . clone ( ) ,
715
710
dll_suffix : self . target . dll_suffix . clone ( ) ,
716
- rejected_via_hash : self . rejected_via_hash ,
717
- rejected_via_triple : self . rejected_via_triple ,
718
- rejected_via_kind : self . rejected_via_kind ,
719
- rejected_via_version : self . rejected_via_version ,
720
- rejected_via_filename : self . rejected_via_filename ,
711
+ crate_rejections : self . crate_rejections ,
721
712
} )
722
713
}
723
714
}
@@ -844,6 +835,15 @@ struct CrateMismatch {
844
835
got : String ,
845
836
}
846
837
838
+ #[ derive( Clone , Default ) ]
839
+ struct CrateRejections {
840
+ via_hash : Vec < CrateMismatch > ,
841
+ via_triple : Vec < CrateMismatch > ,
842
+ via_kind : Vec < CrateMismatch > ,
843
+ via_version : Vec < CrateMismatch > ,
844
+ via_filename : Vec < CrateMismatch > ,
845
+ }
846
+
847
847
/// Candidate rejection reasons collected during crate search.
848
848
/// If no candidate is accepted, then these reasons are presented to the user,
849
849
/// otherwise they are ignored.
@@ -853,11 +853,7 @@ crate struct CombinedLocatorError {
853
853
triple : TargetTriple ,
854
854
dll_prefix : String ,
855
855
dll_suffix : String ,
856
- rejected_via_hash : Vec < CrateMismatch > ,
857
- rejected_via_triple : Vec < CrateMismatch > ,
858
- rejected_via_kind : Vec < CrateMismatch > ,
859
- rejected_via_version : Vec < CrateMismatch > ,
860
- rejected_via_filename : Vec < CrateMismatch > ,
856
+ crate_rejections : CrateRejections ,
861
857
}
862
858
863
859
crate enum CrateError {
@@ -966,7 +962,7 @@ impl CrateError {
966
962
Some ( r) => format ! ( " which `{}` depends on" , r. name) ,
967
963
} ;
968
964
let mut msg = "the following crate versions were found:" . to_string ( ) ;
969
- let mut err = if !locator. rejected_via_hash . is_empty ( ) {
965
+ let mut err = if !locator. crate_rejections . via_hash . is_empty ( ) {
970
966
let mut err = struct_span_err ! (
971
967
sess,
972
968
span,
@@ -976,7 +972,7 @@ impl CrateError {
976
972
add,
977
973
) ;
978
974
err. note ( "perhaps that crate needs to be recompiled?" ) ;
979
- let mismatches = locator. rejected_via_hash . iter ( ) ;
975
+ let mismatches = locator. crate_rejections . via_hash . iter ( ) ;
980
976
for CrateMismatch { path, .. } in mismatches {
981
977
msg. push_str ( & format ! ( "\n crate `{}`: {}" , crate_name, path. display( ) ) ) ;
982
978
}
@@ -987,7 +983,7 @@ impl CrateError {
987
983
}
988
984
err. note ( & msg) ;
989
985
err
990
- } else if !locator. rejected_via_triple . is_empty ( ) {
986
+ } else if !locator. crate_rejections . via_triple . is_empty ( ) {
991
987
let mut err = struct_span_err ! (
992
988
sess,
993
989
span,
@@ -997,7 +993,7 @@ impl CrateError {
997
993
locator. triple,
998
994
add,
999
995
) ;
1000
- let mismatches = locator. rejected_via_triple . iter ( ) ;
996
+ let mismatches = locator. crate_rejections . via_triple . iter ( ) ;
1001
997
for CrateMismatch { path, got } in mismatches {
1002
998
msg. push_str ( & format ! (
1003
999
"\n crate `{}`, target triple {}: {}" ,
@@ -1008,7 +1004,7 @@ impl CrateError {
1008
1004
}
1009
1005
err. note ( & msg) ;
1010
1006
err
1011
- } else if !locator. rejected_via_kind . is_empty ( ) {
1007
+ } else if !locator. crate_rejections . via_kind . is_empty ( ) {
1012
1008
let mut err = struct_span_err ! (
1013
1009
sess,
1014
1010
span,
@@ -1018,13 +1014,13 @@ impl CrateError {
1018
1014
add,
1019
1015
) ;
1020
1016
err. help ( "please recompile that crate using --crate-type lib" ) ;
1021
- let mismatches = locator. rejected_via_kind . iter ( ) ;
1017
+ let mismatches = locator. crate_rejections . via_kind . iter ( ) ;
1022
1018
for CrateMismatch { path, .. } in mismatches {
1023
1019
msg. push_str ( & format ! ( "\n crate `{}`: {}" , crate_name, path. display( ) ) ) ;
1024
1020
}
1025
1021
err. note ( & msg) ;
1026
1022
err
1027
- } else if !locator. rejected_via_version . is_empty ( ) {
1023
+ } else if !locator. crate_rejections . via_version . is_empty ( ) {
1028
1024
let mut err = struct_span_err ! (
1029
1025
sess,
1030
1026
span,
@@ -1037,7 +1033,7 @@ impl CrateError {
1037
1033
"please recompile that crate using this compiler ({})" ,
1038
1034
rustc_version( ) ,
1039
1035
) ) ;
1040
- let mismatches = locator. rejected_via_version . iter ( ) ;
1036
+ let mismatches = locator. crate_rejections . via_version . iter ( ) ;
1041
1037
for CrateMismatch { path, got } in mismatches {
1042
1038
msg. push_str ( & format ! (
1043
1039
"\n crate `{}` compiled by {}: {}" ,
@@ -1104,8 +1100,8 @@ impl CrateError {
1104
1100
err
1105
1101
} ;
1106
1102
1107
- if !locator. rejected_via_filename . is_empty ( ) {
1108
- let mismatches = locator. rejected_via_filename . iter ( ) ;
1103
+ if !locator. crate_rejections . via_filename . is_empty ( ) {
1104
+ let mismatches = locator. crate_rejections . via_filename . iter ( ) ;
1109
1105
for CrateMismatch { path, .. } in mismatches {
1110
1106
err. note ( & format ! (
1111
1107
"extern location for {} is of an unknown type: {}" ,
0 commit comments