Snap for 10447354 from c3cc2de2bf0606264864087bba4d58eae60dea68 to mainline-cellbroadcast-release

Change-Id: I82c43ca652f87f9f33b3f1843bc173931b10b60d
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index dfc0076..1beb39f 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
 {
   "git": {
-    "sha1": "00c21d873aeeac16935ac85962486b41776fe976"
+    "sha1": "6e284984aee68cc2d1b7e7d5e7b5a2a2279cf8e3"
   },
   "path_in_vcs": ""
 }
\ No newline at end of file
diff --git a/.github/workflows/libloading.yml b/.github/workflows/libloading.yml
index e7e84ac..5837da4 100644
--- a/.github/workflows/libloading.yml
+++ b/.github/workflows/libloading.yml
@@ -1,10 +1,11 @@
-name: Test libloading
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
 
 on:
   push:
-    paths-ignore:
-    - '*.mkd'
-    - 'LICENSE'
+    branches: [master]
+    paths-ignore: ['*.mkd', 'LICENSE']
   pull_request:
     types: [opened, reopened, synchronize]
 
@@ -19,38 +20,18 @@
     timeout-minutes: 20
     steps:
       - uses: actions/checkout@v2
-      - name: Install Rust ${{ matrix.rust_toolchain }}
-        uses: actions-rs/toolchain@v1
-        with:
-            toolchain: ${{ matrix.rust_toolchain }}
-            profile: minimal
-            components: clippy
-            default: true
-      - name: Clippy
-        uses: actions-rs/cargo@v1
-        with:
-          command: clippy
-      - name: Test
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: -- --nocapture
-      - name: Test Release
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: --release -- --nocapture
-      - name: Documentation
-        uses: actions-rs/cargo@v1
-        with:
-          command: rustdoc
-          args: |
-            -Zunstable-options
-            --config
-            'build.rustdogflags=["--cfg", "libloading_docs", "-D", "rustdoc::broken_intra_doc_links"]'
+      - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal
+      - run: rustup default ${{ matrix.rust_toolchain }}
+      - run: rustup component add clippy
+      - run: cargo clippy
+      - run: cargo test -- --nocapture
+      - run: cargo test --release -- --nocapture
+      - run: cargo rustdoc -Zunstable-options --config 'build.rustdocflags=["--cfg", "libloading_docs", "-D", "rustdoc::broken_intra_doc_links"]'
         if: ${{ matrix.rust_toolchain == 'nightly' }}
+        # pwsh.exe drops quotes kekw. https://stackoverflow.com/a/59036879
+        shell: bash
 
-  windows-gnu-test:
+  windows-test:
     runs-on: windows-latest
     strategy:
       fail-fast: false
@@ -59,39 +40,35 @@
         rust_target:
           - x86_64-pc-windows-gnu
           - i686-pc-windows-gnu
+        include:
+          - rust_target: x86_64-pc-windows-gnu
+            mingw_path: C:/msys64/mingw64/bin
+            package: mingw-w64-x86_64-gcc
+          - rust_target: i686-pc-windows-gnu
+            mingw_path: C:/msys64/mingw32/bin
+            package: mingw-w64-i686-gcc
     steps:
       - uses: actions/checkout@v2
-      - name: Add MSYS2 to the PATH
-        run: echo "c:/msys64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
-      - name: Add 32-bit mingw-w64 to the PATH
-        run: echo "c:/msys64/mingw32/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
-        if: startsWith(matrix.rust_target, 'i686')
-      - name: Add 64-bit mingw-w64 to the PATH
-        run: echo "c:/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
-        if: startsWith(matrix.rust_target, 'x86_64')
-      - name: Set TARGET variable
-        run: echo "TARGET=${{ matrix.rust_target}}" | Out-File -FilePath $env:GITHUB_ENV -Append
-      - name: Install Rust nightly
-        uses: actions-rs/toolchain@v1
+      - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal
+      - run: rustup default ${{ matrix.rust_toolchain }}
+      - run: rustup target add ${{ matrix.rust_target }}
+      - uses: msys2/setup-msys2@v2
         with:
