From 40a3bded3638e008b1f9754c6418cd016156cc9d Mon Sep 17 00:00:00 2001 From: David Mak Date: Wed, 12 Jun 2024 12:27:35 +0800 Subject: [PATCH] meta: Set clippy lints in {main,lib}.rs So that this does not have to be manually passed to the `cargo clippy` command-line every single time. Also allows incrementally addressing these lints by removing and fixing them one-by-one. --- nac3artiq/src/lib.rs | 12 ++++++++++++ nac3ast/src/lib.rs | 15 +++++++++++++++ nac3core/src/codegen/expr.rs | 2 +- nac3core/src/codegen/stmt.rs | 2 +- nac3core/src/lib.rs | 18 ++++++++++++++++-- nac3ld/src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ nac3parser/src/lib.rs | 26 +++++++++++++++++++++++++- nac3standalone/src/main.rs | 9 +++++---- runkernel/src/main.rs | 4 ++++ 9 files changed, 114 insertions(+), 9 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 3263b4f6c..dfe7cefb7 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -1,3 +1,15 @@ +#![deny(clippy::all)] +#![warn(clippy::pedantic)] +#![allow( + clippy::cast_lossless, + clippy::cast_possible_truncation, + clippy::cast_sign_loss, + clippy::enum_glob_use, + clippy::similar_names, + clippy::too_many_lines, + clippy::wildcard_imports +)] + use std::collections::{HashMap, HashSet}; use std::fs; use std::io::Write; diff --git a/nac3ast/src/lib.rs b/nac3ast/src/lib.rs index 46259896c..be77530f5 100644 --- a/nac3ast/src/lib.rs +++ b/nac3ast/src/lib.rs @@ -1,3 +1,18 @@ +#![deny(clippy::all)] +#![warn(clippy::pedantic)] +#![allow( + clippy::cast_lossless, + clippy::default_trait_access, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::needless_pass_by_value, + clippy::too_many_lines, + clippy::uninlined_format_args, + clippy::wildcard_imports +)] + #[macro_use] extern crate lazy_static; diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 7a452032c..bc7195129 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -2367,7 +2367,7 @@ pub fn gen_expr<'ctx, G: CodeGenerator>( )) } Some(v) => Ok(Some(v)), - } + }; } ValueEnum::Dynamic(BasicValueEnum::PointerValue(ptr)) => { let not_null = diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index 0448cba1a..a83336ca5 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -1270,7 +1270,7 @@ pub fn gen_try<'ctx, 'a, G: CodeGenerator>( // run end_catch before continue/break/return let mut final_proxy_lambda = |ctx: &mut CodeGenContext<'ctx, 'a>, target: BasicBlock<'ctx>, block: BasicBlock<'ctx>| { - final_proxy(ctx, target, block, final_data.as_mut().unwrap()) + final_proxy(ctx, target, block, final_data.as_mut().unwrap()); }; let mut redirect_lambda = |ctx: &mut CodeGenContext<'ctx, 'a>, target: BasicBlock<'ctx>, block: BasicBlock<'ctx>| { diff --git a/nac3core/src/lib.rs b/nac3core/src/lib.rs index bff6b5cc8..68ed07f09 100644 --- a/nac3core/src/lib.rs +++ b/nac3core/src/lib.rs @@ -1,5 +1,19 @@ -#![warn(clippy::all)] -#![allow(dead_code)] +#![deny(clippy::all)] +#![warn(clippy::pedantic)] +#![allow( + dead_code, + clippy::cast_lossless, + clippy::cast_possible_truncation, + clippy::cast_sign_loss, + clippy::enum_glob_use, + clippy::implicit_hasher, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::similar_names, + clippy::too_many_lines, + clippy::wildcard_imports +)] pub mod codegen; pub mod symbol_resolver; diff --git a/nac3ld/src/lib.rs b/nac3ld/src/lib.rs index c6348e1fa..416c6ea24 100644 --- a/nac3ld/src/lib.rs +++ b/nac3ld/src/lib.rs @@ -1,3 +1,38 @@ +#![deny(clippy::all)] +#![warn(clippy::pedantic)] +#![allow( + clippy::borrow_as_ptr, + clippy::cast_lossless, + clippy::cast_possible_truncation, + clippy::cast_possible_wrap, + clippy::cast_ptr_alignment, + clippy::cast_sign_loss, + clippy::doc_markdown, + clippy::enum_glob_use, + clippy::explicit_iter_loop, + clippy::expl_impl_clone_on_copy, + clippy::items_after_statements, + clippy::manual_let_else, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::needless_pass_by_value, + clippy::ptr_as_ptr, + clippy::redundant_closure_call, + clippy::result_unit_err, + clippy::semicolon_if_nothing_returned, + clippy::similar_names, + clippy::stable_sort_primitive, + clippy::struct_field_names, + clippy::too_many_lines, + clippy::type_complexity, + clippy::unnecessary_wraps, + clippy::unnested_or_patterns, + clippy::unreadable_literal, + clippy::wildcard_imports +)] + use dwarf::*; use elf::*; use std::collections::HashMap; diff --git a/nac3parser/src/lib.rs b/nac3parser/src/lib.rs index 991cf3018..2a6cce9fa 100644 --- a/nac3parser/src/lib.rs +++ b/nac3parser/src/lib.rs @@ -15,6 +15,30 @@ //! //! ``` +#![deny(clippy::all)] +#![warn(clippy::pedantic)] +#![allow( + clippy::default_trait_access, + clippy::doc_markdown, + clippy::enum_glob_use, + clippy::fn_params_excessive_bools, + clippy::if_not_else, + clippy::implicit_clone, + clippy::match_same_arms, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions, + clippy::must_use_candidate, + clippy::redundant_closure_for_method_calls, + clippy::semicolon_if_nothing_returned, + clippy::single_match_else, + clippy::too_many_lines, + clippy::uninlined_format_args, + clippy::unnested_or_patterns, + clippy::unused_self, + clippy::wildcard_imports +)] + #[macro_use] extern crate log; use lalrpop_util::lalrpop_mod; @@ -27,7 +51,7 @@ pub mod lexer; pub mod mode; pub mod parser; lalrpop_mod!( - #[allow(clippy::all)] + #[allow(clippy::all, clippy::pedantic)] #[allow(unused)] python ); diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs index 349063f08..b15b9329d 100644 --- a/nac3standalone/src/main.rs +++ b/nac3standalone/src/main.rs @@ -1,3 +1,7 @@ +#![deny(clippy::all)] +#![warn(clippy::pedantic)] +#![allow(clippy::cast_possible_truncation, clippy::too_many_lines, clippy::wildcard_imports)] + use clap::Parser; use inkwell::{ memory_buffer::MemoryBuffer, passes::PassBuilderOptions, support::is_multithreaded, targets::*, @@ -310,10 +314,7 @@ fn main() { StmtKind::ImportFrom { module, names, .. } if module == &Some("__future__".into()) && names.len() == 1 - && names[0].name == "annotations".into() => - { - () - } + && names[0].name == "annotations".into() => {} _ => { let (name, def_id, ty) = composer .register_top_level(stmt, Some(resolver.clone()), "__main__", true) diff --git a/runkernel/src/main.rs b/runkernel/src/main.rs index 8c6d2d181..d7f4eea69 100644 --- a/runkernel/src/main.rs +++ b/runkernel/src/main.rs @@ -1,3 +1,7 @@ +#![deny(clippy::all)] +#![warn(clippy::pedantic)] +#![allow(clippy::semicolon_if_nothing_returned, clippy::uninlined_format_args)] + use std::env; static mut NOW: i64 = 0;