Commit f401ba2e authored by Steven Fackler's avatar Steven Fackler
Browse files

Run clippy

parent 40603199
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ on:
  push:
    branches:
      - master
      - github-actions

env:
  RUSTFLAGS: -Dwarnings
@@ -23,3 +22,28 @@ jobs:
        run: rustup update stable && rustup default stable
      - name: Check formatting
        run: cargo fmt --all -- --check

  clippy:
    name: clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Rust
        run: rustup update stable && rustup default stable
      - name: Get rust version
        id: rust-version
        run: echo "::set-output name=version::$(rustc --version)"
      - name: Create lockfile
        run: cargo generate-lockfile
      - name: Cache cargo registry
        uses: actions/cache@v1
        with:
          path: ~/.cargo/registry/cache
          key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
      - name: Cache target directory
        uses: actions/cache@v1
        with:
          path: target
          key: clippy-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
      - name: Check clippy
        run: cargo clippy --all --all-targets
+1 −0
Original line number Diff line number Diff line
#[allow(clippy::inconsistent_digit_grouping)]
pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&'static str> {
    let mut cfgs = vec![];

+28 −25
Original line number Diff line number Diff line
@@ -9,14 +9,15 @@ pub fn get_openssl(target: &str) -> (PathBuf, PathBuf) {
    let lib_dir = env("OPENSSL_LIB_DIR").map(PathBuf::from);
    let include_dir = env("OPENSSL_INCLUDE_DIR").map(PathBuf::from);

    if lib_dir.is_none() || include_dir.is_none() {
    match (lib_dir, include_dir) {
        (Some(lib_dir), Some(include_dir)) => (lib_dir, include_dir),
        (lib_dir, include_dir) => {
            let openssl_dir = env("OPENSSL_DIR").unwrap_or_else(|| find_openssl_dir(&target));
            let openssl_dir = Path::new(&openssl_dir);
            let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib"));
            let include_dir = include_dir.unwrap_or_else(|| openssl_dir.join("include"));
            (lib_dir, include_dir)
    } else {
        (lib_dir.unwrap(), include_dir.unwrap())
        }
    }
}

@@ -93,7 +94,7 @@ openssl-sys = {}
    if host.contains("apple-darwin") && target.contains("apple-darwin") {
        let system = Path::new("/usr/lib/libssl.0.9.8.dylib");
        if system.exists() {
            msg.push_str(&format!(
            msg.push_str(
                "

It looks like you're compiling on macOS, where the system contains a version of
@@ -105,27 +106,28 @@ install the `openssl` package, or as a maintainer you can use the openssl-sys

Unfortunately though the compile cannot continue, so aborting.

"
            ));
",
            );
        }
    }

    if host.contains("unknown-linux") && target.contains("unknown-linux-gnu") {
        if Command::new("pkg-config").output().is_err() {
            msg.push_str(&format!(
    if host.contains("unknown-linux")
        && target.contains("unknown-linux-gnu")
        && Command::new("pkg-config").output().is_err()
    {
        msg.push_str(
            "
It looks like you're compiling on Linux and also targeting Linux. Currently this
requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config`
could not be found. If you have OpenSSL installed you can likely fix this by
installing `pkg-config`.

"
            ));
        }
",
        );
    }

    if host.contains("windows") && target.contains("windows-gnu") {
        msg.push_str(&format!(
        msg.push_str(
            "
It looks like you're compiling for MinGW but you may not have either OpenSSL or
pkg-config installed. You can install these two dependencies with:
@@ -134,12 +136,12 @@ pacman -S openssl-devel pkg-config

and try building this crate again.

"
        ));
",
        );
    }

    if host.contains("windows") && target.contains("windows-msvc") {
        msg.push_str(&format!(
        msg.push_str(
            "
It looks like you're compiling for MSVC but we couldn't detect an OpenSSL
installation. If there isn't one installed then you can try the rust-openssl
@@ -148,8 +150,8 @@ OpenSSL:

https://github.com/sfackler/rust-openssl#windows

"
        ));
",
        );
    }

    panic!(msg);
@@ -234,5 +236,6 @@ fn execute_command_and_get_output(cmd: &str, args: &[&str]) -> Option<String> {
            }
        }
    }
    return None;

    None
}
+4 −2
Original line number Diff line number Diff line
#![allow(clippy::inconsistent_digit_grouping)]

extern crate autocfg;
extern crate cc;
#[cfg(feature = "vendored")]
@@ -79,11 +81,11 @@ fn main() {
    );
    println!("cargo:include={}", include_dir.to_string_lossy());

    let version = validate_headers(&[include_dir.clone().into()]);
    let version = validate_headers(&[include_dir]);

    let libs_env = env("OPENSSL_LIBS");
    let libs = match libs_env.as_ref().and_then(|s| s.to_str()) {
        Some(ref v) => v.split(":").collect(),
        Some(ref v) => v.split(':').collect(),
        None => match version {
            Version::Openssl10x if target.contains("windows") => vec!["ssleay32", "libeay32"],
            Version::Openssl11x if target.contains("windows-msvc") => vec!["libssl", "libcrypto"],
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ const_fn! {
    pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong {
        ((l as c_ulong & 0x0FF) << 24) |
        ((f as c_ulong & 0xFFF) << 12) |
        ((r as c_ulong & 0xFFF))
        (r as c_ulong & 0xFFF)
    }

    pub const fn ERR_GET_LIB(l: c_ulong) -> c_int {
Loading