Skip to content

Commit 43f22a8

Browse files
authored
Fix all remaining clippy lints (model-checking#1466)
1 parent ecc410d commit 43f22a8

File tree

13 files changed

+20
-32
lines changed

13 files changed

+20
-32
lines changed

.cargo/config.toml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,5 @@ rustflags = [ # Global lints/warnings. Need to use underscore instead of -.
77
# Purposefully disabled lints
88
"-Aclippy::expect_fun_call",
99
"-Aclippy::or_fun_call",
10-
11-
# todo address the following lints.
12-
"-Aclippy::derive_partial_eq_without_eq",
13-
"-Aclippy::manual_map",
14-
"-Aclippy::manual_range_contains",
15-
"-Aclippy::map_entry",
16-
"-Aclippy::missing_safety_doc",
17-
"-Aclippy::module_inception",
18-
"-Aclippy::new_ret_no_self",
1910
"-Aclippy::new_without_default",
20-
"-Aclippy::too_many_arguments",
21-
"-Aclippy::type_complexity",
2211
]

cprover_bindings/src/goto_program/typ.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,8 @@ impl Type {
781781
&self,
782782
st: &'a SymbolTable,
783783
) -> Option<Vec<&'a DatatypeComponent>> {
784-
if let Some(components) = self.lookup_components(st) {
785-
Some(components.iter().filter(|x| x.sizeof_in_bits(st) != 0).collect())
786-
} else {
787-
None
788-
}
784+
self.lookup_components(st)
785+
.map(|components| components.iter().filter(|x| x.sizeof_in_bits(st) != 0).collect())
789786
}
790787

791788
/// Calculates an under-approximation of whether two types are structurally equivalent.

cprover_bindings/src/irep/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! TODO: Parser for json symbol tables into the internal irep format
1515
//! TODO: Investigate memory usage, and consider using sharing to reduce memory usage
1616
17+
#[allow(clippy::module_inception)]
1718
mod irep;
1819
mod irep_id;
1920
pub mod serialize;

kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,10 @@ impl<'tcx> GotocCtx<'tcx> {
713713
let normalized = self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty);
714714
let goto_typ = self.codegen_ty_inner(normalized);
715715
if let Some(tag) = goto_typ.tag() {
716-
if !self.type_map.contains_key(&tag) {
716+
self.type_map.entry(tag).or_insert_with(|| {
717717
debug!(mir_type=?normalized, gotoc_name=?tag, ?goto_typ, "codegen_ty: new type");
718-
self.type_map.insert(tag, normalized);
719-
}
718+
normalized
719+
});
720720
}
721721
goto_typ
722722
}

kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub struct GotocCodegenBackend {
3737
}
3838

3939
impl GotocCodegenBackend {
40-
pub fn new(queries: &Rc<QueryDb>) -> Box<dyn CodegenBackend> {
41-
Box::new(GotocCodegenBackend { queries: Rc::clone(queries) })
40+
pub fn new(queries: &Rc<QueryDb>) -> Self {
41+
GotocCodegenBackend { queries: Rc::clone(queries) }
4242
}
4343
}
4444

kani-compiler/src/codegen_cprover_gotoc/utils/debug.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub fn init() {
2424
LazyLock::force(&DEFAULT_HOOK); // Install ice hook
2525
}
2626

27-
// Custom panic hook to add more information when panic occurs during goto-c codegen.
27+
/// Custom panic hook to add more information when panic occurs during goto-c codegen.
28+
#[allow(clippy::type_complexity)]
2829
static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
2930
LazyLock::new(|| {
3031
let hook = panic::take_hook();

kani-compiler/src/codegen_cprover_gotoc/utils/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
mod debug;
77
mod names;
8+
#[allow(clippy::module_inception)]
89
mod utils;
910

1011
// TODO clean this up

kani-compiler/src/codegen_cprover_gotoc/utils/utils.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ impl<'tcx> GotocCtx<'tcx> {
5757
// Save this occurrence so we can emit a warning in the compilation report.
5858
debug!("codegen_unimplemented: {} at {}", operation_name, loc.short_string());
5959
let key: InternedString = operation_name.into();
60-
if !self.unsupported_constructs.contains_key(&key) {
61-
self.unsupported_constructs.insert(key, Vec::new());
62-
}
63-
self.unsupported_constructs.get_mut(&key).unwrap().push(loc);
60+
self.unsupported_constructs.entry(key).or_insert_with(Vec::new).push(loc);
6461

6562
let body = vec![
6663
// Assert false to alert the user that there is a path that uses an unimplemented feature.

kani-compiler/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn main() -> Result<(), &'static str> {
100100
if matches.is_present("goto-c") {
101101
if cfg!(feature = "cprover") {
102102
compiler.set_make_codegen_backend(Some(Box::new(move |_cfg| {
103-
codegen_cprover_gotoc::GotocCodegenBackend::new(&Rc::new(queries))
103+
Box::new(codegen_cprover_gotoc::GotocCodegenBackend::new(&Rc::new(queries)))
104104
})));
105105
} else {
106106
return Err("Kani was configured without 'cprover' feature. You must enable this \

kani-compiler/src/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const BUG_REPORT_URL: &str =
1919
"https://github.com/model-checking/kani/issues/new?labels=bug&template=bug_report.md";
2020

2121
// Custom panic hook.
22+
#[allow(clippy::type_complexity)]
2223
static PANIC_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
2324
LazyLock::new(|| {
2425
let hook = panic::take_hook();

0 commit comments

Comments
 (0)