-            toolchain: ${{ matrix.rust_toolchain }}
-            target: ${{ matrix.rust_target }}
-            profile: minimal
-            default: true
-      - uses: actions-rs/cargo@v1
-        with:
-          command: build
-          args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml
-      - uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml
+          release: false
+          install: ${{ matrix.package }}
+      - run: echo "c:/msys64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
+      - run: echo "${{ matrix.mingw_path }}" | Out-File -FilePath $env:GITHUB_PATH -Append
+        if: ${{ matrix.mingw_path }}"
+      - run: cargo test --target ${{ matrix.rust_target }}
+        env:
+          TARGET: ${{ matrix.rust_target}}
 
   bare-cross-build:
     runs-on: ubuntu-latest
     strategy:
       fail-fast: false
       matrix:
+        rust_toolchain: [nightly]
         rust_target:
           # BSDs: could be tested with full system emulation
           # - x86_64-unknown-dragonfly
@@ -105,25 +82,10 @@
     timeout-minutes: 20
     steps:
       - uses: actions/checkout@v2
-      - name: Install Rust nightly
-        uses: actions-rs/toolchain@v1
-        with:
-            toolchain: nightly
-            profile: minimal
-            default: true
-      - name: Fix-up toolchain
-        run: |
-            rustup component add rust-src --toolchain nightly --target ${{ matrix.rust_target }}
-      - name: Update
-        uses: actions-rs/cargo@v1
-        with:
-          command: update
-          args: --manifest-path=Cargo.toml
-      - name: Build ${{ matrix.rust_target }}
-        uses: actions-rs/cargo@v1
-        with:
-          command: build
-          args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml -Zbuild-std
+      - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal
+      - run: rustup default ${{ matrix.rust_toolchain }}
+      - run: rustup component add rust-src --toolchain nightly --target ${{ matrix.rust_target }}
+      - run: cargo build --target ${{ matrix.rust_target }} -Zbuild-std
 
   cross-ios-build:
     runs-on: macos-latest
@@ -137,20 +99,7 @@
     timeout-minutes: 20
     steps:
       - uses: actions/checkout@v2
-      - name: Install Rust ${{ matrix.rust_toolchain }}
-        uses: actions-rs/toolchain@v1
-        with:
-            toolchain: ${{ matrix.rust_toolchain }}
-            target: ${{ matrix.rust_target }}
-            profile: minimal
-            default: true
-      - name: Update
-        uses: actions-rs/cargo@v1
-        with:
-          command: update
-          args: --manifest-path=Cargo.toml
-      - name: Build ${{ matrix.rust_target }}
-        uses: actions-rs/cargo@v1
-        with:
-          command: build
-          args: --target=${{ matrix.rust_target }} --manifest-path=Cargo.toml
+      - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal
+      - run: rustup default ${{ matrix.rust_toolchain }}
+      - run: rustup target add ${{ matrix.rust_target }}
+      - run: cargo build  --target=${{ matrix.rust_target }}
diff --git a/Android.bp b/Android.bp
index bdf4513..4c7c2ac 100644
--- a/Android.bp
+++ b/Android.bp
@@ -23,7 +23,7 @@
     host_supported: true,
     crate_name: "libloading",
     cargo_env_compat: true,
-    cargo_pkg_version: "0.7.3",
+    cargo_pkg_version: "0.7.4",
     srcs: ["src/lib.rs"],
     edition: "2015",
     rustlibs: [
@@ -33,4 +33,6 @@
         "//apex_available:platform",
         "com.android.virt",
     ],
+    product_available: true,
+    vendor_available: true,
 }
diff --git a/Cargo.toml b/Cargo.toml
index 39b41f3..65168d5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,25 +12,40 @@
 [package]
 rust-version = "1.40.0"
 name = "libloading"
-version = "0.7.3"
+version = "0.7.4"
 authors = ["Simonas Kazlauskas <libloading@kazlauskas.me>"]
 description = "Bindings around the platform's dynamic library loading primitives with greatly improved memory safety."
 documentation = "https://docs.rs/libloading/"
 readme = "README.mkd"
-keywords = ["dlopen", "load", "shared", "dylib"]
+keywords = [
+    "dlopen",
+    "load",
+    "shared",
+    "dylib",
+]
 categories = ["api-bindings"]
 license = "ISC"
 repository = "https://github.com/nagisa/rust_libloading/"
+
 [package.metadata.docs.rs]
 all-features = true
