Skip to content

Commit fb71d45

Browse files
Enable clippy, suppress lots, fix a couple. (#703)
This enables clippy in CI and suppresses most of the existing warnings. We can drill down and fix those later, but this will help start getting things under control.
1 parent 39a3955 commit fb71d45

File tree

14 files changed

+49
-7
lines changed

14 files changed

+49
-7
lines changed

.github/workflows/rust.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
env:
1212
CARGO_TERM_COLOR: always
13+
RUSTFLAGS: "-D warnings"
1314

1415
jobs:
1516
rustfmt:
@@ -46,6 +47,9 @@ jobs:
4647
run: cargo build --verbose
4748
- name: Run tests
4849
run: cargo test --verbose
50+
- name: Run clippy
51+
if: matrix.os == 'macos-14' && matrix.toolchain == 'stable'
52+
run: cargo clippy --all-targets --workspace
4953
typos:
5054
# If this fails, consider changing your text or adding something to .typos.toml
5155
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ license = "MIT OR Apache-2.0"
88
repository = "https://github.com/servo/core-foundation-rs"
99
rust-version = "1.65"
1010

11+
# TODO: Remove most of these by fixing the actual issues.
12+
[workspace.lints]
13+
clippy.assertions_on_constants = "allow"
14+
clippy.len_without_is_empty = "allow"
15+
clippy.manual_range_contains = "allow"
16+
clippy.missing_safety_doc = "allow"
17+
clippy.new_ret_no_self = "allow"
18+
clippy.new_without_default = "allow"
19+
clippy.non_canonical_partial_ord_impl = "allow"
20+
clippy.not_unsafe_ptr_arg_deref = "allow"
21+
clippy.result_unit_err = "allow"
22+
clippy.too_many_arguments = "allow"
23+
clippy.type_complexity = "allow"
24+
1125
[workspace.dependencies]
1226
cocoa-foundation = { default-features = false, path = "cocoa-foundation", version = "0.2" }
1327
core-foundation = { default-features = false, path = "core-foundation", version = "0.10" }

cocoa-foundation/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ rust-version.workspace = true
1212
[package.metadata.docs.rs]
1313
default-target = "x86_64-apple-darwin"
1414

15+
[lints]
16+
workspace = true
17+
1518
[dependencies]
1619
core-foundation.workspace = true
1720
core-graphics-types.workspace = true

cocoa-foundation/src/foundation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub type NSInteger = core::ffi::c_long;
2626
#[cfg(target_pointer_width = "64")]
2727
pub type NSUInteger = core::ffi::c_ulong;
2828

29-
pub const NSIntegerMax: NSInteger = NSInteger::max_value();
29+
pub const NSIntegerMax: NSInteger = NSInteger::MAX;
3030
pub const NSNotFound: NSInteger = NSIntegerMax;
3131

3232
const UTF8_ENCODING: usize = 4;

cocoa/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ rust-version.workspace = true
1212
[package.metadata.docs.rs]
1313
default-target = "x86_64-apple-darwin"
1414

15+
[lints]
16+
workspace = true
17+
1518
[dependencies]
1619
cocoa-foundation.workspace = true
1720
core-foundation.workspace = true

core-foundation-sys/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ rust-version.workspace = true
1313
all-features = true
1414
default-target = "x86_64-apple-darwin"
1515

16+
[lints]
17+
workspace = true
18+
1619
[dependencies]
1720

1821
[features]

core-foundation/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ rust-version.workspace = true
1616
all-features = true
1717
default-target = "x86_64-apple-darwin"
1818

19+
[lints]
20+
workspace = true
21+
1922
[dependencies]
2023
core-foundation-sys.workspace = true
2124

core-foundation/src/dictionary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ pub mod test {
471471
assert_eq!(mut_dict.retain_count(), 2);
472472
assert_eq!(dict.retain_count(), 2);
473473
assert_eq!(
474-
*dict.get(&CFString::from_static_string("Bar")),
474+
*dict.get(CFString::from_static_string("Bar")),
475475
CFBoolean::false_value()
476476
);
477477

core-graphics-types/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ rust-version.workspace = true
1212
[package.metadata.docs.rs]
1313
default-target = "x86_64-apple-darwin"
1414

15+
[lints]
16+
workspace = true
17+
1518
[dependencies]
1619
core-foundation.workspace = true
1720

core-graphics/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ rust-version.workspace = true
1313
all-features = true
1414
default-target = "x86_64-apple-darwin"
1515

16+
[lints]
17+
workspace = true
18+
1619
[dependencies]
1720
core-foundation.workspace = true
1821
core-graphics-types.workspace = true

0 commit comments

Comments
 (0)