From d0f12ccde0ec000dfde6240437ecd4499f2c4e04 Mon Sep 17 00:00:00 2001 From: Tim Oram Date: Sun, 30 Jun 2024 11:04:15 -0230 Subject: [PATCH] Move linting config to Cargo.toml and only warn This reworks the rustc, Clippy, and rustdoc linting configuration to the Cargo.toml file, and converts all denied lints to be warnings. --- Cargo.toml | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 60 ------------------------------------- 2 files changed, 88 insertions(+), 60 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 30b267d..70831e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,91 @@ edition = "2018" [lib] name = "captur" + +[lints.rust] +future_incompatible = { level = "warn", priority = -2 } +keyword_idents = { level = "warn", priority = -3 } +let_underscore = { level = "warn", priority = -2 } +nonstandard_style = { level = "warn", priority = -2 } +# refiing_impl_trait - Not needed for this project +rust_2018_compatibility = { level = "warn", priority = -2 } +rust_2018_idioms = { level = "warn", priority = -2 } +rust_2021_compatibility = { level = "warn", priority = -2 } +rust_2024_compatibility = { level = "warn", priority = -2 } +unused = { level = "warn", priority = -2 } + +unknown_lints = { level = "warn", priority = -1 } +renamed_and_removed_lints = { level = "warn", priority = -1 } + +# Allow certain configs in the check-cfg linting +unexpected_cfgs = { level = "warn", check-cfg = ["cfg(tarpaulin_include)"] } + +# absolute_paths_not_starting_with_crate - group rust_2018_compatibility +# box-pointers - no reason to disallow this in project +deprecated_in_future = "warn" +# elided_lifetimes_in_paths - group: rust_2018_idioms +# explicit_outlives_requirements - group: rust_2018_idioms +ffi_unwind_calls = "warn" +# fuzzy_provenance_casts - unstable +# impl_trait_overcaptures - unstable +# keyword_idents_2018 - group: rust_2018_compatibility +# keyword_idents_2024 - group: rust_2024_compatibility +# let_underscore_drop - group: let_underscore +# lossy_provenance_casts - unstable +macro_use_extern_crate = "warn" +meta_variable_misuse = "warn" +missing_abi = "warn" +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +# missing_docs - not requiring docs in this project +# multiple_supertrait_upcastable - unstable +# must_not_suspend - unstable +non_ascii_idents = "warn" +# non_exhaustive_omitted_patterns - unstable +redundant_lifetimes = "warn" +# rust_2021_incompatible_closure_captures - group: rust_2021_compatibility +# rust_2021_incompatible_or_patterns - group: rust_2021_compatibility +# rust_2021_prefixes_incompatible_syntax - group: rust_2021_compatibility +# rust_2021_prelude_collisions - group: rust_2021_compatibility +# rust_2024_incompatible_pat - unstable +single_use_lifetimes = "warn" +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unit-bindings = "warn" +unnameable_types = "warn" +unreachable_pub = "warn" +unsafe_code = "warn" +# unsafe_op_in_unsafe_fn - group: rust_2024_compatibility +# unstable_features - deprecated +unused_crate_dependencies = "warn" +# unused_extern_crates - group: unused, rust_2018_idioms +unused_import_braces = "warn" +unused_lifetimes = "warn" +# unused_macro_rules - group: unused +unused_qualifications = "warn" +unused_results = "warn" +variant_size_differences = "warn" + +[lints.clippy] +all = { level = "warn", priority = -2 } +cargo = { level = "warn", priority = -2 } +pedantic = { level = "warn", priority = -2 } +restriction = { level = "warn", priority = -2 } + +# Clippy restricts enabling restricted lints +blanket_clippy_restriction_lints = { level = "allow", priority = 5 } + +implicit_return = "allow" +min_ident_chars = "allow" +missing_docs_in_private_items = "allow" +redundant_pub_crate = "allow" +tabs_in_doc_comments = "allow" + +[lints.rustdoc] +bare_urls = "warn" +broken_intra_doc_links = "warn" +invalid_codeblock_attributes = "warn" +invalid_html_tags = "warn" +missing_crate_level_docs = "allow" +private_doc_tests = "warn" +private_intra_doc_links = "warn" diff --git a/src/lib.rs b/src/lib.rs index eb2f7a6..98162e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,63 +1,3 @@ -#![deny( - future_incompatible, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - unused, - warnings -)] -// rustc's additional allowed by default lints -#![deny( - absolute_paths_not_starting_with_crate, - deprecated_in_future, - elided_lifetimes_in_paths, - explicit_outlives_requirements, - keyword_idents, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - missing_docs, - non_ascii_idents, - noop_method_call, - or_patterns_back_compat, - pointer_structural_match, - semicolon_in_expressions_from_macros, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_code, - unsafe_op_in_unsafe_fn, - unstable_features, - unused_crate_dependencies, - unused_extern_crates, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_results, - variant_size_differences -)] -// enable all of Clippy's lints -#![deny(clippy::all, clippy::cargo, clippy::nursery, clippy::pedantic, clippy::restriction)] -#![allow( - clippy::blanket_clippy_restriction_lints, - clippy::implicit_return, - clippy::missing_docs_in_private_items, - clippy::redundant_pub_crate, - clippy::tabs_in_doc_comments -)] -#![deny( - rustdoc::bare_urls, - rustdoc::broken_intra_doc_links, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_html_tags, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::private_intra_doc_links -)] - //! # Captur //! //! Starting in Rust 2021, Rust will no longer capture whole structs and instead will only capture a