-rustdoc-args = ["--cfg", "libloading_docs"]
+rustdoc-args = [
+    "--cfg",
+    "libloading_docs",
+]
+
 [dev-dependencies.libc]
 version = "0.2"
 
 [dev-dependencies.static_assertions]
 version = "1.1"
+
 [target."cfg(unix)".dependencies.cfg-if]
 version = "1"
+
 [target."cfg(windows)".dependencies.winapi]
 version = "0.3"
-features = ["errhandlingapi", "libloaderapi"]
+features = [
+    "errhandlingapi",
+    "libloaderapi",
+]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 35e8353..3fdf0c8 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -3,7 +3,7 @@
 # When bumping
 # * Don’t forget to add an entry to `src/changelog.rs`
 # * If bumping to an incompatible version, adjust the documentation in `src/lib.rs`
-version = "0.7.3"
+version = "0.7.4"
 authors = ["Simonas Kazlauskas <libloading@kazlauskas.me>"]
 license = "ISC"
 repository = "https://github.com/nagisa/rust_libloading/"
diff --git a/METADATA b/METADATA
index 0efb20d..ca107f6 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/libloading
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
 name: "libloading"
 description: "Bindings around the platform\'s dynamic library loading primitives with greatly improved memory safety."
 third_party {
@@ -7,13 +11,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/libloading/libloading-0.7.3.crate"
+    value: "https://static.crates.io/crates/libloading/libloading-0.7.4.crate"
   }
-  version: "0.7.3"
+  version: "0.7.4"
   license_type: NOTICE
   last_upgrade_date {
     year: 2022
-    month: 3
-    day: 1
+    month: 12
+    day: 12
   }
 }
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 0f8796c..cc33493 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -9,22 +9,12 @@
     },
     {
       "path": "external/rust/crates/vulkano"
-    }
-  ],
-  "presubmit": [
-    {
-      "name": "keystore2_test"
     },
     {
-      "name": "legacykeystore_test"
-    }
-  ],
-  "presubmit-rust": [
-    {
-      "name": "keystore2_test"
+      "path": "system/security/keystore2"
     },
     {
-      "name": "legacykeystore_test"
+      "path": "system/security/keystore2/legacykeystore"
     }
   ]
 }
diff --git a/cargo2android.json b/cargo2android.json
index 42b7833..9569807 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -5,5 +5,6 @@
   ],
   "dependencies": true,
   "device": true,
-  "run": true
+  "run": true,
+  "vendor_available": true
 }
\ No newline at end of file
diff --git a/src/changelog.rs b/src/changelog.rs
index f8b898e..162544f 100644
--- a/src/changelog.rs
+++ b/src/changelog.rs
@@ -1,5 +1,12 @@
 //! The change log.
 
+/// Release 0.7.4 (2022-11-07)
+///
+/// This release has no functional changes.
+///
+/// `RTLD_LAZY`, `RTLD_GLOBAL` and `RTLD_LOCAL` constants have been implemented for AIX platforms.
+pub mod r0_7_4 {}
+
 /// Release 0.7.3 (2022-01-15)
 ///
 /// This release has no functional changes.
@@ -198,7 +205,7 @@
 /// Release 0.6.0 (2020-04-05)
 ///
 /// * Introduced a new method [`os::unix::Library::get_singlethreaded`];
-/// * Added (untested) support for building when targetting Redox and Fuchsia;
+/// * Added (untested) support for building when targeting Redox and Fuchsia;
 /// * The APIs exposed by this library no longer panic and instead return an `Err` when it used
 ///   to panic.
 ///
diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs
index dbe4df9..ea7a6a1 100644
--- a/src/os/unix/consts.rs
+++ b/src/os/unix/consts.rs
@@ -60,6 +60,8 @@
     cfg_if! {
         if #[cfg(target_os = "haiku")] {
             pub(super) const RTLD_LAZY: c_int = 0;
+        } else if #[cfg(target_os = "aix")] {
+            pub(super) const RTLD_LAZY: c_int = 4;
         } else if #[cfg(any(
             target_os = "linux",
             target_os = "android",
@@ -104,6 +106,7 @@
             target_os = "openbsd",
             target_os = "netbsd",
 
+            target_os = "aix",
             target_os = "solaris",
             target_os = "illumos",
 
