From 7c4b1fdf70884b93d927d8a6589076c2d33765e1 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 4 Sep 2021 18:09:14 +0100 Subject: [PATCH 01/21] no more clippy slippage --- .gitlab-ci.yml | 9 ++++ lints.toml | 126 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 lints.toml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98b29fa65e374..351bdb404eeb8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -268,6 +268,15 @@ cargo-fmt: - cargo +nightly fmt --all -- --check allow_failure: true +cargo-clippy: + stage: test + <<: *docker-env + <<: *test-refs + script: + - cargo +nightly install cargo-lints + - cargo +nightly lints clippy + allow_failure: true + cargo-check-benches: stage: test <<: *docker-env diff --git a/lints.toml b/lints.toml new file mode 100644 index 0000000000000..5c5533e64432c --- /dev/null +++ b/lints.toml @@ -0,0 +1,126 @@ +# +# For all clippy lints please visit: https://rust-lang.github.io/rust-clippy/master/ +# +allow = [ + # lints we choose not to enforce: + "clippy::zero_prefixed_literal", + "clippy::tabs_in_doc_comments", + "clippy::type_complexity", + + # allow a few lints we've not fixed yet: + # Feel free to raise a PR removing one of these + # (but you will need to fixup the code too!) + "clippy::large_enum_variant", + "clippy::needless_lifetimes", + "clippy::collapsible_if", + "clippy::needless_return", + "clippy::new_without_default", + "clippy::borrowed_box", + "clippy::assign_op_pattern", + "clippy::clone_on_copy", + "clippy::collapsible_else_if", + "clippy::comparison_chain", + "clippy::drop_copy", + "clippy::enum_variant_names", + "clippy::extra_unused_lifetimes", + "clippy::from_over_into", + "clippy::identity_op", + "clippy::into_iter_on_ref", + "clippy::len_without_is_empty", + "clippy::len_zero", + "clippy::let_and_return", + "clippy::many_single_char_names", + "clippy::map_collect_result_unit", + "clippy::match_like_matches_macro", + "clippy::match_ref_pats", + "clippy::mem_replace_with_default", + "clippy::module_inception", + "clippy::mut_from_ref", + "clippy::needless_borrow", + "clippy::needless_collect", + "clippy::needless_doctest_main", + "clippy::needless_range_loop", + "clippy::new_ret_no_self", + "clippy::bind_instead_of_map", + "clippy::comparison_to_empty", + "clippy::nonminimal_bool", + "clippy::single_match", + "clippy::option_as_ref_deref", + "clippy::map_entry", + "clippy::bool_comparison", + "clippy::explicit_counter_loop", + "clippy::clone_double_ref", + "clippy::blacklisted_name", + "clippy::cmp_owned", + "clippy::filter_map_identity", + "clippy::double_must_use", + "clippy::redundant_pattern", + "clippy::eval_order_dependence", + "clippy::from_str_radix_10", + "clippy::clone_double_ref", + "clippy::cmp_owned", + "clippy::redundant_field_names", + "clippy::useless_format", + "clippy::iter_next_slice", + "clippy::blocks_in_if_conditions", + "clippy::if_let_some_result", + "clippy::expect_fun_call", + "clippy::needless_update", + "clippy::manual_strip", + "clippy::print_with_newline", + "clippy::manual_flatten", + "clippy::string_extend_chars", + "clippy::match_overlapping_arm", + "clippy::iter_nth_zero", + "clippy::filter_next", + "clippy::blocks_in_if_conditions", + "clippy::skip_while_next", + "clippy::boxed_local", + "clippy::manual_saturating_arithmetic", + "clippy::unnecessary_filter_map", + "clippy::write_literal", + "clippy::iter_cloned_collect", + "clippy::derive_hash_xor_eq", + "clippy::if_same_then_else", + "clippy::unwrap_or_else_default", + "clippy::unit_arg", + "clippy::op_ref", + "clippy::field_reassign_with_default", + "clippy::needless_question_mark", + "clippy::map_clone", + "clippy::option_map_unit_fn", + "clippy::or_fun_call", + "clippy::int_plus_one", + "clippy::println_empty_string", + "clippy::ptr_arg", + "clippy::deref_addrof", + "clippy::redundant_clone", + "clippy::redundant_closure", + "clippy::redundant_pattern_matching", + "clippy::redundant_slicing", + "clippy::redundant_static_lifetimes", + "clippy::result_unit_err", + "clippy::search_is_some", + "clippy::should_implement_trait", + "clippy::single_char_add_str", + "clippy::single_component_path_imports", + "clippy::stable_sort_primitive", + "clippy::suspicious_else_formatting", + "clippy::too_many_arguments", + "clippy::try_err", + "clippy::unnecessary_lazy_evaluations", + "clippy::unnecessary_unwrap", + "clippy::unnecessary_mut_passed", + "clippy::unnecessary_cast", + "clippy::unused_unit", + "clippy::unusual_byte_groupings", + "clippy::useless_asref", + "clippy::useless_conversion", + "clippy::vec_init_then_push", + "clippy::while_let_on_iterator", + "clippy::writeln_empty_string", + "clippy::wrong_self_convention" +] +deny = [ +] +warn = [] From ea7eb3839738d3d5eaab2a100bcc6db99e6873b7 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 4 Sep 2021 18:19:53 +0100 Subject: [PATCH 02/21] For testing include clippy explicitly --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 351bdb404eeb8..0b8a3d4de7aba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -273,6 +273,7 @@ cargo-clippy: <<: *docker-env <<: *test-refs script: + - rustup +nightly component add clippy - cargo +nightly install cargo-lints - cargo +nightly lints clippy allow_failure: true From e3ad2915acf5c9ea8533a9db7127277d78017d3a Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 4 Sep 2021 19:41:50 +0100 Subject: [PATCH 03/21] Commenting out new lint CI doesn't know about it yet. --- lints.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lints.toml b/lints.toml index 5c5533e64432c..c424740f68a54 100644 --- a/lints.toml +++ b/lints.toml @@ -82,7 +82,7 @@ allow = [ "clippy::iter_cloned_collect", "clippy::derive_hash_xor_eq", "clippy::if_same_then_else", - "clippy::unwrap_or_else_default", + #"clippy::unwrap_or_else_default", "clippy::unit_arg", "clippy::op_ref", "clippy::field_reassign_with_default", From 9289226f4b156895d72513d6514e7e9280d741d7 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 4 Sep 2021 21:26:05 +0100 Subject: [PATCH 04/21] Add instructions --- lints.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lints.toml b/lints.toml index c424740f68a54..b2cba802e4f25 100644 --- a/lints.toml +++ b/lints.toml @@ -1,4 +1,9 @@ # +# To run these specific lints run: +# +# cargo install cargo-lints +# cargo lints clippy +# # For all clippy lints please visit: https://rust-lang.github.io/rust-clippy/master/ # allow = [ From 3de24696efd61df8f414a5bcc78f4644e447f602 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sun, 19 Sep 2021 12:46:00 +0100 Subject: [PATCH 05/21] Remove need for cargo-lints --- .gitlab-ci.yml | 3 +- .maintain/clippy.sh | 120 ++++++++++++++++++++++++++++++++++++++++ lints.toml | 131 -------------------------------------------- 3 files changed, 121 insertions(+), 133 deletions(-) create mode 100755 .maintain/clippy.sh delete mode 100644 lints.toml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b8a3d4de7aba..7547631fa1ae7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -274,8 +274,7 @@ cargo-clippy: <<: *test-refs script: - rustup +nightly component add clippy - - cargo +nightly install cargo-lints - - cargo +nightly lints clippy + - ./.maintain/clippy.sh allow_failure: true cargo-check-benches: diff --git a/.maintain/clippy.sh b/.maintain/clippy.sh new file mode 100755 index 0000000000000..8e4ec55775c6b --- /dev/null +++ b/.maintain/clippy.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env sh + +# Script for building only the WASM binary of the given project. + +set -e + +# +nightly +SKIP_WASM_BUILD=1 cargo clippy -- \ +-A clippy::zero_prefixed_literal \ +-A clippy::tabs_in_doc_comments \ +-A clippy::type_complexity \ +-A clippy::large_enum_variant \ +-A clippy::needless_lifetimes \ +-A clippy::collapsible_if \ +-A clippy::needless_return \ +-A clippy::new_without_default \ +-A clippy::borrowed_box \ +-A clippy::assign_op_pattern \ +-A clippy::clone_on_copy \ +-A clippy::collapsible_else_if \ +-A clippy::comparison_chain \ +-A clippy::drop_copy \ +-A clippy::enum_variant_names \ +-A clippy::extra_unused_lifetimes \ +-A clippy::from_over_into \ +-A clippy::identity_op \ +-A clippy::into_iter_on_ref \ +-A clippy::len_without_is_empty \ +-A clippy::len_zero \ +-A clippy::let_and_return \ +-A clippy::many_single_char_names \ +-A clippy::map_collect_result_unit \ +-A clippy::match_like_matches_macro \ +-A clippy::match_ref_pats \ +-A clippy::mem_replace_with_default \ +-A clippy::module_inception \ +-A clippy::mut_from_ref \ +-A clippy::needless_borrow \ +-A clippy::needless_collect \ +-A clippy::needless_doctest_main \ +-A clippy::needless_range_loop \ +-A clippy::new_ret_no_self \ +-A clippy::bind_instead_of_map \ +-A clippy::comparison_to_empty \ +-A clippy::nonminimal_bool \ +-A clippy::single_match \ +-A clippy::option_as_ref_deref \ +-A clippy::map_entry \ +-A clippy::bool_comparison \ +-A clippy::explicit_counter_loop \ +-A clippy::clone_double_ref \ +-A clippy::blacklisted_name \ +-A clippy::cmp_owned \ +-A clippy::filter_map_identity \ +-A clippy::double_must_use \ +-A clippy::redundant_pattern \ +-A clippy::eval_order_dependence \ +-A clippy::from_str_radix_10 \ +-A clippy::clone_double_ref \ +-A clippy::cmp_owned \ +-A clippy::redundant_field_names \ +-A clippy::useless_format \ +-A clippy::iter_next_slice \ +-A clippy::blocks_in_if_conditions \ +-A clippy::if_let_some_result \ +-A clippy::expect_fun_call \ +-A clippy::needless_update \ +-A clippy::manual_strip \ +-A clippy::print_with_newline \ +-A clippy::manual_flatten \ +-A clippy::string_extend_chars \ +-A clippy::match_overlapping_arm \ +-A clippy::iter_nth_zero \ +-A clippy::filter_next \ +-A clippy::blocks_in_if_conditions \ +-A clippy::skip_while_next \ +-A clippy::boxed_local \ +-A clippy::manual_saturating_arithmetic \ +-A clippy::unnecessary_filter_map \ +-A clippy::write_literal \ +-A clippy::iter_cloned_collect \ +-A clippy::derive_hash_xor_eq \ +-A clippy::if_same_then_else \ +-A clippy::unit_arg \ +-A clippy::op_ref \ +-A clippy::field_reassign_with_default \ +-A clippy::needless_question_mark \ +-A clippy::map_clone \ +-A clippy::option_map_unit_fn \ +-A clippy::or_fun_call \ +-A clippy::int_plus_one \ +-A clippy::println_empty_string \ +-A clippy::ptr_arg \ +-A clippy::deref_addrof \ +-A clippy::redundant_clone \ +-A clippy::redundant_closure \ +-A clippy::redundant_pattern_matching \ +-A clippy::redundant_slicing \ +-A clippy::redundant_static_lifetimes \ +-A clippy::result_unit_err \ +-A clippy::search_is_some \ +-A clippy::should_implement_trait \ +-A clippy::single_char_add_str \ +-A clippy::single_component_path_imports \ +-A clippy::stable_sort_primitive \ +-A clippy::suspicious_else_formatting \ +-A clippy::too_many_arguments \ +-A clippy::try_err \ +-A clippy::unnecessary_lazy_evaluations \ +-A clippy::unnecessary_unwrap \ +-A clippy::unnecessary_mut_passed \ +-A clippy::unnecessary_cast \ +-A clippy::unused_unit \ +-A clippy::unusual_byte_groupings \ +-A clippy::useless_asref \ +-A clippy::useless_conversion \ +-A clippy::vec_init_then_push \ +-A clippy::while_let_on_iterator \ +-A clippy::writeln_empty_string \ +-A clippy::wrong_self_convention \ No newline at end of file diff --git a/lints.toml b/lints.toml deleted file mode 100644 index b2cba802e4f25..0000000000000 --- a/lints.toml +++ /dev/null @@ -1,131 +0,0 @@ -# -# To run these specific lints run: -# -# cargo install cargo-lints -# cargo lints clippy -# -# For all clippy lints please visit: https://rust-lang.github.io/rust-clippy/master/ -# -allow = [ - # lints we choose not to enforce: - "clippy::zero_prefixed_literal", - "clippy::tabs_in_doc_comments", - "clippy::type_complexity", - - # allow a few lints we've not fixed yet: - # Feel free to raise a PR removing one of these - # (but you will need to fixup the code too!) - "clippy::large_enum_variant", - "clippy::needless_lifetimes", - "clippy::collapsible_if", - "clippy::needless_return", - "clippy::new_without_default", - "clippy::borrowed_box", - "clippy::assign_op_pattern", - "clippy::clone_on_copy", - "clippy::collapsible_else_if", - "clippy::comparison_chain", - "clippy::drop_copy", - "clippy::enum_variant_names", - "clippy::extra_unused_lifetimes", - "clippy::from_over_into", - "clippy::identity_op", - "clippy::into_iter_on_ref", - "clippy::len_without_is_empty", - "clippy::len_zero", - "clippy::let_and_return", - "clippy::many_single_char_names", - "clippy::map_collect_result_unit", - "clippy::match_like_matches_macro", - "clippy::match_ref_pats", - "clippy::mem_replace_with_default", - "clippy::module_inception", - "clippy::mut_from_ref", - "clippy::needless_borrow", - "clippy::needless_collect", - "clippy::needless_doctest_main", - "clippy::needless_range_loop", - "clippy::new_ret_no_self", - "clippy::bind_instead_of_map", - "clippy::comparison_to_empty", - "clippy::nonminimal_bool", - "clippy::single_match", - "clippy::option_as_ref_deref", - "clippy::map_entry", - "clippy::bool_comparison", - "clippy::explicit_counter_loop", - "clippy::clone_double_ref", - "clippy::blacklisted_name", - "clippy::cmp_owned", - "clippy::filter_map_identity", - "clippy::double_must_use", - "clippy::redundant_pattern", - "clippy::eval_order_dependence", - "clippy::from_str_radix_10", - "clippy::clone_double_ref", - "clippy::cmp_owned", - "clippy::redundant_field_names", - "clippy::useless_format", - "clippy::iter_next_slice", - "clippy::blocks_in_if_conditions", - "clippy::if_let_some_result", - "clippy::expect_fun_call", - "clippy::needless_update", - "clippy::manual_strip", - "clippy::print_with_newline", - "clippy::manual_flatten", - "clippy::string_extend_chars", - "clippy::match_overlapping_arm", - "clippy::iter_nth_zero", - "clippy::filter_next", - "clippy::blocks_in_if_conditions", - "clippy::skip_while_next", - "clippy::boxed_local", - "clippy::manual_saturating_arithmetic", - "clippy::unnecessary_filter_map", - "clippy::write_literal", - "clippy::iter_cloned_collect", - "clippy::derive_hash_xor_eq", - "clippy::if_same_then_else", - #"clippy::unwrap_or_else_default", - "clippy::unit_arg", - "clippy::op_ref", - "clippy::field_reassign_with_default", - "clippy::needless_question_mark", - "clippy::map_clone", - "clippy::option_map_unit_fn", - "clippy::or_fun_call", - "clippy::int_plus_one", - "clippy::println_empty_string", - "clippy::ptr_arg", - "clippy::deref_addrof", - "clippy::redundant_clone", - "clippy::redundant_closure", - "clippy::redundant_pattern_matching", - "clippy::redundant_slicing", - "clippy::redundant_static_lifetimes", - "clippy::result_unit_err", - "clippy::search_is_some", - "clippy::should_implement_trait", - "clippy::single_char_add_str", - "clippy::single_component_path_imports", - "clippy::stable_sort_primitive", - "clippy::suspicious_else_formatting", - "clippy::too_many_arguments", - "clippy::try_err", - "clippy::unnecessary_lazy_evaluations", - "clippy::unnecessary_unwrap", - "clippy::unnecessary_mut_passed", - "clippy::unnecessary_cast", - "clippy::unused_unit", - "clippy::unusual_byte_groupings", - "clippy::useless_asref", - "clippy::useless_conversion", - "clippy::vec_init_then_push", - "clippy::while_let_on_iterator", - "clippy::writeln_empty_string", - "clippy::wrong_self_convention" -] -deny = [ -] -warn = [] From a34944b71d5d3198bb998df83f02517f2b4f5058 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sun, 19 Sep 2021 12:56:40 +0100 Subject: [PATCH 06/21] Clippy component already installed --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7547631fa1ae7..f6b103b573956 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -273,7 +273,6 @@ cargo-clippy: <<: *docker-env <<: *test-refs script: - - rustup +nightly component add clippy - ./.maintain/clippy.sh allow_failure: true From 3f6ce9931a1b263e8142833dc7984c4d23aecaa1 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sun, 19 Sep 2021 13:00:54 +0100 Subject: [PATCH 07/21] nightly clippy --- .maintain/clippy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.maintain/clippy.sh b/.maintain/clippy.sh index 8e4ec55775c6b..5896b0d4c6f6a 100755 --- a/.maintain/clippy.sh +++ b/.maintain/clippy.sh @@ -5,7 +5,7 @@ set -e # +nightly -SKIP_WASM_BUILD=1 cargo clippy -- \ +SKIP_WASM_BUILD=1 cargo +nightly clippy -- \ -A clippy::zero_prefixed_literal \ -A clippy::tabs_in_doc_comments \ -A clippy::type_complexity \ From d22159e261a8b28c291693cbb704b381d36a7165 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Mon, 20 Sep 2021 11:49:38 +0100 Subject: [PATCH 08/21] Focus on correctness lints --- .maintain/clippy.sh | 117 +----------------- client/executor/src/wasm_runtime.rs | 1 + .../executor/wasmtime/src/instance_wrapper.rs | 1 + 3 files changed, 6 insertions(+), 113 deletions(-) diff --git a/.maintain/clippy.sh b/.maintain/clippy.sh index 5896b0d4c6f6a..ea4a3fb71eb5c 100755 --- a/.maintain/clippy.sh +++ b/.maintain/clippy.sh @@ -4,117 +4,8 @@ set -e -# +nightly SKIP_WASM_BUILD=1 cargo +nightly clippy -- \ --A clippy::zero_prefixed_literal \ --A clippy::tabs_in_doc_comments \ --A clippy::type_complexity \ --A clippy::large_enum_variant \ --A clippy::needless_lifetimes \ --A clippy::collapsible_if \ --A clippy::needless_return \ --A clippy::new_without_default \ --A clippy::borrowed_box \ --A clippy::assign_op_pattern \ --A clippy::clone_on_copy \ --A clippy::collapsible_else_if \ --A clippy::comparison_chain \ --A clippy::drop_copy \ --A clippy::enum_variant_names \ --A clippy::extra_unused_lifetimes \ --A clippy::from_over_into \ --A clippy::identity_op \ --A clippy::into_iter_on_ref \ --A clippy::len_without_is_empty \ --A clippy::len_zero \ --A clippy::let_and_return \ --A clippy::many_single_char_names \ --A clippy::map_collect_result_unit \ --A clippy::match_like_matches_macro \ --A clippy::match_ref_pats \ --A clippy::mem_replace_with_default \ --A clippy::module_inception \ --A clippy::mut_from_ref \ --A clippy::needless_borrow \ --A clippy::needless_collect \ --A clippy::needless_doctest_main \ --A clippy::needless_range_loop \ --A clippy::new_ret_no_self \ --A clippy::bind_instead_of_map \ --A clippy::comparison_to_empty \ --A clippy::nonminimal_bool \ --A clippy::single_match \ --A clippy::option_as_ref_deref \ --A clippy::map_entry \ --A clippy::bool_comparison \ --A clippy::explicit_counter_loop \ --A clippy::clone_double_ref \ --A clippy::blacklisted_name \ --A clippy::cmp_owned \ --A clippy::filter_map_identity \ --A clippy::double_must_use \ --A clippy::redundant_pattern \ --A clippy::eval_order_dependence \ --A clippy::from_str_radix_10 \ --A clippy::clone_double_ref \ --A clippy::cmp_owned \ --A clippy::redundant_field_names \ --A clippy::useless_format \ --A clippy::iter_next_slice \ --A clippy::blocks_in_if_conditions \ --A clippy::if_let_some_result \ --A clippy::expect_fun_call \ --A clippy::needless_update \ --A clippy::manual_strip \ --A clippy::print_with_newline \ --A clippy::manual_flatten \ --A clippy::string_extend_chars \ --A clippy::match_overlapping_arm \ --A clippy::iter_nth_zero \ --A clippy::filter_next \ --A clippy::blocks_in_if_conditions \ --A clippy::skip_while_next \ --A clippy::boxed_local \ --A clippy::manual_saturating_arithmetic \ --A clippy::unnecessary_filter_map \ --A clippy::write_literal \ --A clippy::iter_cloned_collect \ --A clippy::derive_hash_xor_eq \ --A clippy::if_same_then_else \ --A clippy::unit_arg \ --A clippy::op_ref \ --A clippy::field_reassign_with_default \ --A clippy::needless_question_mark \ --A clippy::map_clone \ --A clippy::option_map_unit_fn \ --A clippy::or_fun_call \ --A clippy::int_plus_one \ --A clippy::println_empty_string \ --A clippy::ptr_arg \ --A clippy::deref_addrof \ --A clippy::redundant_clone \ --A clippy::redundant_closure \ --A clippy::redundant_pattern_matching \ --A clippy::redundant_slicing \ --A clippy::redundant_static_lifetimes \ --A clippy::result_unit_err \ --A clippy::search_is_some \ --A clippy::should_implement_trait \ --A clippy::single_char_add_str \ --A clippy::single_component_path_imports \ --A clippy::stable_sort_primitive \ --A clippy::suspicious_else_formatting \ --A clippy::too_many_arguments \ --A clippy::try_err \ --A clippy::unnecessary_lazy_evaluations \ --A clippy::unnecessary_unwrap \ --A clippy::unnecessary_mut_passed \ --A clippy::unnecessary_cast \ --A clippy::unused_unit \ --A clippy::unusual_byte_groupings \ --A clippy::useless_asref \ --A clippy::useless_conversion \ --A clippy::vec_init_then_push \ --A clippy::while_let_on_iterator \ --A clippy::writeln_empty_string \ --A clippy::wrong_self_convention \ No newline at end of file +-A clippy::all \ +-D clippy::correctness \ +-A clippy::if-same-then-else \ +-A clippy::clone-double-ref diff --git a/client/executor/src/wasm_runtime.rs b/client/executor/src/wasm_runtime.rs index 892c3681c7ce4..201edb0ba421e 100644 --- a/client/executor/src/wasm_runtime.rs +++ b/client/executor/src/wasm_runtime.rs @@ -306,6 +306,7 @@ pub fn create_wasm_runtime_with_code( // // We drop the cache_path here to silence warnings that cache_path is not used if // compiling without the `wasmtime` flag. + #[allow(clippy::drop_copy)] drop(cache_path); sc_executor_wasmi::create_runtime( diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index f66d62f673d90..e5c850314715f 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -399,6 +399,7 @@ impl InstanceWrapper { /// See `[memory_as_slice]`. In addition to those requirements, since a mutable reference is /// returned it must be ensured that only one mutable and no shared references to memory exists /// at the same time. + #[allow(clippy::mut_from_ref)] unsafe fn memory_as_slice_mut(&self) -> &mut [u8] { let ptr = self.memory.data_ptr(); let len = self.memory.data_size(); From 2a42bf68443541f18443b699da292629c14625fa Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Mon, 20 Sep 2021 12:53:48 +0100 Subject: [PATCH 09/21] These seem well defined. --- client/network/src/block_request_handler.rs | 1 + client/network/src/state_request_handler.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/client/network/src/block_request_handler.rs b/client/network/src/block_request_handler.rs index 67a83af897685..c346f424e58ca 100644 --- a/client/network/src/block_request_handler.rs +++ b/client/network/src/block_request_handler.rs @@ -85,6 +85,7 @@ struct SeenRequestsKey { support_multiple_justifications: bool, } +#[allow(clippy::derive_hash_xor_eq)] impl Hash for SeenRequestsKey { fn hash(&self, state: &mut H) { self.peer.hash(state); diff --git a/client/network/src/state_request_handler.rs b/client/network/src/state_request_handler.rs index a15ee246a2ef8..e948b2c691a4a 100644 --- a/client/network/src/state_request_handler.rs +++ b/client/network/src/state_request_handler.rs @@ -78,6 +78,7 @@ struct SeenRequestsKey { start: Vec, } +#[allow(clippy::derive_hash_xor_eq)] impl Hash for SeenRequestsKey { fn hash(&self, state: &mut H) { self.peer.hash(state); From ce2090f951590c20683e79e559b0f89f8cccdf8e Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 25 Sep 2021 13:01:33 +0100 Subject: [PATCH 10/21] use 'standard' way to state which lints we opt into. This relies on a compiler patch that landed 8th July 2021. If people are using an earlier version of the compiler everything will still work unless they try and run clippy. --- .gitlab-ci.yml | 4 ++-- .maintain/clippy.sh | 11 ----------- shell.nix | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100755 .maintain/clippy.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f6b103b573956..a4ce5704d2858 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -257,7 +257,7 @@ cargo-deny: when: always paths: - deny.log - # FIXME: Temorarily allow to fail. + # FIXME: Temporarily allow to fail. allow_failure: true cargo-fmt: @@ -273,7 +273,7 @@ cargo-clippy: <<: *docker-env <<: *test-refs script: - - ./.maintain/clippy.sh + - SKIP_WASM_BUILD=1 cargo +nightly clippy allow_failure: true cargo-check-benches: diff --git a/.maintain/clippy.sh b/.maintain/clippy.sh deleted file mode 100755 index ea4a3fb71eb5c..0000000000000 --- a/.maintain/clippy.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env sh - -# Script for building only the WASM binary of the given project. - -set -e - -SKIP_WASM_BUILD=1 cargo +nightly clippy -- \ --A clippy::all \ --D clippy::correctness \ --A clippy::if-same-then-else \ --A clippy::clone-double-ref diff --git a/shell.nix b/shell.nix index 65a330bf33e12..4528c159dea93 100644 --- a/shell.nix +++ b/shell.nix @@ -5,7 +5,7 @@ let rev = "4a07484cf0e49047f82d83fd119acffbad3b235f"; }); nixpkgs = import { overlays = [ mozillaOverlay ]; }; - rust-nightly = with nixpkgs; ((rustChannelOf { date = "2021-07-06"; channel = "nightly"; }).rust.override { + rust-nightly = with nixpkgs; ((rustChannelOf { date = "2021-07-10"; channel = "nightly"; }).rust.override { extensions = [ "rust-src" ]; targets = [ "wasm32-unknown-unknown" ]; }); From 421546b6ab526e1702514e537914e89e4357a9b6 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 25 Sep 2021 13:37:38 +0100 Subject: [PATCH 11/21] Avoid the override --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4ce5704d2858..b685f67628b98 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -272,6 +272,8 @@ cargo-clippy: stage: test <<: *docker-env <<: *test-refs + variables: + RUSTFLAGS: "" script: - SKIP_WASM_BUILD=1 cargo +nightly clippy allow_failure: true From e8209307fcddf23ff8c6ad0210de29c8cb21b8b2 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 25 Sep 2021 14:12:30 +0100 Subject: [PATCH 12/21] grr gitlab --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b685f67628b98..9aabde8e3f565 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -272,10 +272,8 @@ cargo-clippy: stage: test <<: *docker-env <<: *test-refs - variables: - RUSTFLAGS: "" script: - - SKIP_WASM_BUILD=1 cargo +nightly clippy + - SKIP_WASM_BUILD=1 unset RUSTFLAGS cargo +nightly clippy allow_failure: true cargo-check-benches: From ac0daf9838082e44423dad48fdfa20c8d91c388c Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 25 Sep 2021 14:15:21 +0100 Subject: [PATCH 13/21] almost --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9aabde8e3f565..fe7088935e067 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -273,7 +273,7 @@ cargo-clippy: <<: *docker-env <<: *test-refs script: - - SKIP_WASM_BUILD=1 unset RUSTFLAGS cargo +nightly clippy + - SKIP_WASM_BUILD=1 unset RUSTFLAGS && cargo +nightly clippy allow_failure: true cargo-check-benches: From 720d02b34fe89e6832d5247ac8cdb035a64184d5 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 25 Sep 2021 14:24:40 +0100 Subject: [PATCH 14/21] take 2 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe7088935e067..f8676dc1ee4f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -273,7 +273,7 @@ cargo-clippy: <<: *docker-env <<: *test-refs script: - - SKIP_WASM_BUILD=1 unset RUSTFLAGS && cargo +nightly clippy + - SKIP_WASM_BUILD=1 RUSTFLAGS= cargo +nightly clippy allow_failure: true cargo-check-benches: From 63720418f9c5a739f9d5dc45d4be70581ac44d53 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sat, 25 Sep 2021 14:37:03 +0100 Subject: [PATCH 15/21] File was in the .gitignore list --- .cargo/config.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000000..2bffc5af1eb02 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,7 @@ +[target.'cfg(feature = "cargo-clippy")'] +rustflags = [ + "-Aclippy::all", + "-Dclippy::correctness", + "-Aclippy::if-same-then-else", + "-Aclippy::clone-double-ref" +] From 49f1e8fa75b5e5724dece399f8183d03a817bfc0 Mon Sep 17 00:00:00 2001 From: Squirrel Date: Sun, 26 Sep 2021 06:43:47 +0100 Subject: [PATCH 16/21] Update client/executor/src/wasm_runtime.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- client/executor/src/wasm_runtime.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/executor/src/wasm_runtime.rs b/client/executor/src/wasm_runtime.rs index 201edb0ba421e..9c0faa80107a6 100644 --- a/client/executor/src/wasm_runtime.rs +++ b/client/executor/src/wasm_runtime.rs @@ -306,8 +306,7 @@ pub fn create_wasm_runtime_with_code( // // We drop the cache_path here to silence warnings that cache_path is not used if // compiling without the `wasmtime` flag. - #[allow(clippy::drop_copy)] - drop(cache_path); + let _ = cache_path; sc_executor_wasmi::create_runtime( blob, From ac1bbcd0b4ed1959a2c0ed25da3d75177329a041 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Sun, 26 Sep 2021 07:00:29 +0100 Subject: [PATCH 17/21] unset --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f8676dc1ee4f0..fcbadabdd5cb4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -273,7 +273,7 @@ cargo-clippy: <<: *docker-env <<: *test-refs script: - - SKIP_WASM_BUILD=1 RUSTFLAGS= cargo +nightly clippy + - SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo +nightly clippy allow_failure: true cargo-check-benches: From de16dcba33efb96b77693ec6e1fd455539ea52fe Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Mon, 27 Sep 2021 12:06:36 +0100 Subject: [PATCH 18/21] Include bool in hash --- .cargo/config.toml | 7 +++++++ .gitignore | 1 - client/network/src/block_request_handler.rs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 2bffc5af1eb02..06328af71459c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,10 @@ +# +# An auto defined `clippy` feature was introduced, +# but it was found to clash with user defined features, +# so was renamed to `cargo-clippy`. +# +# If you want standard clippy run: +# RUSTFLAGS= cargo clippy [target.'cfg(feature = "cargo-clippy")'] rustflags = [ "-Aclippy::all", diff --git a/.gitignore b/.gitignore index 0486a1a716e5c..7c136d6f69585 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ rls*.log .local **/hfuzz_target/ **/hfuzz_workspace/ -.cargo/ .cargo-remote.toml *.bin *.iml diff --git a/client/network/src/block_request_handler.rs b/client/network/src/block_request_handler.rs index 77a7e2c35068d..3ea7833970d9e 100644 --- a/client/network/src/block_request_handler.rs +++ b/client/network/src/block_request_handler.rs @@ -92,7 +92,7 @@ impl Hash for SeenRequestsKey { self.max_blocks.hash(state); self.direction.hash(state); self.attributes.hash(state); - + self.support_multiple_justifications.hash(state); match self.from { BlockId::Hash(h) => h.hash(state), BlockId::Number(n) => n.hash(state), From 8cff766fb5760c8addc7c03592c376fa5d8026a0 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Mon, 27 Sep 2021 12:12:05 +0100 Subject: [PATCH 19/21] Correctness is mandatory. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2abe73bf9a563..fd1d8011e918c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -327,7 +327,7 @@ cargo-clippy: <<: *test-refs script: - SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo +nightly clippy - allow_failure: true + allow_failure: false cargo-check-benches: stage: test From ea6403207ad5b96a2d74b3197c9c6f1cb476746e Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Tue, 28 Sep 2021 17:44:26 +0100 Subject: [PATCH 20/21] Explicit Ord impl --- frame/support/src/traits/metadata.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/frame/support/src/traits/metadata.rs b/frame/support/src/traits/metadata.rs index 14b7e6d7355e2..e60cf8be8a41c 100644 --- a/frame/support/src/traits/metadata.rs +++ b/frame/support/src/traits/metadata.rs @@ -78,7 +78,7 @@ pub trait GetCallMetadata { } /// The version of a crate. -#[derive(RuntimeDebug, Eq, PartialEq, Encode, Decode, Ord, Clone, Copy, Default)] +#[derive(RuntimeDebug, Eq, PartialEq, Encode, Decode, Clone, Copy, Default)] pub struct CrateVersion { /// The major version of the crate. pub major: u16, @@ -94,14 +94,17 @@ impl CrateVersion { } } -impl sp_std::cmp::PartialOrd for CrateVersion { - fn partial_cmp(&self, other: &Self) -> Option { - let res = self - .major +impl sp_std::cmp::Ord for CrateVersion { + fn cmp(&self, other: &Self) -> sp_std::cmp::Ordering { + self.major .cmp(&other.major) - .then_with(|| self.minor.cmp(&other.minor).then_with(|| self.patch.cmp(&other.patch))); + .then_with(|| self.minor.cmp(&other.minor).then_with(|| self.patch.cmp(&other.patch))) + } +} - Some(res) +impl sp_std::cmp::PartialOrd for CrateVersion { + fn partial_cmp(&self, other: &Self) -> Option { + Some(::cmp(&self, other)) } } From 633f914985e09052b39870b798f55f02a5c35664 Mon Sep 17 00:00:00 2001 From: Squirrel Date: Fri, 1 Oct 2021 13:29:03 +0100 Subject: [PATCH 21/21] Update .gitlab-ci.yml Co-authored-by: Denis Pisarev --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd1d8011e918c..0d150d96deedc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -327,7 +327,6 @@ cargo-clippy: <<: *test-refs script: - SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo +nightly clippy - allow_failure: false cargo-check-benches: stage: test