Generate documentation and run clippy in CI

This commit is contained in:
Simonas Kazlauskas
2020-08-22 06:26:20 +03:00
committed by Simonas Kazlauskas
parent 903641db60
commit adbc5bebba
4 changed files with 29 additions and 11 deletions
+22 -2
View File
@@ -24,12 +24,17 @@ jobs:
with:
toolchain: ${{ matrix.rust_toolchain }}
profile: minimal
components: clippy
default: true
- name: Update
uses: actions-rs/cargo@v1
with:
command: update
args: --manifest-path=Cargo.toml
- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
- name: Build
uses: actions-rs/cargo@v1
with:
@@ -45,6 +50,14 @@ jobs:
with:
command: test
args: --manifest-path=Cargo.toml --release -- --nocapture
- name: Documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --manifest-path=Cargo.toml
env:
RUSTDOCFLAGS: --cfg docsrs
if: ${{ matrix.rust_toolchain == 'nightly' }}
windows-gnu-test:
runs-on: windows-latest
@@ -54,10 +67,17 @@ jobs:
rust_toolchain: [nightly, stable]
rust_target:
- x86_64-pc-windows-gnu
# Only 64 bit GCC is preinstalled
#- i686-pc-windows-gnu
- i686-pc-windows-gnu
steps:
- uses: actions/checkout@v2
- name: Add MSYS2 to the PATH
run: echo "::add-path::c:/msys64/bin"
- name: Add 32-bit mingw-w64 to the PATH
run: echo "::add-path::c:/msys64/mingw32/bin"
if: startsWith(matrix.rust_target, 'i686')
- name: Add 64-bit mingw-w64 to the PATH
run: echo "::add-path::c:/msys64/mingw64/bin"
if: startsWith(matrix.rust_target, 'x86_64')
- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
+4 -6
View File
@@ -219,11 +219,9 @@ impl Library {
#[inline(always)]
pub unsafe fn get<T>(&self, symbol: &[u8]) -> Result<Symbol<T>, crate::Error> {
#[cfg(mtsafe_dlerror)]
{ return self.get_singlethreaded(symbol); }
{ self.get_singlethreaded(symbol) }
#[cfg(not(mtsafe_dlerror))]
{
return self.get_impl(symbol, || Err(crate::Error::DlSymUnknown));
}
{ self.get_impl(symbol, || Err(crate::Error::DlSymUnknown)) }
}
/// Get a pointer to function or static variable by symbol name.
@@ -275,7 +273,7 @@ impl Library {
/// with this pointer as an argument.
pub unsafe fn from_raw(handle: *mut raw::c_void) -> Library {
Library {
handle: handle
handle
}
}
@@ -359,7 +357,7 @@ impl<T> ::std::ops::Deref for Symbol<T> {
fn deref(&self) -> &T {
unsafe {
// Additional reference level for a dereference on `deref` return value.
mem::transmute(&self.pointer)
&*(&self.pointer as *const *mut _ as *const T)
}
}
}
+2 -2
View File
@@ -265,7 +265,7 @@ impl<T> ::std::ops::Deref for Symbol<T> {
fn deref(&self) -> &T {
unsafe {
// Additional reference level for a dereference on `deref` return value.
mem::transmute(&self.pointer)
&*(&self.pointer as *const *mut _ as *const T)
}
}
}
@@ -276,11 +276,11 @@ impl<T> fmt::Debug for Symbol<T> {
}
}
static USE_ERRORMODE: AtomicBool = AtomicBool::new(false);
struct ErrorModeGuard(DWORD);
impl ErrorModeGuard {
#[allow(clippy::if_same_then_else)]
fn new() -> Option<ErrorModeGuard> {
unsafe {
if !USE_ERRORMODE.load(Ordering::Acquire) {
+1 -1
View File
@@ -7,7 +7,7 @@ use crate::Error;
/// Checks for last byte and avoids allocating if it is zero.
///
/// Non-last null bytes still result in an error.
pub(crate) fn cstr_cow_from_bytes<'a>(slice: &'a [u8]) -> Result<Cow<'a, CStr>, Error> {
pub(crate) fn cstr_cow_from_bytes(slice: &[u8]) -> Result<Cow<'_, CStr>, Error> {
static ZERO: raw::c_char = 0;
Ok(match slice.last() {
// Slice out of 0 elements