@@ -129,6 +132,8 @@
             all(target_os = "android",target_pointer_width = "32"),
         ))] {
             pub(super) const RTLD_GLOBAL: c_int = 2;
+        } else if #[cfg(target_os = "aix")] {
+            pub(super) const RTLD_GLOBAL: c_int = 0x10000;
         } else if #[cfg(any(
             target_env = "uclibc",
             all(target_os = "linux", target_arch = "mips"),
@@ -169,6 +174,8 @@
     cfg_if! {
         if #[cfg(target_os = "netbsd")] {
             pub(super) const RTLD_LOCAL: c_int = 0x200;
+        } else if #[cfg(target_os = "aix")] {
+            pub(super) const RTLD_LOCAL: c_int = 0x80000;
         } else if #[cfg(any(
             target_os = "macos",
             target_os = "ios",
diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs
index fd0777e..df7efda 100644
--- a/src/os/unix/mod.rs
+++ b/src/os/unix/mod.rs
@@ -365,9 +365,7 @@
 impl<T> Symbol<T> {
     /// Convert the loaded `Symbol` into a raw pointer.
     pub fn into_raw(self) -> *mut raw::c_void {
-        let pointer = self.pointer;
-        mem::forget(self);
-        pointer
+        self.pointer
     }
 }
 
diff --git a/src/os/windows/mod.rs b/src/os/windows/mod.rs
index eadeb69..e3da940 100644
--- a/src/os/windows/mod.rs
+++ b/src/os/windows/mod.rs
@@ -307,7 +307,7 @@
             let mut buf =
                 mem::MaybeUninit::<[mem::MaybeUninit::<WCHAR>; 1024]>::uninit().assume_init();
             let len = libloaderapi::GetModuleFileNameW(self.0,
-                (&mut buf[..]).as_mut_ptr().cast(), 1024) as usize;
+                buf[..].as_mut_ptr().cast(), 1024) as usize;
             if len == 0 {
                 f.write_str(&format!("Library@{:p}", self.0))
             } else {
@@ -333,9 +333,7 @@
 impl<T> Symbol<T> {
     /// Convert the loaded `Symbol` into a handle.
     pub fn into_raw(self) -> FARPROC {
-        let pointer = self.pointer;
-        mem::forget(self);
-        pointer
+        self.pointer
     }
 }
 
diff --git a/tests/functions.rs b/tests/functions.rs
index 795f0cf..c8d1952 100644
--- a/tests/functions.rs
+++ b/tests/functions.rs
@@ -2,19 +2,26 @@
 extern crate winapi;
 
 extern crate libloading;
-use libloading::{Symbol, Library};
+use libloading::{Library, Symbol};
 
-const LIBPATH: &'static str = "target/libtest_helpers.module";
+const TARGET_DIR: Option<&'static str> = option_env!("CARGO_TARGET_DIR");
+const TARGET_TMPDIR: Option<&'static str> = option_env!("CARGO_TARGET_TMPDIR");
+
+fn lib_path() -> std::path::PathBuf {
+    [
+        TARGET_TMPDIR.unwrap_or(TARGET_DIR.unwrap_or("target")),
+        "libtest_helpers.module",
+    ]
+    .iter()
+    .collect()
+}
 
 fn make_helpers() {
     static ONCE: ::std::sync::Once = ::std::sync::Once::new();
     ONCE.call_once(|| {
-        let rustc = std::env::var_os("RUSTC").unwrap_or_else(|| { "rustc".into() });
+        let rustc = std::env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
         let mut cmd = ::std::process::Command::new(rustc);
-        cmd
-            .arg("src/test_helpers.rs")
-            .arg("-o")
-            .arg(LIBPATH);
+        cmd.arg("src/test_helpers.rs").arg("-o").arg(lib_path());
         if let Some(target) = std::env::var_os("TARGET") {
             cmd.arg("--target").arg(target);
         } else {
@@ -23,8 +30,7 @@
         assert!(cmd
             .status()
             .expect("could not compile the test helpers!")
-            .success()
-        );
+            .success());
     });
 }
 
@@ -32,28 +38,41 @@
 fn test_id_u32() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
-        let f: Symbol<unsafe extern fn(u32) -> u32> = lib.get(b"test_identity_u32\0").unwrap();
+        let lib = Library::new(lib_path()).unwrap();
+        let f: Symbol<unsafe extern "C" fn(u32) -> u32> = lib.get(b"test_identity_u32\0").unwrap();
         assert_eq!(42, f(42));
     }
 }
 
 #[repr(C)]
