Skip to content

Commit 542f7c4

Browse files
author
Yoshiki Takashima
authored
Clippy in Regressions. (rust-lang#1403)
* Added jq for json querying. * Added clippy to regression. * Added error ignore and todo to kani-compiler. * Added clippy todo to cprover_bindings. * Forced failure on warnings (Werror for clippy). * Added clippy todo to compiletest. * Clippy supression for bookrunner. * Resolved metadata warnings with publish = false. * Clippy todo for kani library. * Clippy todos and publish fix for kani_macros. * Cargo fmt. * Temporally turned off clippy fail. * Moved clippy to format checks. * Moved clippy to the format check. * Added missing dependency. * Fixed yaml overwrite problem. * Gather stats on clippy warnings. * jq install for osx not needed. * Moved clippy control to a central config file. * Fixed clippy warnings under library/ * Adjusted actions to print stats by removing lint supression. * Ignored 3 clippy warnings that regressed after merge. * Forgot to remove manual -A * got rid of redundant allowed lints. * Moved jq install to workflow side. * removed .cargo from gitignore
1 parent 9f20e84 commit 542f7c4

File tree

18 files changed

+83
-6
lines changed

18 files changed

+83
-6
lines changed

.cargo/config.toml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
[target.'cfg(all())']
5+
rustflags = [ # Global lints/warnings. Need to use underscore instead of -.
6+
7+
# Purposefully disabled lints
8+
"-Aclippy::expect_fun_call",
9+
"-Aclippy::or_fun_call",
10+
11+
# todo address the following lints.
12+
"-Aclippy::cargo_common_metadata",
13+
"-Aclippy::derive_partial_eq_without_eq",
14+
"-Aclippy::explicit_auto_deref",
15+
"-Aclippy::if_same_then_else",
16+
"-Aclippy::iter_nth_zero",
17+
"-Aclippy::let_and_return",
18+
"-Aclippy::manual_map",
19+
"-Aclippy::manual_range_contains",
20+
"-Aclippy::manual_strip",
21+
"-Aclippy::map_entry",
22+
"-Aclippy::match_like_matches_macro",
23+
"-Aclippy::missing_safety_doc",
24+
"-Aclippy::module_inception",
25+
"-Aclippy::needless_arbitrary_self_type",
26+
"-Aclippy::needless_bool",
27+
"-Aclippy::needless_return",
28+
"-Aclippy::new_ret_no_self",
29+
"-Aclippy::new_without_default",
30+
"-Aclippy::redundant_clone",
31+
"-Aclippy::too_many_arguments",
32+
"-Aclippy::type_complexity",
33+
"-Aclippy::unnecessary_lazy_evaluations",
34+
"-Aclippy::useless_conversion",
35+
"-Aclippy::needless_borrow",
36+
"-Aclippy::unnecessary_filter_map",
37+
]

.github/workflows/format-check.yml

+26
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,29 @@ jobs:
2020
run: |
2121
pip3 install --upgrade autopep8
2222
./scripts/run-autopep8.sh
23+
24+
clippy-check:
25+
runs-on: ubuntu-20.04
26+
steps:
27+
- name: Checkout Kani
28+
uses: actions/checkout@v2
29+
30+
- name: Setup Kani Dependencies
31+
uses: ./.github/actions/setup
32+
with:
33+
os: ubuntu-20.04
34+
35+
- name: "Install jq for parsing."
36+
run: |
37+
sudo apt-get install -y jq
38+
39+
- name: "Run Clippy"
40+
run: |
41+
cargo clippy --all -- -D warnings
42+
43+
- name: "Print Clippy Statistics"
44+
run: |
45+
rm .cargo/config.toml
46+
(cargo clippy --all --message-format=json 2>/dev/null | \
47+
jq 'select(.message!=null) | .message.code.code' | grep -v '^null$' | \
48+
sort | uniq -c) || true

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ Session.vim
2424

2525
## Tool
2626
.valgrindrc
27-
.cargo
28-
# Included because it is part of the test case
29-
!/test/run-make/thumb-none-qemu/example/.cargo
3027

3128
## Configuration
3229
/config.toml

cprover_bindings/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name = "cprover_bindings"
66
version = "0.6.0"
77
edition = "2021"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
[lib]
1112
test = true

kani-compiler/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name = "kani-compiler"
66
version = "0.6.0"
77
edition = "2021"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
[dependencies]
1112
ar = { version = "0.9.0", optional = true }

kani-compiler/kani_queries/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name = "kani_queries"
66
version = "0.6.0"
77
edition = "2021"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
[dependencies]
1112
tracing = {version = "0.1"}

kani-driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description = "Build a project with Kani and run all proof harnesses"
99
license = "MIT OR Apache-2.0"
1010
homepage = "https://github.com/model-checking/kani"
1111
repository = "https://github.com/model-checking/kani"
12+
publish = false
1213

1314
[dependencies]
1415
kani_metadata = { path = "../kani_metadata" }

kani_metadata/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name = "kani_metadata"
66
version = "0.6.0"
77
edition = "2021"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1112

library/kani/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name = "kani"
66
version = "0.6.0"
77
edition = "2021"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
[dependencies]
1112
kani_macros = { path = "../kani_macros" }

library/kani/src/invariant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ unsafe impl Invariant for char {
6767
fn is_valid(&self) -> bool {
6868
// Kani translates char into i32.
6969
let val = *self as i32;
70-
val <= 0xD7FF || (val >= 0xE000 && val <= 0x10FFFF)
70+
val <= 0xD7FF || (0xE000..=0x10FFFF).contains(&val)
7171
}
7272
}
7373

library/kani/src/slice.rs

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ where
149149
AnySlice::<T, MAX_SLICE_LENGTH>::new()
150150
}
151151

