Skip to content

Commit a301d25

Browse files
authored
Merge pull request #169 from madsmtm/clippy
Run clippy in CI
2 parents 73983a0 + cf75986 commit a301d25

27 files changed

+152
-113
lines changed

.github/workflows/ci.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
rust:
6868
toolchain: nightly
6969
target: x86_64-apple-darwin
70-
components: rust-src
70+
components: clippy, rust-src
7171
args: -Zbuild-std -Zdoctest-xcompile
7272
# 32-bit support was removed in 10.15, so we can't test the
7373
# binary, only build it
@@ -114,7 +114,7 @@ jobs:
114114
rust:
115115
toolchain: nightly
116116
target: x86_64-apple-darwin
117-
components: rust-src
117+
components: clippy, rust-src
118118
args: -Zbuild-std -Zdoctest-xcompile
119119
test-args: --no-run
120120
- name: Build iOS ARMv7s
@@ -123,7 +123,7 @@ jobs:
123123
rust:
124124
toolchain: nightly
125125
target: x86_64-apple-darwin
126-
components: rust-src
126+
components: clippy, rust-src
127127
args: -Zbuild-std -Zdoctest-xcompile
128128
test-args: --no-run
129129
- name: Build iOS 32bit x86
@@ -132,7 +132,7 @@ jobs:
132132
rust:
133133
toolchain: nightly
134134
target: x86_64-apple-darwin
135-
components: rust-src
135+
components: clippy, rust-src
136136
args: -Zbuild-std -Zdoctest-xcompile
137137
test-args: --no-run
138138
- name: Test Compiler-RT
@@ -302,7 +302,7 @@ jobs:
302302
toolchain: ${{ matrix.rust.toolchain || 'stable' }}
303303
profile: minimal
304304
override: true
305-
components: ${{ matrix.rust.components }}
305+
components: ${{ matrix.rust.components || 'clippy' }}
306306
# Allows installing for a different base target
307307
target: ${{ matrix.rust.target || matrix.target }}
308308

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

315+
- name: Lint
316+
uses: actions-rs/cargo@v1
317+
with:
318+
command: clippy
319+
# Temporarily allow `clippy::let_unit_value`
320+
args: ${{ env.ARGS }} --all-targets -- --deny warnings --allow clippy::let_unit_value
321+
315322
- name: Build
316323
if: ${{ !matrix.dinghy }}
317324
uses: actions-rs/cargo@v1

block-sys/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
// See https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html.
1414

1515
#![no_std]
16+
#![warn(elided_lifetimes_in_paths)]
17+
#![deny(non_ascii_idents)]
18+
#![warn(unreachable_pub)]
19+
#![deny(unsafe_op_in_unsafe_fn)]
20+
#![warn(clippy::cargo)]
21+
#![warn(clippy::ptr_as_ptr)]
1622
// Update in Cargo.toml as well.
1723
#![doc(html_root_url = "https://docs.rs/block-sys/0.0.4")]
1824

block2/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
#![deny(non_ascii_idents)]
8181
#![warn(unreachable_pub)]
8282
#![deny(unsafe_op_in_unsafe_fn)]
83+
#![warn(clippy::cargo)]
84+
#![warn(clippy::ptr_as_ptr)]
8385
// Update in Cargo.toml as well.
8486
#![doc(html_root_url = "https://docs.rs/block2/0.2.0-alpha.4")]
8587

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

183190
unsafe impl<A: BlockArguments + EncodeArguments, R: Encode> RefEncode for Block<A, R> {

objc-sys/src/constants.rs

+2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ use std::os::raw::c_int;
66
use crate::{id, objc_class, BOOL};
77

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

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

1416
/// A quick alias for a [`null_mut`][`core::ptr::null_mut`] object / instance.

objc-sys/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
//! [objc4]: https://github.com/apple-oss-distributions/objc4
1515
1616
#![no_std]
17+
#![warn(elided_lifetimes_in_paths)]
18+
#![deny(non_ascii_idents)]
19+
#![warn(unreachable_pub)]
20+
#![deny(unsafe_op_in_unsafe_fn)]
21+
#![warn(clippy::cargo)]
22+
#![warn(clippy::ptr_as_ptr)]
1723
#![allow(clippy::upper_case_acronyms)]
1824
#![allow(non_camel_case_types)]
1925
#![allow(non_upper_case_globals)]

objc-sys/src/types.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod inner {
2121
target_os = "watchos",
2222
))]
2323
// C: _Bool
24-
pub type BOOL = bool;
24+
pub(crate) type BOOL = bool;
2525

2626
// Inverse of the above
2727
#[cfg(not(any(
@@ -31,26 +31,26 @@ mod inner {
3131
target_os = "watchos",
3232
)))]
3333
// C: (explicitly) signed char
34-
pub type BOOL = i8;
34+
pub(crate) type BOOL = i8;
3535
}
3636

3737
// GNUStep's and Microsoft's libobjc2
3838
#[cfg(all(gnustep, libobjc2_strict_apple_compat))]
3939
mod inner {
4040
// C: (explicitly) signed char
41-
pub type BOOL = i8;
41+
pub(crate) type BOOL = i8;
4242
}
4343

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

5050
// The inverse
5151
#[cfg(not(all(windows, not(all(target_pointer_width = "64", target_env = "gnu")))))]
5252
// C: unsigned char
53-
pub type BOOL = u8;
53+
pub(crate) type BOOL = u8;
5454
}
5555

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

6464
// Note that ObjFW uses `bool` in return types, but that doesn't change
6565
// the ABI, so we'll just use `BOOL` there for ease of use.

objc2-encode/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
#![deny(non_ascii_idents)]
9191
#![warn(unreachable_pub)]
9292
#![deny(unsafe_op_in_unsafe_fn)]
93+
#![warn(clippy::cargo)]
94+
#![warn(clippy::ptr_as_ptr)]
9395
// Update in Cargo.toml as well.
9496
#![doc(html_root_url = "https://docs.rs/objc2-encode/2.0.0-pre.0")]
9597

objc2-encode/src/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub(crate) fn rm_enc_prefix<'a>(s: &'a str, enc: &Encoding<'_>) -> Option<&'a st
8383

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

0 commit comments

Comments
 (0)