-#[derive(Clone,Copy,PartialEq,Debug)]
+#[derive(Clone, Copy, PartialEq, Debug)]
 struct S {
     a: u64,
     b: u32,
     c: u16,
-    d: u8
+    d: u8,
 }
 
 #[test]
 fn test_id_struct() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
-        let f: Symbol<unsafe extern fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
-        assert_eq!(S { a: 1, b: 2, c: 3, d: 4 }, f(S { a: 1, b: 2, c: 3, d: 4 }));
+        let lib = Library::new(lib_path()).unwrap();
+        let f: Symbol<unsafe extern "C" fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
+        assert_eq!(
+            S {
+                a: 1,
+                b: 2,
+                c: 3,
+                d: 4
+            },
+            f(S {
+                a: 1,
+                b: 2,
+                c: 3,
+                d: 4
+            })
+        );
     }
 }
 
@@ -61,9 +80,9 @@
 fn test_0_no_0() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
-        let f: Symbol<unsafe extern fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
-        let f2: Symbol<unsafe extern fn(S) -> S> = lib.get(b"test_identity_struct").unwrap();
+        let lib = Library::new(lib_path()).unwrap();
+        let f: Symbol<unsafe extern "C" fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
+        let f2: Symbol<unsafe extern "C" fn(S) -> S> = lib.get(b"test_identity_struct").unwrap();
         assert_eq!(*f, *f2);
     }
 }
@@ -71,7 +90,9 @@
 #[test]
 fn wrong_name_fails() {
     unsafe {
-        Library::new("target/this_location_is_definitely_non existent:^~").err().unwrap();
+        Library::new("target/this_location_is_definitely_non existent:^~")
+            .err()
+            .unwrap();
     }
 }
 
@@ -79,7 +100,7 @@
 fn missing_symbol_fails() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
+        let lib = Library::new(lib_path()).unwrap();
         lib.get::<*mut ()>(b"test_does_not_exist").err().unwrap();
         lib.get::<*mut ()>(b"test_does_not_exist\0").err().unwrap();
     }
@@ -89,9 +110,11 @@
 fn interior_null_fails() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
+        let lib = Library::new(lib_path()).unwrap();
         lib.get::<*mut ()>(b"test_does\0_not_exist").err().unwrap();
-        lib.get::<*mut ()>(b"test\0_does_not_exist\0").err().unwrap();
+        lib.get::<*mut ()>(b"test\0_does_not_exist\0")
+            .err()
+            .unwrap();
     }
 }
 
@@ -99,10 +122,10 @@
 fn test_incompatible_type() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
+        let lib = Library::new(lib_path()).unwrap();
         assert!(match lib.get::<()>(b"test_identity_u32\0") {
-           Err(libloading::Error::IncompatibleSize) => true,
-           _ => false,
+            Err(libloading::Error::IncompatibleSize) => true,
+            _ => false,
         })
     }
 }
@@ -114,10 +137,10 @@
         l.get::<T>(b"test_identity_u32\0")
     }
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
+        let lib = Library::new(lib_path()).unwrap();
         assert!(match get(&lib, test_incompatible_type_named_fn) {
-           Err(libloading::Error::IncompatibleSize) => true,
-           _ => false,
+            Err(libloading::Error::IncompatibleSize) => true,
+            _ => false,
         })
     }
 }
@@ -126,10 +149,11 @@
 fn test_static_u32() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
+        let lib = Library::new(lib_path()).unwrap();
         let var: Symbol<*mut u32> = lib.get(b"TEST_STATIC_U32\0").unwrap();
         **var = 42;
-        let help: Symbol<unsafe extern fn() -> u32> = lib.get(b"test_get_static_u32\0").unwrap();
+        let help: Symbol<unsafe extern "C" fn() -> u32> =
+            lib.get(b"test_get_static_u32\0").unwrap();
         assert_eq!(42, help());
     }
 }