152+
/// # Safety
153+
///
154+
/// TODO: Safety of any_raw_slice is a complex matter. See
155+
/// https://github.com/model-checking/kani/issues/1394
152156
pub unsafe fn any_raw_slice<T, const MAX_SLICE_LENGTH: usize>() -> AnySlice<T, MAX_SLICE_LENGTH> {
153157
AnySlice::<T, MAX_SLICE_LENGTH>::new_raw()
154158
}

library/kani_macros/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name = "kani_macros"
66
version = "0.6.0"
77
edition = "2021"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
[lib]
1112
proc-macro = true

library/kani_macros/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn proof(_attr: TokenStream, item: TokenStream) -> TokenStream {
3939
pub fn proof(attr: TokenStream, item: TokenStream) -> TokenStream {
4040
let mut result = TokenStream::new();
4141

42-
assert!(attr.to_string().len() == 0, "#[kani::proof] does not take any arguments");
42+
assert!(attr.to_string().is_empty(), "#[kani::proof] does not take any arguments");
4343
result.extend("#[kanitool::proof]".parse::<TokenStream>().unwrap());
4444
// no_mangle is a temporary hack to make the function "public" so it gets codegen'd
4545
result.extend("#[no_mangle]".parse::<TokenStream>().unwrap());
@@ -67,7 +67,7 @@ pub fn unwind(attr: TokenStream, item: TokenStream) -> TokenStream {
6767
let mut result = TokenStream::new();
6868

6969
// Translate #[kani::unwind(arg)] to #[kanitool::unwind(arg)]
70-
let insert_string = "#[kanitool::unwind(".to_owned() + &attr.clone().to_string() + ")]";
70+
let insert_string = "#[kanitool::unwind(".to_owned() + &attr.to_string() + ")]";
7171
result.extend(insert_string.parse::<TokenStream>().unwrap());
7272

7373
result.extend(item);

library/std/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ name = "std"
88
version = "0.6.0"
99
edition = "2021"
1010
license = "MIT OR Apache-2.0"
11+
publish = false
1112

1213
[dependencies]
1314
kani = {path="../kani"}

tools/bookrunner/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name = "bookrunner"
66
version = "0.1.0"
77
edition = "2018"
88
license = "MIT OR Apache-2.0"
9+
publish = false
910

1011
[dependencies]
1112
Inflector = "0.11.4"

tools/bookrunner/librustdoc/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ name = "rustdoc"
77
version = "0.0.0"
88
edition = "2021"
99
license = "MIT OR Apache-2.0"
10+
publish = false
11+
1012
# From upstream librustdoc:
1113
# https://github.com/rust-lang/rust/tree/master/src/librustdoc
1214
# Upstream crate does not list license but Rust statues:

tools/compiletest/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ name = "compiletest"
88
version = "0.0.0"
99
edition = "2021"
1010
license = "MIT OR Apache-2.0"
11+
publish = false
1112
# From upstream compiletest:
1213
# https://github.com/rust-lang/rust/tree/master/src/tools/compiletest
1314
# Upstream crate does not list license but Rust statues:

tools/make-kani-release/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.1.0"
77
edition = "2021"
88
description = "Contructs a Kani release bundle"
99
license = "MIT OR Apache-2.0"
10+
publish = false
1011

1112
[dependencies]
1213
anyhow = "1"

0 commit comments

Comments
 (0)