@@ -792,7 +792,7 @@ impl ValidationContext {
792
792
}
793
793
}
794
794
795
- fn validate_elf < ' data , Elf : FileHeader < Endian = Endianness > > (
795
+ fn validate_elf < Elf : FileHeader < Endian = Endianness > > (
796
796
context : & mut ValidationContext ,
797
797
json : & PythonJsonMain ,
798
798
target_triple : & str ,
@@ -985,20 +985,18 @@ fn validate_elf<'data, Elf: FileHeader<Endian = Endianness>>(
985
985
if let Some ( version) = version_version {
986
986
let parts: Vec < & str > = version. splitn ( 2 , '_' ) . collect ( ) ;
987
987
988
- if parts. len ( ) == 2 {
989
- if parts[ 0 ] == "GLIBC" {
990
- let v = version_compare:: Version :: from ( parts[ 1 ] )
991
- . expect ( "unable to parse version" ) ;
988
+ if parts. len ( ) == 2 && parts[ 0 ] == "GLIBC" {
989
+ let v = version_compare:: Version :: from ( parts[ 1 ] )
990
+ . expect ( "unable to parse version" ) ;
992
991
993
- if & v > wanted_glibc_max_version {
994
- context. errors . push ( format ! (
995
- "{} references too new glibc symbol {:?} ({} > {})" ,
996
- path. display( ) ,
997
- name,
998
- v,
999
- wanted_glibc_max_version,
1000
- ) ) ;
1001
- }
992
+ if & v > wanted_glibc_max_version {
993
+ context. errors . push ( format ! (
994
+ "{} references too new glibc symbol {:?} ({} > {})" ,
995
+ path. display( ) ,
996
+ name,
997
+ v,
998
+ wanted_glibc_max_version,
999
+ ) ) ;
1002
1000
}
1003
1001
}
1004
1002
}
@@ -1026,12 +1024,12 @@ fn validate_elf<'data, Elf: FileHeader<Endian = Endianness>>(
1026
1024
if let Some ( filename) = path. file_name ( ) {
1027
1025
let filename = filename. to_string_lossy ( ) ;
1028
1026
1029
- if filename. starts_with ( "libpython" ) && filename . ends_with ( ".so.1.0" ) {
1030
- if matches ! ( symbol . st_bind ( ) , STB_GLOBAL | STB_WEAK )
1031
- && symbol. st_visibility ( ) == STV_DEFAULT
1032
- {
1033
- context . libpython_exported_symbols . insert ( name . to_string ( ) ) ;
1034
- }
1027
+ if filename. starts_with ( "libpython" )
1028
+ && filename . ends_with ( ".so.1.0" )
1029
+ && matches ! ( symbol. st_bind ( ) , STB_GLOBAL | STB_WEAK )
1030
+ && symbol . st_visibility ( ) == STV_DEFAULT
1031
+ {
1032
+ context . libpython_exported_symbols . insert ( name . to_string ( ) ) ;
1035
1033
}
1036
1034
}
1037
1035
}
@@ -1058,6 +1056,7 @@ fn parse_version_nibbles(v: u32) -> semver::Version {
1058
1056
semver:: Version :: new ( major as _ , minor as _ , patch as _ )
1059
1057
}
1060
1058
1059
+ #[ allow( clippy:: too_many_arguments) ]
1061
1060
fn validate_macho < Mach : MachHeader < Endian = Endianness > > (
1062
1061
context : & mut ValidationContext ,
1063
1062
target_triple : & str ,
@@ -1125,7 +1124,7 @@ fn validate_macho<Mach: MachHeader<Endian = Endianness>>(
1125
1124
target_version = Some ( parse_version_nibbles ( v. version . get ( endian) ) ) ;
1126
1125
}
1127
1126
LoadCommandVariant :: Dylib ( command) => {
1128
- let raw_string = load_command. string ( endian, command. dylib . name . clone ( ) ) ?;
1127
+ let raw_string = load_command. string ( endian, command. dylib . name ) ?;
1129
1128
let lib = String :: from_utf8 ( raw_string. to_vec ( ) ) ?;
1130
1129
1131
1130
dylib_names. push ( lib. clone ( ) ) ;
@@ -1336,9 +1335,9 @@ fn validate_possible_object_file(
1336
1335
json,
1337
1336
triple,
1338
1337
python_major_minor,
1339
- path. as_ref ( ) ,
1338
+ path,
1340
1339
header,
1341
- & data,
1340
+ data,
1342
1341
) ?;
1343
1342
}
1344
1343
FileKind :: Elf64 => {
@@ -1349,9 +1348,9 @@ fn validate_possible_object_file(
1349
1348
json,
1350
1349
triple,
1351
1350
python_major_minor,
1352
- path. as_ref ( ) ,
1351
+ path,
1353
1352
header,
1354
- & data,
1353
+ data,
1355
1354
) ?;
1356
1355
}
1357
1356
FileKind :: MachO32 => {
@@ -1367,9 +1366,9 @@ fn validate_possible_object_file(
1367
1366
json. apple_sdk_version
1368
1367
. as_ref ( )
1369
1368
. expect ( "apple_sdk_version should be set" ) ,
1370
- path. as_ref ( ) ,
1369
+ path,
1371
1370
header,
1372
- & data,
1371
+ data,
1373
1372
) ?;
1374
1373
}
1375
1374
FileKind :: MachO64 => {
@@ -1385,9 +1384,9 @@ fn validate_possible_object_file(
1385
1384
json. apple_sdk_version
1386
1385
. as_ref ( )
1387
1386
. expect ( "apple_sdk_version should be set" ) ,
1388
- path. as_ref ( ) ,
1387
+ path,
1389
1388
header,
1390
- & data,
1389
+ data,
1391
1390
) ?;
1392
1391
}
1393
1392
FileKind :: MachOFat32 | FileKind :: MachOFat64 => {
@@ -1399,11 +1398,11 @@ fn validate_possible_object_file(
1399
1398
}
1400
1399
FileKind :: Pe32 => {
1401
1400
let file = PeFile32 :: parse ( data) ?;
1402
- validate_pe ( & mut context, path. as_ref ( ) , & file) ?;
1401
+ validate_pe ( & mut context, path, & file) ?;
1403
1402
}
1404
1403
FileKind :: Pe64 => {
1405
1404
let file = PeFile64 :: parse ( data) ?;
1406
- validate_pe ( & mut context, path. as_ref ( ) , & file) ?;
1405
+ validate_pe ( & mut context, path, & file) ?;
1407
1406
}
1408
1407
_ => { }
1409
1408
}
@@ -1431,7 +1430,7 @@ fn validate_extension_modules(
1431
1430
return Ok ( errors) ;
1432
1431
}
1433
1432
1434
- let mut wanted = BTreeSet :: from_iter ( GLOBAL_EXTENSIONS . iter ( ) . map ( |x| * x ) ) ;
1433
+ let mut wanted = BTreeSet :: from_iter ( GLOBAL_EXTENSIONS . iter ( ) . copied ( ) ) ;
1435
1434
1436
1435
match python_major_minor {
1437
1436
"3.8" => {
@@ -1576,15 +1575,12 @@ fn validate_json(json: &PythonJsonMain, triple: &str, is_debug: bool) -> Result<
1576
1575
. map ( |x| x. as_str ( ) )
1577
1576
. collect :: < BTreeSet < _ > > ( ) ;
1578
1577
1579
- errors. extend (
1580
- validate_extension_modules (
1581
- & json. python_major_minor_version ,
1582
- triple,
1583
- json. crt_features . contains ( & "static" . to_string ( ) ) ,
1584
- & have_extensions,
1585
- ) ?
1586
- . into_iter ( ) ,
1587
- ) ;
1578
+ errors. extend ( validate_extension_modules (
1579
+ & json. python_major_minor_version ,
1580
+ triple,
1581
+ json. crt_features . contains ( & "static" . to_string ( ) ) ,
1582
+ & have_extensions,
1583
+ ) ?) ;
1588
1584
1589
1585
Ok ( errors)
1590
1586
}
@@ -1635,7 +1631,7 @@ fn validate_distribution(
1635
1631
1636
1632
let is_static = triple. contains ( "unknown-linux-musl" ) ;
1637
1633
1638
- let mut tf = crate :: open_distribution_archive ( & dist_path) ?;
1634
+ let mut tf = crate :: open_distribution_archive ( dist_path) ?;
1639
1635
1640
1636
// First entry in archive should be python/PYTHON.json.
1641
1637
let mut entries = tf. entries ( ) ?;
@@ -1701,7 +1697,7 @@ fn validate_distribution(
1701
1697
context. merge ( validate_possible_object_file (
1702
1698
json. as_ref ( ) . unwrap ( ) ,
1703
1699
python_major_minor,
1704
- & triple,
1700
+ triple,
1705
1701
& path,
1706
1702
& data,
1707
1703
) ?) ;
@@ -1726,9 +1722,9 @@ fn validate_distribution(
1726
1722
context. merge ( validate_possible_object_file (
1727
1723
json. as_ref ( ) . unwrap ( ) ,
1728
1724
python_major_minor,
1729
- & triple,
1725
+ triple,
1730
1726
& member_path,
1731
- & member_data,
1727
+ member_data,
1732
1728
) ?) ;
1733
1729
}
1734
1730
}
@@ -1841,9 +1837,7 @@ fn validate_distribution(
1841
1837
1842
1838
// Ensure that some well known Python symbols are being exported from libpython.
1843
1839
for symbol in PYTHON_EXPORTED_SYMBOLS {
1844
- let exported = context
1845
- . libpython_exported_symbols
1846
- . contains ( & symbol. to_string ( ) ) ;
1840
+ let exported = context. libpython_exported_symbols . contains ( * symbol) ;
1847
1841
let wanted = !is_static;
1848
1842
1849
1843
if exported != wanted {
@@ -1867,6 +1861,7 @@ fn validate_distribution(
1867
1861
}
1868
1862
}
1869
1863
1864
+ #[ allow( clippy:: if_same_then_else) ]
1870
1865
// Static builds never have shared library extension modules.
1871
1866
let want_shared = if is_static {
1872
1867
false
@@ -1904,6 +1899,7 @@ fn validate_distribution(
1904
1899
1905
1900
let exported = context. libpython_exported_symbols . contains ( & ext. init_fn ) ;
1906
1901
1902
+ #[ allow( clippy:: needless_bool, clippy:: if_same_then_else) ]
1907
1903
// Static distributions never export symbols.
1908
1904
let wanted = if is_static {
1909
1905
false
@@ -1996,7 +1992,7 @@ fn verify_distribution_behavior(dist_path: &Path) -> Result<Vec<String>> {
1996
1992
tf. unpack ( temp_dir. path ( ) ) ?;
1997
1993
1998
1994
let python_json_path = temp_dir. path ( ) . join ( "python" ) . join ( "PYTHON.json" ) ;
1999
- let python_json_data = std:: fs:: read ( & python_json_path) ?;
1995
+ let python_json_data = std:: fs:: read ( python_json_path) ?;
2000
1996
let python_json = parse_python_json ( & python_json_data) ?;
2001
1997
2002
1998
let python_exe = temp_dir. path ( ) . join ( "python" ) . join ( python_json. python_exe ) ;
@@ -2005,7 +2001,7 @@ fn verify_distribution_behavior(dist_path: &Path) -> Result<Vec<String>> {
2005
2001
std:: fs:: write ( & test_file, PYTHON_VERIFICATIONS . as_bytes ( ) ) ?;
2006
2002
2007
2003
eprintln ! ( " running interpreter tests (output should follow)" ) ;
2008
- let output = duct:: cmd ( & python_exe, & [ test_file. display ( ) . to_string ( ) ] )
2004
+ let output = duct:: cmd ( python_exe, [ test_file. display ( ) . to_string ( ) ] )
2009
2005
. stdout_to_stderr ( )
2010
2006
. unchecked ( )
2011
2007
. env ( "TARGET_TRIPLE" , & python_json. target_triple )
0 commit comments