@@ -138,10 +162,10 @@
 fn test_static_ptr() {
     make_helpers();
     unsafe {
-        let lib = Library::new(LIBPATH).unwrap();
+        let lib = Library::new(lib_path()).unwrap();
         let var: Symbol<*mut *mut ()> = lib.get(b"TEST_STATIC_PTR\0").unwrap();
         **var = *var as *mut _;
-        let works: Symbol<unsafe extern fn() -> bool> =
+        let works: Symbol<unsafe extern "C" fn() -> bool> =
             lib.get(b"test_check_static_ptr\0").unwrap();
         assert!(works());
     }
@@ -152,25 +176,26 @@
 // and unloaded many times. So far it seems like an issue with mingw, not libloading, so ignoring
 // the target. Especially since it is very unlikely to be fixed given the state of support its
 // support.
-#[cfg(not(all(target_arch="x86", target_os="windows", target_env="gnu")))]
+#[cfg(not(all(target_arch = "x86", target_os = "windows", target_env = "gnu")))]
 fn manual_close_many_times() {
     make_helpers();
-    let join_handles: Vec<_> = (0..16).map(|_| {
-        std::thread::spawn(|| unsafe {
-            for _ in 0..10000 {
-                let lib = Library::new(LIBPATH).expect("open library");
-                let _: Symbol<unsafe extern fn(u32) -> u32> =
-                    lib.get(b"test_identity_u32").expect("get fn");
-                lib.close().expect("close is successful");
-            }
+    let join_handles: Vec<_> = (0..16)
+        .map(|_| {
+            std::thread::spawn(|| unsafe {
+                for _ in 0..10000 {
+                    let lib = Library::new(lib_path()).expect("open library");
+                    let _: Symbol<unsafe extern "C" fn(u32) -> u32> =
+                        lib.get(b"test_identity_u32").expect("get fn");
+                    lib.close().expect("close is successful");
+                }
+            })
         })
-    }).collect();
+        .collect();
     for handle in join_handles {
         handle.join().expect("thread should succeed");
     }
 }
 
-
 #[cfg(unix)]
 #[test]
 fn library_this_get() {
@@ -178,10 +203,12 @@
     make_helpers();
     // SAFE: functions are never called
     unsafe {
-        let _lib = Library::new(LIBPATH).unwrap();
+        let _lib = Library::new(lib_path()).unwrap();
         let this = Library::this();
         // Library we loaded in `_lib` (should be RTLD_LOCAL).
-        assert!(this.get::<unsafe extern "C" fn()>(b"test_identity_u32").is_err());
+        assert!(this
+            .get::<unsafe extern "C" fn()>(b"test_identity_u32")
+            .is_err());
         // Something obscure from libc...
         assert!(this.get::<unsafe extern "C" fn()>(b"freopen").is_ok());
     }
@@ -194,11 +221,13 @@
     make_helpers();
     unsafe {
         // SAFE: well-known library without initialisers is loaded.
-        let _lib = Library::new(LIBPATH).unwrap();
+        let _lib = Library::new(lib_path()).unwrap();
         let this = Library::this().expect("this library");
         // SAFE: functions are never called.
         // Library we loaded in `_lib`.
-        assert!(this.get::<unsafe extern "C" fn()>(b"test_identity_u32").is_err());
+        assert!(this
+            .get::<unsafe extern "C" fn()>(b"test_identity_u32")
+            .is_err());
         // Something "obscure" from kernel32...
         assert!(this.get::<unsafe extern "C" fn()>(b"GetLastError").is_err());
     }
@@ -207,9 +236,9 @@
 #[cfg(windows)]
 #[test]
 fn works_getlasterror() {
-    use winapi::um::errhandlingapi;
-    use winapi::shared::minwindef::DWORD;
     use libloading::os::windows::{Library, Symbol};
+    use winapi::shared::minwindef::DWORD;
+    use winapi::um::errhandlingapi;
 
     unsafe {
         let lib = Library::new("kernel32.dll").unwrap();
@@ -222,9 +251,9 @@
 #[cfg(windows)]
 #[test]
 fn works_getlasterror0() {
-    use winapi::um::errhandlingapi;
-    use winapi::shared::minwindef::DWORD;
     use libloading::os::windows::{Library, Symbol};
+    use winapi::shared::minwindef::DWORD;
+    use winapi::um::errhandlingapi;
 
     unsafe {
         let lib = Library::new("kernel32.dll").unwrap();