Skip to content

Commit

Permalink
Merge pull request #169 from madsmtm/clippy
Browse files Browse the repository at this point in the history
Run clippy in CI
  • Loading branch information
madsmtm authored Jun 16, 2022
2 parents 73983a0 + cf75986 commit a301d25
Show file tree
Hide file tree
Showing 27 changed files with 152 additions and 113 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
rust:
toolchain: nightly
target: x86_64-apple-darwin
components: rust-src
components: clippy, rust-src
args: -Zbuild-std -Zdoctest-xcompile
# 32-bit support was removed in 10.15, so we can't test the
# binary, only build it
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
rust:
toolchain: nightly
target: x86_64-apple-darwin
components: rust-src
components: clippy, rust-src
args: -Zbuild-std -Zdoctest-xcompile
test-args: --no-run
- name: Build iOS ARMv7s
Expand All @@ -123,7 +123,7 @@ jobs:
rust:
toolchain: nightly
target: x86_64-apple-darwin
components: rust-src
components: clippy, rust-src
args: -Zbuild-std -Zdoctest-xcompile
test-args: --no-run
- name: Build iOS 32bit x86
Expand All @@ -132,7 +132,7 @@ jobs:
rust:
toolchain: nightly
target: x86_64-apple-darwin
components: rust-src
components: clippy, rust-src
args: -Zbuild-std -Zdoctest-xcompile
test-args: --no-run
- name: Test Compiler-RT
Expand Down Expand Up @@ -302,7 +302,7 @@ jobs:
toolchain: ${{ matrix.rust.toolchain || 'stable' }}
profile: minimal
override: true
components: ${{ matrix.rust.components }}
components: ${{ matrix.rust.components || 'clippy' }}
# Allows installing for a different base target
target: ${{ matrix.rust.target || matrix.target }}

Expand All @@ -312,6 +312,13 @@ jobs:
# cargo install cargo-dinghy --version=^0.4 --root=$HOME/extern --target=x86_64-apple-darwin
run: cargo install --git https://github.com/madsmtm/dinghy.git --branch update-cargo --bin cargo-dinghy --root=$HOME/extern --target=x86_64-apple-darwin

- name: Lint
uses: actions-rs/cargo@v1
with:
command: clippy
# Temporarily allow `clippy::let_unit_value`
args: ${{ env.ARGS }} --all-targets -- --deny warnings --allow clippy::let_unit_value

- name: Build
if: ${{ !matrix.dinghy }}
uses: actions-rs/cargo@v1
Expand Down
6 changes: 6 additions & 0 deletions block-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
// See https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html.

#![no_std]
#![warn(elided_lifetimes_in_paths)]
#![deny(non_ascii_idents)]
#![warn(unreachable_pub)]
#![deny(unsafe_op_in_unsafe_fn)]
#![warn(clippy::cargo)]
#![warn(clippy::ptr_as_ptr)]
// Update in Cargo.toml as well.
#![doc(html_root_url = "https://docs.rs/block-sys/0.0.4")]

Expand Down
9 changes: 8 additions & 1 deletion block2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
#![deny(non_ascii_idents)]
#![warn(unreachable_pub)]
#![deny(unsafe_op_in_unsafe_fn)]
#![warn(clippy::cargo)]
#![warn(clippy::ptr_as_ptr)]
// Update in Cargo.toml as well.
#![doc(html_root_url = "https://docs.rs/block2/0.2.0-alpha.4")]

