Skip to content

Commit e70b031

Browse files
nyuriktgross35
authored andcommitted
chore: add clippy CI tests
run cargo clippy for all targets (backport <#4411>) (cherry picked from commit bea4d1b)
1 parent ccdcaff commit e70b031

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,25 @@ members = [
150150
"ctest",
151151
"libc-test",
152152
]
153+
154+
#
155+
# TODO: These should be renamed as `[workspace.lints.*]` once MSRV is abve 1.64
156+
# This way all crates can use it with `[lints] workspace=true` section
157+
#
158+
159+
[lints.rust]
160+
# TODO: make ident usage consistent in each file
161+
unused_qualifications = "allow"
162+
163+
[lints.clippy]
164+
# TODO: all these are default lints and should probably be fixed
165+
identity_op = "allow"
166+
if_same_then_else = "allow"
167+
missing_safety_doc = "allow"
168+
non_minimal_cfg = "allow"
169+
precedence = "allow"
170+
redundant_field_names = "allow"
171+
redundant_static_lifetimes = "allow"
172+
unnecessary_cast = "allow"
173+
unused_unit = "allow"
174+
zero_ptr = "allow"

ci/style.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -eux
44

55
[ -n "${CI:-}" ] && check="--check"
66

7+
# TODO: for some reason using `--workspace` validates a lot of generated code in ./target/** dir
8+
cargo clippy -p libc@1.0.0-alpha.1 -p ctest --all-targets -- -D warnings
9+
710
cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture
811

912
command -v rustfmt

ci/verify-build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ test_target() {
4444
# The basic command that is run each time
4545
cmd="cargo +$rust build --target $target"
4646

47+
# The basic clippy command
48+
clippy_cmd="cargo +$rust clippy --all-targets --target $target"
49+
4750
if [ "${no_dist}" != "0" ]; then
4851
# If we can't download a `core`, we need to build it
4952
cmd="$cmd -Zbuild-std=core,alloc"
53+
clippy_cmd="$clippy_cmd -Zbuild-std=core,alloc"
5054

5155
# FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
5256
RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions"
@@ -67,6 +71,9 @@ test_target() {
6771
done
6872
fi
6973

74+
# Run cargo clippy first
75+
$clippy_cmd
76+
7077
# Test with expected combinations of features
7178
$cmd
7279
$cmd --features const-extern-fn

libc-test/Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,26 @@ harness = true
104104
name = "style_tests"
105105
path = "test/style_tests.rs"
106106
harness = true
107+
108+
#
109+
# TODO: These should be moved to the root Cargo.toml as `[workspace.lints.*]` once MSRV is abve 1.64
110+
# replace it with `[lints] workspace=true`
111+
#
112+
113+
[lints.rust]
114+
# TODO: make ident usage consistent in each file
115+
unused_qualifications = "allow"
116+
117+
[lints.clippy]
118+
# TODO: fix these, and enable pedantic lints with needed exceptions
119+
needless_return = "allow"
120+
comparison_to_empty = "allow"
121+
unused_io_amount = "allow"
122+
write_with_newline = "allow"
123+
needless_borrows_for_generic_args = "allow"
124+
only_used_in_recursion = "allow"
125+
match_like_matches_macro = "allow"
126+
useless_format = "allow"
127+
wildcard_in_or_patterns = "allow"
128+
nonminimal_bool = "allow"
129+
match_single_binding = "allow"

0 commit comments

Comments
 (0)