From e6c17461a36133af220d6bb9e93001731f540883 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 11 Nov 2024 14:08:20 +0000 Subject: [PATCH] rust: Provide and use a workspace.lints table Provide and use a `workspace.lints` table. This makes it easier to maintain and to enforce one coding style. Let's explicitly disable the `missing_docs` linting rule for tests. MSRV for the lints table is 1.74 [1] [1] https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table Signed-off-by: Marc Hartmayer Reviewed-by: Steffen Eiden Acked-by: Finn Callies Signed-off-by: Steffen Eiden --- rust/Cargo.toml | 8 ++++++++ rust/pv/Cargo.toml | 3 +++ rust/pv/src/lib.rs | 8 -------- rust/pv/tests/add_secret_request.rs | 2 ++ rust/pv/tests/cert_verifier.rs | 1 + rust/pv_core/Cargo.toml | 3 +++ rust/pv_core/src/lib.rs | 8 -------- rust/pvattest/Cargo.toml | 3 +++ rust/pvattest/build.rs | 1 + rust/pvattest/src/main.rs | 1 + rust/pvsecret/Cargo.toml | 3 +++ rust/pvsecret/build.rs | 1 + rust/pvsecret/src/main.rs | 1 + 13 files changed, 27 insertions(+), 16 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index cf9f4026..5fc718f7 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -15,5 +15,13 @@ edition = "2021" license = "MIT" rust-version = "1.75.0" +[workspace.lints.rust] +missing_docs = "deny" +missing_debug_implementations = "warn" +trivial_numeric_casts = "warn" +unstable_features = "warn" +unused_import_braces = "warn" +unused_qualifications = "warn" + [profile.release] lto = true diff --git a/rust/pv/Cargo.toml b/rust/pv/Cargo.toml index b04f65f6..02a2e1a1 100644 --- a/rust/pv/Cargo.toml +++ b/rust/pv/Cargo.toml @@ -10,6 +10,9 @@ repository = "https://github.com/ibm-s390-linux/s390-tools/tree/master/rust" categories = ["hardware-support"] readme = "README.md" +[lints] +workspace = true + [dependencies] byteorder = "1.3" curl = "0.4.44" diff --git a/rust/pv/src/lib.rs b/rust/pv/src/lib.rs index 1adcb3c1..26f95b98 100644 --- a/rust/pv/src/lib.rs +++ b/rust/pv/src/lib.rs @@ -2,14 +2,6 @@ // // Copyright IBM Corp. 2023, 2024 -#![deny(missing_docs)] -#![warn( - missing_debug_implementations, - trivial_numeric_casts, - unstable_features, - unused_import_braces, - unused_qualifications -)] #![doc = include_str!("../README.md")] //! # Library for Protected Virtualization (PV) related tools //! diff --git a/rust/pv/tests/add_secret_request.rs b/rust/pv/tests/add_secret_request.rs index 257a3e5c..c576a7a3 100644 --- a/rust/pv/tests/add_secret_request.rs +++ b/rust/pv/tests/add_secret_request.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT // // Copyright IBM Corp. 2023 + +#![allow(missing_docs)] use openssl::{ ec::{EcGroup, EcKey}, nid::Nid, diff --git a/rust/pv/tests/cert_verifier.rs b/rust/pv/tests/cert_verifier.rs index dac3fe80..04145748 100644 --- a/rust/pv/tests/cert_verifier.rs +++ b/rust/pv/tests/cert_verifier.rs @@ -2,6 +2,7 @@ // // Copyright IBM Corp. 2023 +#![allow(missing_docs)] use s390_pv::request::CertVerifier; use s390_pv::test_utils::*; use s390_pv::{Error, HkdVerifyErrorType::*}; diff --git a/rust/pv_core/Cargo.toml b/rust/pv_core/Cargo.toml index 98641615..5311cc80 100644 --- a/rust/pv_core/Cargo.toml +++ b/rust/pv_core/Cargo.toml @@ -12,6 +12,9 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true + [dependencies] libc = "0.2.49" log = { version = "0.4.6", features = ["std", "release_max_level_debug"] } diff --git a/rust/pv_core/src/lib.rs b/rust/pv_core/src/lib.rs index d351d2d9..349c0b28 100644 --- a/rust/pv_core/src/lib.rs +++ b/rust/pv_core/src/lib.rs @@ -1,14 +1,6 @@ // SPDX-License-Identifier: MIT // // Copyright IBM Corp. 2023, 2024 -#![deny(missing_docs)] -#![warn( - missing_debug_implementations, - trivial_numeric_casts, - unstable_features, - unused_import_braces, - unused_qualifications -)] #![doc = include_str!("../README.md")] mod confidential; mod error; diff --git a/rust/pvattest/Cargo.toml b/rust/pvattest/Cargo.toml index c48340e2..c46159ca 100644 --- a/rust/pvattest/Cargo.toml +++ b/rust/pvattest/Cargo.toml @@ -5,6 +5,9 @@ edition.workspace = true license.workspace = true rust-version.workspace = true +[lints] +workspace = true + [dependencies] anyhow = { version = "1.0.70", features = ["std"] } byteorder = "1.3" diff --git a/rust/pvattest/build.rs b/rust/pvattest/build.rs index 4c79d3f9..91212adf 100644 --- a/rust/pvattest/build.rs +++ b/rust/pvattest/build.rs @@ -2,6 +2,7 @@ // // Copyright IBM Corp. 2024 // it under the terms of the MIT license. See LICENSE for details. +#![allow(missing_docs)] use clap::CommandFactory; use clap_complete::{generate_to, Shell}; diff --git a/rust/pvattest/src/main.rs b/rust/pvattest/src/main.rs index 6c3d8fd3..9e756b9b 100644 --- a/rust/pvattest/src/main.rs +++ b/rust/pvattest/src/main.rs @@ -2,6 +2,7 @@ // // Copyright IBM Corp. 2024 +#![allow(missing_docs)] mod cli; mod cmd; mod exchange; diff --git a/rust/pvsecret/Cargo.toml b/rust/pvsecret/Cargo.toml index 4e775e38..0227d979 100644 --- a/rust/pvsecret/Cargo.toml +++ b/rust/pvsecret/Cargo.toml @@ -5,6 +5,9 @@ edition.workspace = true license.workspace = true rust-version.workspace = true +[lints] +workspace = true + [dependencies] anyhow = { version = "1.0.70", features = ["std"] } clap = { version ="4.1", features = ["derive", "wrap_help"]} diff --git a/rust/pvsecret/build.rs b/rust/pvsecret/build.rs index 7c9bb779..f5054cad 100644 --- a/rust/pvsecret/build.rs +++ b/rust/pvsecret/build.rs @@ -3,6 +3,7 @@ // Copyright IBM Corp. 2024 // it under the terms of the MIT license. See LICENSE for details. +#![allow(missing_docs)] use clap_complete::{generate_to, Shell}; use std::env; use std::io::Error; diff --git a/rust/pvsecret/src/main.rs b/rust/pvsecret/src/main.rs index 71f8dab1..502a6ea0 100644 --- a/rust/pvsecret/src/main.rs +++ b/rust/pvsecret/src/main.rs @@ -2,6 +2,7 @@ // // Copyright IBM Corp. 2023, 2024 +#![allow(missing_docs)] mod cli; mod cmd;