Expand Down Expand Up @@ -177,7 +179,12 @@ block_args_impl!(
#[repr(C)]
pub struct Block<A, R> {
_inner: [u8; 0],
p: PhantomData<(ffi::Block_layout, fn(A) -> R)>,
// We effectively store `Block_layout` + a bit more, but `Block` has to
// remain an empty type otherwise the compiler thinks we only have
// provenance over `Block_layout`.
_layout: PhantomData<ffi::Block_layout>,
// To get correct variance on args and return types
_p: PhantomData<fn(A) -> R>,
}

unsafe impl<A: BlockArguments + EncodeArguments, R: Encode> RefEncode for Block<A, R> {
Expand Down
2 changes: 2 additions & 0 deletions objc-sys/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ use std::os::raw::c_int;
use crate::{id, objc_class, BOOL};

/// The equivalent of `true` for Objective-C's [`BOOL`][`super::BOOL`] type.
#[allow(clippy::unnecessary_cast)]
pub const YES: BOOL = true as BOOL; // true -> 1

/// The equivalent of `false` for Objective-C's [`BOOL`][`super::BOOL`] type.
#[allow(clippy::unnecessary_cast)]
pub const NO: BOOL = false as BOOL; // false -> 0

/// A quick alias for a [`null_mut`][`core::ptr::null_mut`] object / instance.
Expand Down
6 changes: 6 additions & 0 deletions objc-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
//! [objc4]: https://github.com/apple-oss-distributions/objc4

#![no_std]
#![warn(elided_lifetimes_in_paths)]
#![deny(non_ascii_idents)]
#![warn(unreachable_pub)]
#![deny(unsafe_op_in_unsafe_fn)]
#![warn(clippy::cargo)]
#![warn(clippy::ptr_as_ptr)]
#![allow(clippy::upper_case_acronyms)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
Expand Down
12 changes: 6 additions & 6 deletions objc-sys/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod inner {
target_os = "watchos",
))]
// C: _Bool
pub type BOOL = bool;
pub(crate) type BOOL = bool;

// Inverse of the above
#[cfg(not(any(
Expand All @@ -31,26 +31,26 @@ mod inner {
target_os = "watchos",
)))]
// C: (explicitly) signed char
pub type BOOL = i8;
pub(crate) type BOOL = i8;
}

// GNUStep's and Microsoft's libobjc2
#[cfg(all(gnustep, libobjc2_strict_apple_compat))]
mod inner {
// C: (explicitly) signed char
pub type BOOL = i8;
pub(crate) type BOOL = i8;
}

#[cfg(all(gnustep, not(libobjc2_strict_apple_compat)))]
mod inner {
// windows && !32bit-MinGW
#[cfg(all(windows, not(all(target_pointer_width = "64", target_env = "gnu"))))]
pub type BOOL = std::os::raw::c_int;
pub(crate) type BOOL = std::os::raw::c_int;

// The inverse
#[cfg(not(all(windows, not(all(target_pointer_width = "64", target_env = "gnu")))))]
// C: unsigned char
pub type BOOL = u8;
pub(crate) type BOOL = u8;
}

// ObjFW
Expand All @@ -59,7 +59,7 @@ mod inner {
// Defined in ObjFW-RT.h
// C: signed char
// This has changed since v0.90, but we don't support that yet.
pub type BOOL = i8;
pub(crate) type BOOL = i8;

// Note that ObjFW uses `bool` in return types, but that doesn't change
// the ABI, so we'll just use `BOOL` there for ease of use.
Expand Down
2 changes: 2 additions & 0 deletions objc2-encode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
#![deny(non_ascii_idents)]
#![warn(unreachable_pub)]
#![deny(unsafe_op_in_unsafe_fn)]
#![warn(clippy::cargo)]
#![warn(clippy::ptr_as_ptr)]
// Update in Cargo.toml as well.
#![doc(html_root_url = "https://docs.rs/objc2-encode/2.0.0-pre.0")]

Expand Down
2 changes: 1 addition & 1 deletion objc2-encode/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub(crate) fn rm_enc_prefix<'a>(s: &'a str, enc: &Encoding<'_>) -> Option<&'a st

fn chomp_int(s: &str) -> Option<(usize, &str)> {
// Chomp until we hit a non-digit
let (num, t) = match s.find(|c: char| !c.is_digit(10)) {
let (num, t) = match s.find(|c: char| !c.is_ascii_digit()) {
Some(i) => s.split_at(i),
None => (s, ""),
};
Expand Down
Loading

0 comments on commit a301d25

Please sign in to comment.