1
- #![ allow(
2
- clippy:: inconsistent_digit_grouping,
3
- clippy:: uninlined_format_args,
4
- clippy:: unusual_byte_groupings
5
- ) ]
6
-
7
1
#[ cfg( feature = "bindgen" ) ]
8
2
extern crate bindgen;
9
3
extern crate cc;
@@ -131,7 +125,6 @@ fn main() {
131
125
}
132
126
}
133
127
134
- #[ allow( clippy:: let_and_return) ]
135
128
fn postprocess ( include_dirs : & [ PathBuf ] ) -> Version {
136
129
let version = validate_headers ( include_dirs) ;
137
130
@@ -146,7 +139,7 @@ fn postprocess(include_dirs: &[PathBuf]) -> Version {
146
139
147
140
/// Validates the header files found in `include_dir` and then returns the
148
141
/// version string of OpenSSL.
149
- #[ allow( clippy:: manual_strip ) ] // we need to support pre-1.45.0
142
+ #[ allow( clippy:: unusual_byte_groupings ) ]
150
143
fn validate_headers ( include_dirs : & [ PathBuf ] ) -> Version {
151
144
// This `*-sys` crate only works with OpenSSL 1.0.1, 1.0.2, 1.1.0, 1.1.1 and 3.0.0.
152
145
// To correctly expose the right API from this crate, take a look at
@@ -162,9 +155,7 @@ fn validate_headers(include_dirs: &[PathBuf]) -> Version {
162
155
// account for compile differences and such.
163
156
println ! ( "cargo:rerun-if-changed=build/expando.c" ) ;
164
157
let mut gcc = cc:: Build :: new ( ) ;
165
- for include_dir in include_dirs {
166
- gcc. include ( include_dir) ;
167
- }
158
+ gcc. includes ( include_dirs) ;
168
159
let expanded = match gcc. file ( "build/expando.c" ) . try_expand ( ) {
169
160
Ok ( expanded) => expanded,
170
161
Err ( e) => {
@@ -210,17 +201,14 @@ See rust-openssl documentation for more information:
210
201
let libressl_prefix = "RUST_VERSION_LIBRESSL_" ;
211
202
let boringsl_prefix = "RUST_OPENSSL_IS_BORINGSSL" ;
212
203
let conf_prefix = "RUST_CONF_" ;
213
- if line. starts_with ( openssl_prefix) {
214
- let version = & line[ openssl_prefix. len ( ) ..] ;
204
+ if let Some ( version) = line. strip_prefix ( openssl_prefix) {
215
205
openssl_version = Some ( parse_version ( version) ) ;
216
- } else if line. starts_with ( new_openssl_prefix) {
217
- let version = & line[ new_openssl_prefix. len ( ) ..] ;
206
+ } else if let Some ( version) = line. strip_prefix ( new_openssl_prefix) {
218
207
openssl_version = Some ( parse_new_version ( version) ) ;
219
- } else if line. starts_with ( libressl_prefix) {
220
- let version = & line[ libressl_prefix. len ( ) ..] ;
208
+ } else if let Some ( version) = line. strip_prefix ( libressl_prefix) {
221
209
libressl_version = Some ( parse_version ( version) ) ;
222
- } else if line. starts_with ( conf_prefix) {
223
- enabled. push ( & line [ conf_prefix . len ( ) .. ] ) ;
210
+ } else if let Some ( conf ) = line. strip_prefix ( conf_prefix) {
211
+ enabled. push ( conf ) ;
224
212
} else if line. starts_with ( boringsl_prefix) {
225
213
is_boringssl = true ;
226
214
}
@@ -336,18 +324,13 @@ due to this version mismatch.
336
324
}
337
325
338
326
// parses a string that looks like "0x100020cfL"
339
- #[ allow( deprecated) ] // trim_right_matches is now trim_end_matches
340
- #[ allow( clippy:: match_like_matches_macro) ] // matches macro requires rust 1.42.0
341
327
fn parse_version ( version : & str ) -> u64 {
342
328
// cut off the 0x prefix
343
329
assert ! ( version. starts_with( "0x" ) ) ;
344
330
let version = & version[ 2 ..] ;
345
331
346
332
// and the type specifier suffix
347
- let version = version. trim_right_matches ( |c : char | match c {
348
- '0' ..='9' | 'a' ..='f' | 'A' ..='F' => false ,
349
- _ => true ,
350
- } ) ;
333
+ let version = version. trim_end_matches ( |c : char | !c. is_ascii_hexdigit ( ) ) ;
351
334
352
335
u64:: from_str_radix ( version, 16 ) . unwrap ( )
353
336
}
0 commit comments