From b69e0f02e7c3a25da7ddb13bc8a585c3e2126f33 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 4 Mar 2024 19:36:27 +0100 Subject: [PATCH 1/6] refactor: Migrate to Cargo.toml top-level `[lints]` entry Introduced in Rust 1.74. --- .cargo/config.toml | 38 -------------------------------------- Cargo.toml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index fa0ad815f5..6ea54550e6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,41 +4,3 @@ debug = true [profile.release] incremental = true lto = true - -[build] -# TODO: Replace with [lints]: -# https://github.com/NomicFoundation/slang/issues/837 -rustflags = [ - # rustc additional warnings: - "-Wunused_crate_dependencies", - "-Wunused_lifetimes", - "-Wunused_macro_rules", - "-Wunused_tuple_struct_fields", # Will be uplifed into `dead_code` (warn-by-default) with https://github.com/rust-lang/rust/pull/118297 - "-Wmeta_variable_misuse", - # Rust 2018 idioms that are not yet warn-by-default: - "-Welided_lifetimes_in_paths", - "-Wunused_extern_crates", - "-Wexplicit_outlives_requirements", - # 📎 Lints that are enabled (warn/deny) by default - "-Wclippy::all", - # Cargo - "-Wclippy::cargo", # Warn about Cargo.toml issues, except... - "-Aclippy::multiple_crate_versions", # Not possible to deduplicate, should be done periodically ourselves - # Restriction (optional, neutral lints) - "-Wclippy::exit", # Prefer not `process::exit`ing directly - "-Wclippy::rest_pat_in_fully_bound_structs", # Prefer not to use `..` in fully bound structs - "-Wclippy::verbose_file_reads", # Prefer simpler and more concise `fs::read_to_string` - # Pedantic - "-Wclippy::pedantic", # Warn about pedantic lints, except... - "-Aclippy::implicit_clone", # A lot of false positives, tuned down in Clippy bundled with Rust 1.73 - "-Aclippy::match_same_arms", # It's often clearer to have the same arm twice - "-Aclippy::missing_errors_doc", # Most of our code is internal; let's not clutter the docs until... - "-Aclippy::missing_panics_doc", # ... we care about the public documentation in our shipped crates - "-Aclippy::module_name_repetitions", # It seems we prefer it this way; we'd need to discuss that - "-Aclippy::must_use_candidate", # Overzealous, we'd have to `[must_use]` a lot of things - "-Aclippy::redundant_closure_for_method_calls", # Not always clearer, let's not pepper `allow`s whenever needed - # Nursery - "-Wclippy::collection_is_never_read", # Lint against collections not used after creation - "-Wclippy::equatable_if_let", # Prefer regular `==` checks over Yoda `if let $pat = $value` - "-Wclippy::useless_let_if_seq", # Use idiomatic direct assignment of `let $val = if $cond { .. } else { ..};` -] diff --git a/Cargo.toml b/Cargo.toml index b9d9dc8b14..29ee6470a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,3 +119,39 @@ thiserror = { version = "1.0.57" } trybuild = { version = "1.0.89" } toml = { version = "0.7.8" } url = { version = "2.3.1" } + +[workspace.lints.rust] +unused_crate_dependencies = "warn" +unused_lifetimes = "warn" +unused_macro_rules = "warn" +unused_tuple_struct_fields = "warn" # Will be uplifed into `dead_code` (warn-by-default) with https://github.com/rust-lang/rust/pull/118297 +meta_variable_misuse = "warn" +# Rust 2018 idioms that are not yet warn-by-default: +elided_lifetimes_in_paths = "warn" +unused_extern_crates = "warn" +explicit_outlives_requirements = "warn" + +[workspace.lints.clippy] +# Lints that are enabled (warn/deny) by default +all = "warn" +# Cargo +cargo = "warn" # Warn about Cargo.toml issues, except... +multiple_crate_versions = { level = "allow", priority = 1 } # Not possible to deduplicate, should be done periodically ourselves +# Restriction (optional, neutral lints) +exit = "warn" # Prefer not `process::exit`ing directly +rest_pat_in_fully_bound_structs = "warn" # Prefer not to use `..` in fully bound structs +verbose_file_reads = "warn" # Prefer simpler and more concise `fs::read_to_string` +# # Pedantic +pedantic = "warn" # Warn about pedantic lints, except... +implicit_clone = { level = "allow", priority = 1 } # A lot of false positives, tuned down in Clippy bundled with Rust 1.73 +match_same_arms = { level = "allow", priority = 1 } # It's often clearer to have the same arm twice +missing_errors_doc = { level = "allow", priority = 1 } # Most of our code is internal; let's not clutter the docs until... +missing_panics_doc = { level = "allow", priority = 1 } # ... we care about the public documentation in our shipped crates +module_name_repetitions = { level = "allow", priority = 1 } # It seems we prefer it this way; we'd need to discuss that +must_use_candidate = { level = "allow", priority = 1 } # Overzealous, we'd have to `[must_use]` a lot of things +redundant_closure_for_method_calls = { level = "allow", priority = 1 } # Not always clearer, let's not pepper `allow`s whenever needed +# # Nursery +collection_is_never_read = "warn" # Lint against collections not used after creation +equatable_if_let = "warn" # Prefer regular `==` checks over Yoda `if let $pat = $value` +useless_let_if_seq = "warn" # Use idiomatic direct assignment of `let $val = if $cond { .. } else { .. };` +redundant_else = "warn" # Warn about redundant `else` blocks From 302f694f2f2d2f4d6c139d8bee2e53a6b4be1e53 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 4 Mar 2024 19:38:52 +0100 Subject: [PATCH 2/6] Ensure lints for every Cargo.toml --- crates/codegen/ebnf/Cargo.toml | 4 ++++ crates/codegen/grammar/Cargo.toml | 4 ++++ crates/codegen/language/definition/Cargo.toml | 4 ++++ crates/codegen/language/internal_macros/Cargo.toml | 4 ++++ crates/codegen/language/macros/Cargo.toml | 4 ++++ crates/codegen/language/tests/Cargo.toml | 4 ++++ crates/codegen/parser/generator/Cargo.toml | 4 ++++ crates/codegen/parser/runtime/Cargo.toml | 4 ++++ crates/codegen/spec/Cargo.toml | 4 ++++ crates/codegen/testing/Cargo.toml | 4 ++++ crates/infra/cli/Cargo.toml | 4 ++++ crates/infra/utils/Cargo.toml | 4 ++++ crates/solidity/inputs/language/Cargo.toml | 4 ++++ crates/solidity/outputs/cargo/slang_solidity/Cargo.toml | 4 ++++ .../outputs/cargo/slang_solidity_node_addon/Cargo.toml | 4 ++++ crates/solidity/outputs/cargo/tests/Cargo.toml | 4 ++++ crates/solidity/outputs/npm/package/Cargo.toml | 4 ++++ crates/solidity/outputs/spec/Cargo.toml | 4 ++++ crates/solidity/testing/sanctuary/Cargo.toml | 4 ++++ crates/solidity/testing/snapshots/Cargo.toml | 4 ++++ crates/solidity/testing/solc/Cargo.toml | 4 ++++ crates/solidity/testing/utils/Cargo.toml | 4 ++++ crates/testlang/inputs/language/Cargo.toml | 4 ++++ crates/testlang/outputs/cargo/slang_testlang/Cargo.toml | 4 ++++ .../outputs/cargo/slang_testlang_node_addon/Cargo.toml | 4 ++++ crates/testlang/outputs/cargo/tests/Cargo.toml | 4 ++++ crates/testlang/outputs/npm/package/Cargo.toml | 4 ++++ 27 files changed, 108 insertions(+) diff --git a/crates/codegen/ebnf/Cargo.toml b/crates/codegen/ebnf/Cargo.toml index c823aeef29..3c91582b73 100644 --- a/crates/codegen/ebnf/Cargo.toml +++ b/crates/codegen/ebnf/Cargo.toml @@ -11,3 +11,7 @@ codegen_language_definition = { workspace = true } derive-new = { workspace = true } indexmap = { workspace = true } Inflector = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/grammar/Cargo.toml b/crates/codegen/grammar/Cargo.toml index adacd96dbe..f99b62bbb6 100644 --- a/crates/codegen/grammar/Cargo.toml +++ b/crates/codegen/grammar/Cargo.toml @@ -10,3 +10,7 @@ codegen_language_definition = { workspace = true } indexmap = { workspace = true } semver = { workspace = true } strum_macros = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/language/definition/Cargo.toml b/crates/codegen/language/definition/Cargo.toml index b523aa3307..b1db94fb47 100644 --- a/crates/codegen/language/definition/Cargo.toml +++ b/crates/codegen/language/definition/Cargo.toml @@ -18,3 +18,7 @@ serde = { workspace = true } strum_macros = { workspace = true } syn = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/language/internal_macros/Cargo.toml b/crates/codegen/language/internal_macros/Cargo.toml index 502d50c468..bac01de4b2 100644 --- a/crates/codegen/language/internal_macros/Cargo.toml +++ b/crates/codegen/language/internal_macros/Cargo.toml @@ -13,3 +13,7 @@ itertools = { workspace = true } proc-macro2 = { workspace = true } quote = { workspace = true } syn = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/language/macros/Cargo.toml b/crates/codegen/language/macros/Cargo.toml index c4178c76ea..b152522878 100644 --- a/crates/codegen/language/macros/Cargo.toml +++ b/crates/codegen/language/macros/Cargo.toml @@ -10,3 +10,7 @@ proc-macro = true [dependencies] codegen_language_definition = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/language/tests/Cargo.toml b/crates/codegen/language/tests/Cargo.toml index 2233243727..2e9eee9562 100644 --- a/crates/codegen/language/tests/Cargo.toml +++ b/crates/codegen/language/tests/Cargo.toml @@ -12,3 +12,7 @@ infra_utils = { workspace = true } rayon = { workspace = true } semver = { workspace = true } trybuild = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/parser/generator/Cargo.toml b/crates/codegen/parser/generator/Cargo.toml index 5d97fe7a3c..4ec238c00c 100644 --- a/crates/codegen/parser/generator/Cargo.toml +++ b/crates/codegen/parser/generator/Cargo.toml @@ -17,3 +17,7 @@ proc-macro2 = { workspace = true } quote = { workspace = true } semver = { workspace = true } serde = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/parser/runtime/Cargo.toml b/crates/codegen/parser/runtime/Cargo.toml index 4f05ae4b47..e7754f5aee 100644 --- a/crates/codegen/parser/runtime/Cargo.toml +++ b/crates/codegen/parser/runtime/Cargo.toml @@ -21,3 +21,7 @@ strum_macros = { workspace = true } [features] default = ["slang_napi_interfaces"] slang_napi_interfaces = ["dep:napi", "dep:napi-derive"] + +[lints] +workspace = true + diff --git a/crates/codegen/spec/Cargo.toml b/crates/codegen/spec/Cargo.toml index c9de989877..90701e8d54 100644 --- a/crates/codegen/spec/Cargo.toml +++ b/crates/codegen/spec/Cargo.toml @@ -14,3 +14,7 @@ Inflector = { workspace = true } infra_utils = { workspace = true } itertools = { workspace = true } serde = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/codegen/testing/Cargo.toml b/crates/codegen/testing/Cargo.toml index cfb1dd2468..595e550737 100644 --- a/crates/codegen/testing/Cargo.toml +++ b/crates/codegen/testing/Cargo.toml @@ -10,3 +10,7 @@ anyhow = { workspace = true } codegen_language_definition = { workspace = true } Inflector = { workspace = true } infra_utils = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/infra/cli/Cargo.toml b/crates/infra/cli/Cargo.toml index 70391e9fd1..d322337663 100644 --- a/crates/infra/cli/Cargo.toml +++ b/crates/infra/cli/Cargo.toml @@ -18,3 +18,7 @@ semver = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } toml = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/infra/utils/Cargo.toml b/crates/infra/utils/Cargo.toml index 2deddc3a04..659dd764ae 100644 --- a/crates/infra/utils/Cargo.toml +++ b/crates/infra/utils/Cargo.toml @@ -21,3 +21,7 @@ serde_json = { workspace = true } similar-asserts = { workspace = true } tera = { workspace = true } toml = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/inputs/language/Cargo.toml b/crates/solidity/inputs/language/Cargo.toml index bffb99ddee..efe3120cb4 100644 --- a/crates/solidity/inputs/language/Cargo.toml +++ b/crates/solidity/inputs/language/Cargo.toml @@ -10,3 +10,7 @@ publish = false codegen_language_definition = { workspace = true } codegen_language_macros = { workspace = true } semver = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml b/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml index 60e677fc86..1d9e8e7cc5 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml +++ b/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml @@ -52,3 +52,7 @@ serde_json = { workspace = true, optional = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml b/crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml index a6872e2f65..0d71cef363 100644 --- a/crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml +++ b/crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml @@ -46,3 +46,7 @@ serde = { workspace = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/outputs/cargo/tests/Cargo.toml b/crates/solidity/outputs/cargo/tests/Cargo.toml index 31fc58d253..eeda098afe 100644 --- a/crates/solidity/outputs/cargo/tests/Cargo.toml +++ b/crates/solidity/outputs/cargo/tests/Cargo.toml @@ -18,3 +18,7 @@ semver = { workspace = true } slang_solidity = { workspace = true } solidity_testing_utils = { workspace = true } strum_macros = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/outputs/npm/package/Cargo.toml b/crates/solidity/outputs/npm/package/Cargo.toml index 5ce2fc9f4c..8aa5067d69 100644 --- a/crates/solidity/outputs/npm/package/Cargo.toml +++ b/crates/solidity/outputs/npm/package/Cargo.toml @@ -10,3 +10,7 @@ anyhow = { workspace = true } codegen_parser_generator = { workspace = true } infra_utils = { workspace = true } solidity_language = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/outputs/spec/Cargo.toml b/crates/solidity/outputs/spec/Cargo.toml index ff1cdecd7d..7d9d137fa3 100644 --- a/crates/solidity/outputs/spec/Cargo.toml +++ b/crates/solidity/outputs/spec/Cargo.toml @@ -11,3 +11,7 @@ anyhow = { workspace = true } codegen_spec = { workspace = true } infra_utils = { workspace = true } solidity_language = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/testing/sanctuary/Cargo.toml b/crates/solidity/testing/sanctuary/Cargo.toml index 34c77d9fef..7890a1de58 100644 --- a/crates/solidity/testing/sanctuary/Cargo.toml +++ b/crates/solidity/testing/sanctuary/Cargo.toml @@ -19,3 +19,7 @@ serde_json = { workspace = true } slang_solidity = { workspace = true } strum_macros = { workspace = true } url = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/testing/snapshots/Cargo.toml b/crates/solidity/testing/snapshots/Cargo.toml index fc112cc932..fc682f4cd0 100644 --- a/crates/solidity/testing/snapshots/Cargo.toml +++ b/crates/solidity/testing/snapshots/Cargo.toml @@ -4,3 +4,7 @@ version.workspace = true rust-version.workspace = true edition.workspace = true publish = false + +[lints] +workspace = true + diff --git a/crates/solidity/testing/solc/Cargo.toml b/crates/solidity/testing/solc/Cargo.toml index e08221ac34..645016439c 100644 --- a/crates/solidity/testing/solc/Cargo.toml +++ b/crates/solidity/testing/solc/Cargo.toml @@ -22,3 +22,7 @@ serde_json = { workspace = true } solidity_language = { workspace = true } strum_macros = { workspace = true } url = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/solidity/testing/utils/Cargo.toml b/crates/solidity/testing/utils/Cargo.toml index ff9b8a569a..cff80bc7b4 100644 --- a/crates/solidity/testing/utils/Cargo.toml +++ b/crates/solidity/testing/utils/Cargo.toml @@ -13,3 +13,7 @@ once_cell = { workspace = true } semver = { workspace = true } slang_solidity = { workspace = true } solidity_language = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/testlang/inputs/language/Cargo.toml b/crates/testlang/inputs/language/Cargo.toml index 3025496177..48cf7658c8 100644 --- a/crates/testlang/inputs/language/Cargo.toml +++ b/crates/testlang/inputs/language/Cargo.toml @@ -10,3 +10,7 @@ publish = false codegen_language_definition = { workspace = true } codegen_language_macros = { workspace = true } semver = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml b/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml index 128f4af251..3696e97670 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml +++ b/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml @@ -20,3 +20,7 @@ serde = { workspace = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml b/crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml index 084fd2b991..e325b846ba 100644 --- a/crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml +++ b/crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml @@ -46,3 +46,7 @@ serde = { workspace = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/testlang/outputs/cargo/tests/Cargo.toml b/crates/testlang/outputs/cargo/tests/Cargo.toml index 6050367f66..5f56849b99 100644 --- a/crates/testlang/outputs/cargo/tests/Cargo.toml +++ b/crates/testlang/outputs/cargo/tests/Cargo.toml @@ -8,3 +8,7 @@ publish = false [dev-dependencies] semver = { workspace = true } slang_testlang = { workspace = true } + +[lints] +workspace = true + diff --git a/crates/testlang/outputs/npm/package/Cargo.toml b/crates/testlang/outputs/npm/package/Cargo.toml index e989c1032b..89b82ad052 100644 --- a/crates/testlang/outputs/npm/package/Cargo.toml +++ b/crates/testlang/outputs/npm/package/Cargo.toml @@ -10,3 +10,7 @@ anyhow = { workspace = true } codegen_parser_generator = { workspace = true } infra_utils = { workspace = true } testlang_language = { workspace = true } + +[lints] +workspace = true + From 834e5fdf937e96913b537f1a1d3993bac2a841ca Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 4 Mar 2024 20:01:21 +0100 Subject: [PATCH 3/6] `unused_tuple_struct_fields` is already warned against in Rust 1.77 --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 29ee6470a4..c3fc51641c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,7 +124,6 @@ url = { version = "2.3.1" } unused_crate_dependencies = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" -unused_tuple_struct_fields = "warn" # Will be uplifed into `dead_code` (warn-by-default) with https://github.com/rust-lang/rust/pull/118297 meta_variable_misuse = "warn" # Rust 2018 idioms that are not yet warn-by-default: elided_lifetimes_in_paths = "warn" From 4d53c3029921acf336851d66bca4960b075601b2 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 4 Mar 2024 20:06:26 +0100 Subject: [PATCH 4/6] Warn against `implicit_clone` again --- Cargo.toml | 1 - .../definition/src/compiler/analysis/definitions.rs | 2 +- .../definition/src/compiler/analysis/references.rs | 2 +- .../language/definition/src/compiler/version_set.rs | 8 ++++---- crates/codegen/language/internal_macros/src/lib.rs | 2 +- crates/infra/utils/src/cargo/workspace.rs | 4 ++-- crates/infra/utils/src/commands/mod.rs | 2 +- .../testing/solc/src/commands/keyword_versioning.rs | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c3fc51641c..ae12fc2b82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,7 +142,6 @@ rest_pat_in_fully_bound_structs = "warn" # Prefer not to use `..` in fully bound verbose_file_reads = "warn" # Prefer simpler and more concise `fs::read_to_string` # # Pedantic pedantic = "warn" # Warn about pedantic lints, except... -implicit_clone = { level = "allow", priority = 1 } # A lot of false positives, tuned down in Clippy bundled with Rust 1.73 match_same_arms = { level = "allow", priority = 1 } # It's often clearer to have the same arm twice missing_errors_doc = { level = "allow", priority = 1 } # Most of our code is internal; let's not clutter the docs until... missing_panics_doc = { level = "allow", priority = 1 } # ... we care about the public documentation in our shipped crates diff --git a/crates/codegen/language/definition/src/compiler/analysis/definitions.rs b/crates/codegen/language/definition/src/compiler/analysis/definitions.rs index f13f2a1076..cfeb6d1c0b 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/definitions.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/definitions.rs @@ -24,7 +24,7 @@ fn collect_top_level_items(analysis: &mut Analysis) { } analysis.metadata.insert( - (**name).to_owned(), + (**name).clone(), ItemMetadata { name: name.clone(), item: item.clone(), diff --git a/crates/codegen/language/definition/src/compiler/analysis/references.rs b/crates/codegen/language/definition/src/compiler/analysis/references.rs index 413cb9ffff..3300f72ce6 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/references.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/references.rs @@ -389,7 +389,7 @@ fn check_reference( if let Some(source) = source { analysis.metadata[source] .referenced_items - .push((**reference).to_owned()); + .push((**reference).clone()); } } diff --git a/crates/codegen/language/definition/src/compiler/version_set.rs b/crates/codegen/language/definition/src/compiler/version_set.rs index 0a447c9d93..34d91ccc5f 100644 --- a/crates/codegen/language/definition/src/compiler/version_set.rs +++ b/crates/codegen/language/definition/src/compiler/version_set.rs @@ -45,10 +45,10 @@ impl VersionSet { // there is some overlap: // make sure 'range' is included in 'from..till', then remove it: if range.start < from { - from = range.start.to_owned(); + from = range.start.clone(); } if till < range.end { - till = range.end.to_owned(); + till = range.end.clone(); } false }); @@ -89,7 +89,7 @@ impl VersionSet { if first.start < second.start { // take part of first that exists before second: - ranges.push(first.start.to_owned()..second.start.to_owned()); + ranges.push(first.start.clone()..second.start.clone()); } if first.end <= second.end { @@ -99,7 +99,7 @@ impl VersionSet { } // keep part of first that exists after second: - first.start = second.end.to_owned(); + first.start = second.end.clone(); // advance second, as it's been fully processed: second_iter.next(); diff --git a/crates/codegen/language/internal_macros/src/lib.rs b/crates/codegen/language/internal_macros/src/lib.rs index d828f67039..c186c50701 100644 --- a/crates/codegen/language/internal_macros/src/lib.rs +++ b/crates/codegen/language/internal_macros/src/lib.rs @@ -10,7 +10,7 @@ use crate::input_model::InputItem; pub fn derive_spanned_type(args: TokenStream, mut input: TokenStream) -> TokenStream { let spanned_type = { let spanned_derive_args = args.into(); - let input = input.to_owned(); + let input = input.clone(); let item = syn::parse_macro_input!(input as InputItem); derive::spanned(item, spanned_derive_args) diff --git a/crates/infra/utils/src/cargo/workspace.rs b/crates/infra/utils/src/cargo/workspace.rs index 8d94a52335..631e45eb40 100644 --- a/crates/infra/utils/src/cargo/workspace.rs +++ b/crates/infra/utils/src/cargo/workspace.rs @@ -22,7 +22,7 @@ impl CargoWorkspace { .get(crate_name) .with_context(|| format!("Cannot find dependency '{crate_name}' in workspace."))? .version - .to_owned() + .clone() .with_context(|| { format!("Dependency '{crate_name}' did not specify a version in Cargo.toml.") })? @@ -47,7 +47,7 @@ impl CargoWorkspace { .get(crate_name) .with_context(|| format!("Cannot find dependency '{crate_name}' in workspace."))? .path - .to_owned() + .clone() .with_context(|| { format!("Dependency '{crate_name}' did not specify a path in Cargo.toml.") })?; diff --git a/crates/infra/utils/src/commands/mod.rs b/crates/infra/utils/src/commands/mod.rs index 8e198b8c0d..dea3d14c46 100644 --- a/crates/infra/utils/src/commands/mod.rs +++ b/crates/infra/utils/src/commands/mod.rs @@ -224,7 +224,7 @@ impl Display for Command { parts.push("&&".to_owned()); } - parts.push(self.name.to_owned()); + parts.push(self.name.clone()); for arg in &self.args { let delimiter = if arg.contains(' ') { diff --git a/crates/solidity/testing/solc/src/commands/keyword_versioning.rs b/crates/solidity/testing/solc/src/commands/keyword_versioning.rs index ca6b9ff86c..3ab5dd5239 100644 --- a/crates/solidity/testing/solc/src/commands/keyword_versioning.rs +++ b/crates/solidity/testing/solc/src/commands/keyword_versioning.rs @@ -133,7 +133,7 @@ impl KeywordVersioningCommand { for variation in variations { assert!( - already_seen.insert((&item.identifier, variation.to_owned())), + already_seen.insert((&item.identifier, variation.clone())), "Duplicate variation: {variation}" ); From 9e6992a71c04f0f10d105a0702e11b1afa84f317 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 4 Mar 2024 20:09:24 +0100 Subject: [PATCH 5/6] Warn against `implicit_clone` again cont. --- crates/solidity/outputs/cargo/tests/src/trivia.rs | 2 +- crates/solidity/testing/sanctuary/src/datasets.rs | 2 +- crates/solidity/testing/sanctuary/src/tests.rs | 2 +- crates/solidity/testing/solc/src/commands/dissect.rs | 4 ++-- .../solidity/testing/solc/src/commands/keyword_versioning.rs | 2 +- crates/solidity/testing/solc/src/utils/binaries.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/solidity/outputs/cargo/tests/src/trivia.rs b/crates/solidity/outputs/cargo/tests/src/trivia.rs index c2e86f4d86..d8486fa4a0 100644 --- a/crates/solidity/outputs/cargo/tests/src/trivia.rs +++ b/crates/solidity/outputs/cargo/tests/src/trivia.rs @@ -35,7 +35,7 @@ fn compare_end_of_lines(input: &str, expected: &[&str]) -> Result<()> { Node::Token(token) => { assert_eq!(token.kind, TokenKind::EndOfLine); - Some(token.text.to_owned()) + Some(token.text.clone()) } }) .collect::>(); diff --git a/crates/solidity/testing/sanctuary/src/datasets.rs b/crates/solidity/testing/sanctuary/src/datasets.rs index 08666f73cf..fa6c40e477 100644 --- a/crates/solidity/testing/sanctuary/src/datasets.rs +++ b/crates/solidity/testing/sanctuary/src/datasets.rs @@ -167,7 +167,7 @@ fn list_contracts(repo_dir: &Path, network: &str) -> Result Result<()> { // https://github.com/tintinweb/smart-contract-sanctuary/issues/31 .replace("[email protected]", "[email-protected]"); - let language = Language::new(version.to_owned())?; + let language = Language::new(version.clone())?; let output = language.parse(RuleKind::SourceUnit, &source); if output.is_valid() { diff --git a/crates/solidity/testing/solc/src/commands/dissect.rs b/crates/solidity/testing/solc/src/commands/dissect.rs index 4b20c5a1a8..8c0783397a 100644 --- a/crates/solidity/testing/solc/src/commands/dissect.rs +++ b/crates/solidity/testing/solc/src/commands/dissect.rs @@ -30,7 +30,7 @@ impl DissectCommand { let language = SolidityDefinition::create(); let binaries = Binary::fetch_all(&language)?; - let mut dissector = Dissector::new(self.file.to_owned())?; + let mut dissector = Dissector::new(self.file.clone())?; for binary in binaries { dissector.inspect_version(&binary)?; @@ -96,7 +96,7 @@ impl Dissector { sources: [( self.file.unwrap_string(), InputSource { - content: self.source.to_owned(), + content: self.source.clone(), }, )] .into(), diff --git a/crates/solidity/testing/solc/src/commands/keyword_versioning.rs b/crates/solidity/testing/solc/src/commands/keyword_versioning.rs index 3ab5dd5239..d06b31f9f6 100644 --- a/crates/solidity/testing/solc/src/commands/keyword_versioning.rs +++ b/crates/solidity/testing/solc/src/commands/keyword_versioning.rs @@ -245,7 +245,7 @@ impl TestCase { sources: [( "input.sol".into(), InputSource { - content: self.source.to_owned(), + content: self.source.clone(), }, )] .into(), diff --git a/crates/solidity/testing/solc/src/utils/binaries.rs b/crates/solidity/testing/solc/src/utils/binaries.rs index 8d2ab0ee92..d7693a19d0 100644 --- a/crates/solidity/testing/solc/src/utils/binaries.rs +++ b/crates/solidity/testing/solc/src/utils/binaries.rs @@ -62,7 +62,7 @@ impl Binary { progress_bar.finish_and_clear(); println!(); - binaries.sort_by_key(|binary| binary.version.to_owned()); + binaries.sort_by_key(|binary| binary.version.clone()); Ok(binaries) } From 83d42fd4211f3531c971c91a2f17260bf175da12 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 5 Mar 2024 10:56:30 +0100 Subject: [PATCH 6/6] fixup: Fix double comments --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ae12fc2b82..4940b1131b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,7 +140,7 @@ multiple_crate_versions = { level = "allow", priority = 1 } # Not possible to de exit = "warn" # Prefer not `process::exit`ing directly rest_pat_in_fully_bound_structs = "warn" # Prefer not to use `..` in fully bound structs verbose_file_reads = "warn" # Prefer simpler and more concise `fs::read_to_string` -# # Pedantic +# Pedantic pedantic = "warn" # Warn about pedantic lints, except... match_same_arms = { level = "allow", priority = 1 } # It's often clearer to have the same arm twice missing_errors_doc = { level = "allow", priority = 1 } # Most of our code is internal; let's not clutter the docs until... @@ -148,7 +148,7 @@ missing_panics_doc = { level = "allow", priority = 1 } # ... we module_name_repetitions = { level = "allow", priority = 1 } # It seems we prefer it this way; we'd need to discuss that must_use_candidate = { level = "allow", priority = 1 } # Overzealous, we'd have to `[must_use]` a lot of things redundant_closure_for_method_calls = { level = "allow", priority = 1 } # Not always clearer, let's not pepper `allow`s whenever needed -# # Nursery +# Nursery collection_is_never_read = "warn" # Lint against collections not used after creation equatable_if_let = "warn" # Prefer regular `==` checks over Yoda `if let $pat = $value` useless_let_if_seq = "warn" # Use idiomatic direct assignment of `let $val = if $cond { .. } else { .. };`