Skip to content

Commit 28b3925

Browse files
authored
Merge pull request #1966 from tesuji/tidy-old-msrv
Remove old codes that belows supported Rust version.
2 parents f03a2dc + 9784356 commit 28b3925

File tree

8 files changed

+16
-35
lines changed

8 files changed

+16
-35
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
runs-on: ubuntu-latest
6060
steps:
6161
- uses: actions/checkout@v3
62+
# Remember to also update `--rust-target` in `openssl-sys/build/run_bindgen.rs`
6263
- uses: sfackler/actions/rustup@master
6364
with:
6465
version: 1.56.0

openssl-sys/build/cfgs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(clippy::unusual_byte_groupings)]
12
pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&'static str> {
23
let mut cfgs = vec![];
34

openssl-sys/build/main.rs

+8-25
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#![allow(
2-
clippy::inconsistent_digit_grouping,
3-
clippy::uninlined_format_args,
4-
clippy::unusual_byte_groupings
5-
)]
6-
71
#[cfg(feature = "bindgen")]
82
extern crate bindgen;
93
extern crate cc;
@@ -131,7 +125,6 @@ fn main() {
131125
}
132126
}
133127

134-
#[allow(clippy::let_and_return)]
135128
fn postprocess(include_dirs: &[PathBuf]) -> Version {
136129
let version = validate_headers(include_dirs);
137130

@@ -146,7 +139,7 @@ fn postprocess(include_dirs: &[PathBuf]) -> Version {
146139

147140
/// Validates the header files found in `include_dir` and then returns the
148141
/// version string of OpenSSL.
149-
#[allow(clippy::manual_strip)] // we need to support pre-1.45.0
142+
#[allow(clippy::unusual_byte_groupings)]
150143
fn validate_headers(include_dirs: &[PathBuf]) -> Version {
151144
// This `*-sys` crate only works with OpenSSL 1.0.1, 1.0.2, 1.1.0, 1.1.1 and 3.0.0.
152145
// To correctly expose the right API from this crate, take a look at
@@ -162,9 +155,7 @@ fn validate_headers(include_dirs: &[PathBuf]) -> Version {
162155
// account for compile differences and such.
163156
println!("cargo:rerun-if-changed=build/expando.c");
164157
let mut gcc = cc::Build::new();
165-
for include_dir in include_dirs {
166-
gcc.include(include_dir);
167-
}
158+
gcc.includes(include_dirs);
168159
let expanded = match gcc.file("build/expando.c").try_expand() {
169160
Ok(expanded) => expanded,
170161
Err(e) => {
@@ -210,17 +201,14 @@ See rust-openssl documentation for more information:
210201
let libressl_prefix = "RUST_VERSION_LIBRESSL_";
211202
let boringsl_prefix = "RUST_OPENSSL_IS_BORINGSSL";
212203
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) {
215205
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) {
218207
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) {
221209
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);
224212
} else if line.starts_with(boringsl_prefix) {
225213
is_boringssl = true;
226214
}
@@ -336,18 +324,13 @@ due to this version mismatch.
336324
}
337325

338326
// 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
341327
fn parse_version(version: &str) -> u64 {
342328
// cut off the 0x prefix
343329
assert!(version.starts_with("0x"));
344330
let version = &version[2..];
345331

346332
// 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());
351334

352335
u64::from_str_radix(version, 16).unwrap()
353336
}

openssl-sys/build/run_bindgen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn run_boringssl(include_dirs: &[PathBuf]) {
167167
bindgen_cmd
168168
.arg("-o")
169169
.arg(out_dir.join("bindgen.rs"))
170-
.arg("--rust-target=1.47")
170+
.arg("--rust-target=1.56")
171171
.arg("--ctypes-prefix=::libc")
172172
.arg("--raw-line=use libc::*;")
173173
.arg("--no-derive-default")

openssl-sys/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#![allow(
22
clippy::missing_safety_doc,
3-
clippy::unreadable_literal,
4-
clippy::uninlined_format_args,
5-
clippy::upper_case_acronyms,
63
dead_code,
74
non_camel_case_types,
85
non_snake_case,
96
non_upper_case_globals,
10-
overflowing_literals,
117
unused_imports
128
)]
139
#![cfg_attr(feature = "unstable_boringssl", allow(ambiguous_glob_reexports))]

openssl/src/ssl/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl AlpnError {
599599
/// Terminate the handshake with a fatal alert.
600600
///
601601
/// Requires OpenSSL 1.1.0 or newer.
602-
#[cfg(any(ossl110))]
602+
#[cfg(ossl110)]
603603
pub const ALERT_FATAL: AlpnError = AlpnError(ffi::SSL_TLSEXT_ERR_ALERT_FATAL);
604604

605605
/// Do not select a protocol, but continue the handshake.
@@ -2413,7 +2413,7 @@ impl SslRef {
24132413
///
24142414
/// Requires OpenSSL 1.0.1 or 1.0.2.
24152415
#[corresponds(SSL_set_tmp_ecdh_callback)]
2416-
#[cfg(any(all(ossl101, not(ossl110))))]
2416+
#[cfg(all(ossl101, not(ossl110)))]
24172417
#[deprecated(note = "this function leaks memory and does not exist on newer OpenSSL versions")]
24182418
pub fn set_tmp_ecdh_callback<F>(&mut self, callback: F)
24192419
where

openssl/src/ssl/test/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ fn test_alpn_server_advertise_multiple() {
467467
}
468468

469469
#[test]
470-
#[cfg(any(ossl110))]
470+
#[cfg(ossl110)]
471471
fn test_alpn_server_select_none_fatal() {
472472
let mut server = Server::builder();
473473
server.ctx().set_alpn_select_callback(|_, client| {

openssl/src/symm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ mod tests {
14781478
}
14791479

14801480
#[test]
1481-
#[cfg(any(ossl110))]
1481+
#[cfg(ossl110)]
14821482
fn test_chacha20() {
14831483
let key = "0000000000000000000000000000000000000000000000000000000000000000";
14841484
let iv = "00000000000000000000000000000000";
@@ -1493,7 +1493,7 @@ mod tests {
14931493
}
14941494

14951495
#[test]
1496-
#[cfg(any(ossl110))]
1496+
#[cfg(ossl110)]
14971497
fn test_chacha20_poly1305() {
14981498
let key = "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f";
14991499
let iv = "070000004041424344454647";

0 commit comments

Comments
 (0)