From 1a138ed6c920725a670cc33740fe51c9b8907812 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 10 Sep 2024 21:22:38 +0200 Subject: [PATCH] Use workspace lint configuration instead of rustflags hack --- .cargo/config.toml | 35 ------------------- Cargo.toml | 34 ++++++++++++++++++ crates/ruma-appservice-api/Cargo.toml | 3 ++ crates/ruma-client-api/Cargo.toml | 3 ++ crates/ruma-client/Cargo.toml | 3 ++ crates/ruma-common/Cargo.toml | 3 ++ crates/ruma-events/Cargo.toml | 3 ++ crates/ruma-federation-api/Cargo.toml | 3 ++ crates/ruma-html/Cargo.toml | 3 ++ crates/ruma-identifiers-validation/Cargo.toml | 3 ++ crates/ruma-identity-service-api/Cargo.toml | 3 ++ crates/ruma-macros/Cargo.toml | 3 ++ crates/ruma-push-gateway-api/Cargo.toml | 3 ++ crates/ruma-server-util/Cargo.toml | 3 ++ crates/ruma-signatures/Cargo.toml | 3 ++ crates/ruma-state-res/Cargo.toml | 3 ++ crates/ruma/Cargo.toml | 3 ++ xtask/Cargo.toml | 3 ++ 18 files changed, 82 insertions(+), 35 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 14d6a664..e3d9d7d2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,40 +4,5 @@ xtask = "run --package xtask --" [doc.extern-map.registries] crates-io = "https://docs.rs/" -[target.'cfg(all())'] -rustflags = [ - "-Wrust_2018_idioms", - "-Wsemicolon_in_expressions_from_macros", - "-Wunreachable_pub", - "-Wunused_import_braces", - "-Wunused_qualifications", - "-Wclippy::branches_sharing_code", - "-Wclippy::cloned_instead_of_copied", - "-Wclippy::dbg_macro", - "-Wclippy::disallowed_types", - "-Wclippy::empty_line_after_outer_attr", - "-Wclippy::exhaustive_enums", - "-Wclippy::exhaustive_structs", - "-Wclippy::inefficient_to_string", - "-Wclippy::macro_use_imports", - "-Wclippy::map_flatten", - "-Wclippy::missing_enforced_import_renames", - # Disabled because it triggers for tests/foo/mod.rs which can't be replaced - # easily. Locally allowing it also doesn't seem to work. - #"-Wclippy::mod_module_files", - "-Wclippy::mut_mut", - "-Aclippy::new_without_default", - "-Wclippy::nonstandard_macro_braces", - "-Wclippy::semicolon_if_nothing_returned", - "-Wclippy::str_to_string", - "-Wclippy::todo", - "-Wclippy::unreadable_literal", - "-Wclippy::unseparated_literal_suffix", - "-Wclippy::wildcard_imports", - # Disabled temporarily because it triggers false positives for types with - # generics. - "-Aclippy::arc_with_non_send_sync", -] - [unstable] rustdoc-map = true diff --git a/Cargo.toml b/Cargo.toml index f870f6ee..ee228792 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,40 @@ tracing = { version = "0.1.37", default-features = false, features = ["std"] } url = { version = "2.5.0" } web-time = "1.1.0" +[workspace.lints.rust] +rust_2018_idioms = { level = "warn", priority = -1 } +semicolon_in_expressions_from_macros = "warn" +unreachable_pub = "warn" +unused_import_braces = "warn" +unused_qualifications = "warn" + +[workspace.lints.clippy] +branches_sharing_code = "warn" +cloned_instead_of_copied = "warn" +dbg_macro = "warn" +disallowed_types = "warn" +empty_line_after_outer_attr = "warn" +exhaustive_enums = "warn" +exhaustive_structs = "warn" +inefficient_to_string = "warn" +macro_use_imports = "warn" +map_flatten = "warn" +missing_enforced_import_renames = "warn" +mod_module_files = "warn" +mut_mut = "warn" +nonstandard_macro_braces = "warn" +semicolon_if_nothing_returned = "warn" +str_to_string = "warn" +todo = "warn" +unreadable_literal = "warn" +unseparated_literal_suffix = "warn" +wildcard_imports = "warn" + +# Not that good of a lint +new_without_default = "allow" +# Disabled temporarily because it triggers false positives for types with generics. +arc_with_non_send_sync = "allow" + [profile.dev] # Speeds up test times by more than 10% in a simple test # Set to 1 or 2 if you want to use a debugger in this workspace diff --git a/crates/ruma-appservice-api/Cargo.toml b/crates/ruma-appservice-api/Cargo.toml index 1779c570..645dcfdf 100644 --- a/crates/ruma-appservice-api/Cargo.toml +++ b/crates/ruma-appservice-api/Cargo.toml @@ -32,3 +32,6 @@ serde_json = { workspace = true } [dev-dependencies] assert_matches2 = { workspace = true } serde_yaml = "0.9.14" + +[lints] +workspace = true diff --git a/crates/ruma-client-api/Cargo.toml b/crates/ruma-client-api/Cargo.toml index 01927db0..64f19f66 100644 --- a/crates/ruma-client-api/Cargo.toml +++ b/crates/ruma-client-api/Cargo.toml @@ -72,3 +72,6 @@ web-time = { workspace = true } [dev-dependencies] assert_matches2 = { workspace = true } + +[lints] +workspace = true diff --git a/crates/ruma-client/Cargo.toml b/crates/ruma-client/Cargo.toml index 80c0f1ce..39c802d0 100644 --- a/crates/ruma-client/Cargo.toml +++ b/crates/ruma-client/Cargo.toml @@ -50,3 +50,6 @@ tracing = { version = "0.1.30", default-features = false, features = ["std"] } [dev-dependencies] ruma-client-api = { workspace = true, features = ["client"] } tokio-stream = "0.1.8" + +[lints] +workspace = true diff --git a/crates/ruma-common/Cargo.toml b/crates/ruma-common/Cargo.toml index 156c4cd1..3f7166bd 100644 --- a/crates/ruma-common/Cargo.toml +++ b/crates/ruma-common/Cargo.toml @@ -87,3 +87,6 @@ assert_matches2 = { workspace = true } assign = { workspace = true } maplit = { workspace = true } trybuild = "1.0.71" + +[lints] +workspace = true diff --git a/crates/ruma-events/Cargo.toml b/crates/ruma-events/Cargo.toml index c578f526..333fda3d 100644 --- a/crates/ruma-events/Cargo.toml +++ b/crates/ruma-events/Cargo.toml @@ -93,3 +93,6 @@ trybuild = "1.0.71" name = "event_deserialize" harness = false required-features = ["criterion"] + +[lints] +workspace = true diff --git a/crates/ruma-federation-api/Cargo.toml b/crates/ruma-federation-api/Cargo.toml index 11a671d9..16e79e9c 100644 --- a/crates/ruma-federation-api/Cargo.toml +++ b/crates/ruma-federation-api/Cargo.toml @@ -45,3 +45,6 @@ serde_json = { workspace = true } [dev-dependencies] assert_matches2 = { workspace = true } http = { workspace = true } + +[lints] +workspace = true diff --git a/crates/ruma-html/Cargo.toml b/crates/ruma-html/Cargo.toml index ad044eec..982c75eb 100644 --- a/crates/ruma-html/Cargo.toml +++ b/crates/ruma-html/Cargo.toml @@ -26,3 +26,6 @@ wildmatch = "2.0.0" [dev-dependencies] assert_matches2 = { workspace = true } + +[lints] +workspace = true diff --git a/crates/ruma-identifiers-validation/Cargo.toml b/crates/ruma-identifiers-validation/Cargo.toml index 63379d2b..a4cc6d60 100644 --- a/crates/ruma-identifiers-validation/Cargo.toml +++ b/crates/ruma-identifiers-validation/Cargo.toml @@ -25,3 +25,6 @@ compat-user-id = [] [dependencies] js_int = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true diff --git a/crates/ruma-identity-service-api/Cargo.toml b/crates/ruma-identity-service-api/Cargo.toml index 62cd8748..1ca77119 100644 --- a/crates/ruma-identity-service-api/Cargo.toml +++ b/crates/ruma-identity-service-api/Cargo.toml @@ -25,3 +25,6 @@ serde = { workspace = true } [dev-dependencies] serde_json = { workspace = true } + +[lints] +workspace = true diff --git a/crates/ruma-macros/Cargo.toml b/crates/ruma-macros/Cargo.toml index 6c62f4a6..3fdb6dab 100644 --- a/crates/ruma-macros/Cargo.toml +++ b/crates/ruma-macros/Cargo.toml @@ -30,3 +30,6 @@ ruma-identifiers-validation = { workspace = true } serde = { workspace = true } syn = { version = "2.0.2", features = ["extra-traits", "full", "visit"] } toml = { version = "0.8.2", default-features = false, features = ["parse"] } + +[lints] +workspace = true diff --git a/crates/ruma-push-gateway-api/Cargo.toml b/crates/ruma-push-gateway-api/Cargo.toml index b41393fd..bb7ad52d 100644 --- a/crates/ruma-push-gateway-api/Cargo.toml +++ b/crates/ruma-push-gateway-api/Cargo.toml @@ -25,3 +25,6 @@ ruma-common = { workspace = true, features = ["api"] } ruma-events = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } + +[lints] +workspace = true diff --git a/crates/ruma-server-util/Cargo.toml b/crates/ruma-server-util/Cargo.toml index 93fc6d70..a6fc4fd2 100644 --- a/crates/ruma-server-util/Cargo.toml +++ b/crates/ruma-server-util/Cargo.toml @@ -24,3 +24,6 @@ tracing = { workspace = true } [dev-dependencies] tracing-subscriber = "0.3.16" + +[lints] +workspace = true diff --git a/crates/ruma-signatures/Cargo.toml b/crates/ruma-signatures/Cargo.toml index 103875ef..b30a57e4 100644 --- a/crates/ruma-signatures/Cargo.toml +++ b/crates/ruma-signatures/Cargo.toml @@ -33,3 +33,6 @@ thiserror = { workspace = true } [dev-dependencies] assert_matches2 = { workspace = true } insta = "1.31.0" + +[lints] +workspace = true diff --git a/crates/ruma-state-res/Cargo.toml b/crates/ruma-state-res/Cargo.toml index a97ac7a1..0b6b7744 100644 --- a/crates/ruma-state-res/Cargo.toml +++ b/crates/ruma-state-res/Cargo.toml @@ -40,3 +40,6 @@ tracing-subscriber = "0.3.16" name = "state_res_bench" harness = false required-features = ["criterion"] + +[lints] +workspace = true diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index bfb40d56..63c6c275 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -310,3 +310,6 @@ ruma-push-gateway-api = { workspace = true, optional = true } [dev-dependencies] serde = { workspace = true } + +[lints] +workspace = true diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 0b774e40..d97ef4e4 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -17,3 +17,6 @@ serde_json = { workspace = true } toml = { version = "0.8.2", default-features = false, features = ["parse"] } toml_edit = { version = "0.20.2", optional = true } xshell = "0.1.17" + +[lints] +workspace = true