Commit b771738a authored by Matt Vertescher's avatar Matt Vertescher
Browse files

Fix rustc warnings

- Use `..=` for inclusive ranges
- Add the `dyn` keyword for trait objects
- Switch from `ONCE_INIT` to `std::sync::Once::new()`
parent 7c2a68c7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ fn parse_version(version: &str) -> u64 {

    // and the type specifier suffix
    let version = version.trim_right_matches(|c: char| match c {
        '0'...'9' | 'a'...'f' | 'A'...'F' => false,
        '0'..='9' | 'a'..='f' | 'A'..='F' => false,
        _ => true,
    });

+2 −2
Original line number Diff line number Diff line
@@ -88,10 +88,10 @@ pub type PasswordCallback = unsafe extern "C" fn(
#[cfg(ossl110)]
pub fn init() {
    use std::ptr;
    use std::sync::{Once, ONCE_INIT};
    use std::sync::Once;

    // explicitly initialize to work around https://github.com/openssl/openssl/issues/3505
    static INIT: Once = ONCE_INIT;
    static INIT: Once = Once::new();

    INIT.call_once(|| unsafe {
        OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, ptr::null_mut());
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ use error::ErrorStack;
pub struct StreamState<S> {
    pub stream: S,
    pub error: Option<io::Error>,
    pub panic: Option<Box<Any + Send>>,
    pub panic: Option<Box<dyn Any + Send>>,
}

/// Safe wrapper for BIO_METHOD
@@ -55,7 +55,7 @@ pub unsafe fn take_error<S>(bio: *mut BIO) -> Option<io::Error> {
    state.error.take()
}

pub unsafe fn take_panic<S>(bio: *mut BIO) -> Option<Box<Any + Send>> {
pub unsafe fn take_panic<S>(bio: *mut BIO) -> Option<Box<dyn Any + Send>> {
    let state = state::<S>(bio);
    state.panic.take()
}
+2 −2
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ impl error::Error for Error {
        "an OpenSSL error"
    }

    fn cause(&self) -> Option<&error::Error> {
    fn cause(&self) -> Option<&dyn error::Error> {
        match self.cause {
            Some(InnerError::Io(ref e)) => Some(e),
            Some(InnerError::Ssl(ref e)) => Some(e),
@@ -159,7 +159,7 @@ impl<S: fmt::Debug> StdError for HandshakeError<S> {
        }
    }

    fn cause(&self) -> Option<&StdError> {
    fn cause(&self) -> Option<&dyn StdError> {
        match *self {
            HandshakeError::SetupFailure(ref e) => Some(e),
            HandshakeError::Failure(ref s) | HandshakeError::WouldBlock(ref s) => Some(s.error()),
+2 −2
Original line number Diff line number Diff line
@@ -46,8 +46,8 @@ impl Server {

pub struct Builder {
    ctx: SslContextBuilder,
    ssl_cb: Box<FnMut(&mut SslRef) + Send>,
    io_cb: Box<FnMut(SslStream<TcpStream>) + Send>,
    ssl_cb: Box<dyn FnMut(&mut SslRef) + Send>,
    io_cb: Box<dyn FnMut(SslStream<TcpStream>) + Send>,
    should_error: bool,
}

Loading