From f74a0febf829952ae562b77aee38bf3fc4ccd4d6 Mon Sep 17 00:00:00 2001 From: rami3l Date: Thu, 21 Dec 2023 13:16:48 +0800 Subject: [PATCH 1/3] build: move lints config to `Cargo.toml` --- Cargo.toml | 18 ++++++++++++++++++ crates/pacaptr-macros/Cargo.toml | 3 +++ crates/pacaptr-macros/src/lib.rs | 10 ---------- src/lib.rs | 13 +------------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4dbf52fb8b..e630cfbb50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,21 @@ pre-release-commit-message = "dist: cut a new release" # https://github.com/crate-ci/cargo-release/issues/333 tag = false +[workspace.lints.rust] +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +trivial_numeric_casts = "warn" +unsafe_code = "forbid" +unused_allocation = "warn" + +[workspace.lints.clippy] +doc_markdown = "warn" +nursery = "warn" +pedantic = "warn" + +[workspace.lints.rustdoc] +broken_intra_doc_links = "warn" + [package] name = "pacaptr" version = "0.20.1" @@ -132,3 +147,6 @@ lto = true opt-level = "z" panic = "abort" strip = "symbols" + +[lints] +workspace = true diff --git a/crates/pacaptr-macros/Cargo.toml b/crates/pacaptr-macros/Cargo.toml index 7d8874cd07..09a65d9727 100644 --- a/crates/pacaptr-macros/Cargo.toml +++ b/crates/pacaptr-macros/Cargo.toml @@ -21,3 +21,6 @@ quote = "1.0.33" regex = "1.10.2" syn = "2.0.39" tabled = "0.14.0" + +[lints] +workspace = true diff --git a/crates/pacaptr-macros/src/lib.rs b/crates/pacaptr-macros/src/lib.rs index 921c2f2956..94d6507acf 100644 --- a/crates/pacaptr-macros/src/lib.rs +++ b/crates/pacaptr-macros/src/lib.rs @@ -1,13 +1,3 @@ -#![forbid(unsafe_code)] -#![warn( - clippy::doc_markdown, - clippy::nursery, - clippy::pedantic, - rustdoc::broken_intra_doc_links, - trivial_numeric_casts, - unused_allocation -)] - mod compat_table; mod test_dsl; diff --git a/src/lib.rs b/src/lib.rs index 23ee3c2a8d..f173aad5d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,18 +15,7 @@ in `-Sp`. "##} )] -#![forbid(unsafe_code)] -#![warn( - clippy::doc_markdown, - clippy::nursery, - clippy::pedantic, - missing_copy_implementations, - missing_debug_implementations, - missing_docs, - rustdoc::broken_intra_doc_links, - trivial_numeric_casts, - unused_allocation -)] +#![warn(missing_docs)] pub mod config; pub mod error; From 47c94772d231143f7cf7ac8aedbc224a6621cd1a Mon Sep 17 00:00:00 2001 From: rami3l Date: Thu, 21 Dec 2023 13:16:49 +0800 Subject: [PATCH 2/3] style: apply clippy fixes --- build.rs | 2 +- tests/common.rs | 30 +++++++++++++++++------------- tests/port.rs | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/build.rs b/build.rs index 0db1625f09..d764d79c1f 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,3 @@ fn main() { - built::write_built_file().expect("failed to acquire build-time information") + built::write_built_file().expect("failed to acquire build-time information"); } diff --git a/tests/common.rs b/tests/common.rs index cdd9bafce6..8976e9e5ea 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -1,4 +1,5 @@ #![cfg(feature = "test")] +#![allow(clippy::missing_panics_doc)] use itertools::{chain, Itertools}; pub use pacaptr_macros::test_dsl; @@ -26,19 +27,22 @@ const fn cmd_prefix() -> (&'static str, &'static [&'static str]) { } } +#[derive(Debug)] pub struct Test<'t> { sequence: Vec<(Input<'t>, Vec<&'t str>)>, pending_input: Option>, } impl<'t> Test<'t> { - pub fn new() -> Self { + #[must_use] + pub const fn new() -> Self { Test { sequence: Vec::new(), pending_input: None, } } + #[must_use] pub fn pacaptr(mut self, args: &'t [&str], flags: &'t [&str]) -> Self { // Guard against consecutive inputs without calling `self.output()`. if self.pending_input.is_some() { @@ -49,6 +53,7 @@ impl<'t> Test<'t> { } #[allow(dead_code)] + #[must_use] pub fn exec(mut self, cmd: &'t [&str], kws: &'t [&str]) -> Self { // Guard against consecutive inputs without calling `self.output()`. if self.pending_input.is_some() { @@ -58,9 +63,10 @@ impl<'t> Test<'t> { self } + #[must_use] pub fn output(mut self, out: &'t [&str]) -> Self { if let Some(cmd) = self.pending_input.take() { - self.sequence.push((cmd, out.into())) + self.sequence.push((cmd, out.into())); } else if let Some((_cmd, outs)) = self.sequence.last_mut() { outs.extend(out); } else { @@ -71,23 +77,21 @@ impl<'t> Test<'t> { pub fn run(&self) { let try_match = |out: &str, patterns: &[&str]| { - patterns.iter().for_each(|p| { + for &p in patterns { let re = RegexBuilder::new(p).multi_line(true).build().unwrap(); let is_match = re.is_match(out); - assert!(is_match, "Failed with pattern `{p}`, got `{out}`") - }) + assert!(is_match, "Failed with pattern `{p}`, got `{out}`"); + } }; // Prevent running the test before `self.sequence` is configured. - if self.sequence.is_empty() { - panic!("Test sequence not yet configured") - } + assert!( + !self.sequence.is_empty(), + "Test sequence not yet configured" + ); let s = Shell::new().unwrap(); - self.sequence.iter().for_each(|(input, patterns)| { - // got = cmd.run() - // if not matches_all(got, patterns): - // raise MatchError(some_msg) + for (input, patterns) in &self.sequence { let (sh, sh_args) = cmd_prefix(); let cmd = match *input { Input::Exec { cmd, kws } => chain!(cmd, kws).join(" "), @@ -102,7 +106,7 @@ impl<'t> Test<'t> { .unwrap(); println!("{got}"); try_match(&got, patterns); - }) + } } } diff --git a/tests/port.rs b/tests/port.rs index be93046186..b1788fc6e1 100644 --- a/tests/port.rs +++ b/tests/port.rs @@ -1,4 +1,4 @@ -//! A big part of these tests are copied from https://guide.macports.org/#using.port.installed. +//! A big part of these tests are copied from . #![cfg(all(target_os = "macos", feature = "test"))] From 31e3571f86efb3a0f5d74eb50d171f6fe2ef346b Mon Sep 17 00:00:00 2001 From: rami3l Date: Thu, 21 Dec 2023 13:16:49 +0800 Subject: [PATCH 3/3] chore(deps): update `Cargo.toml` --- Cargo.lock | 126 +++++++++++++++---------------- Cargo.toml | 10 +-- crates/pacaptr-macros/Cargo.toml | 8 +- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 12283bb9bc..bde37c0f18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" dependencies = [ "anstyle", "anstyle-parse", @@ -48,47 +48,47 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "59d2a3357dde987206219e78ecfbbb6e8dad06cbb65292758d3270e6254f7355" [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", ] [[package]] @@ -178,9 +178,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.10" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.9" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -207,7 +207,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", ] [[package]] @@ -467,11 +467,11 @@ checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "home" -version = "0.5.5" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -541,9 +541,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libgit2-sys" @@ -634,9 +634,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", @@ -675,9 +675,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pacaptr" @@ -724,15 +724,15 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.39", + "syn 2.0.42", "tabled", ] [[package]] name = "papergrid" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ccbe15f2b6db62f9a9871642746427e297b0ceb85f9a7f1ee5ff47d184d0c8" +checksum = "9ad43c07024ef767f9160710b3a6773976194758c7919b17e63b863db0bdf7fb" dependencies = [ "bytecount", "fnv", @@ -747,9 +747,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pear" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a386cd715229d399604b50d1361683fe687066f42d56f54be995bc6868f71c" +checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" dependencies = [ "inlinable_string", "pear_codegen", @@ -758,14 +758,14 @@ dependencies = [ [[package]] name = "pear_codegen" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f0f13dac8069c139e8300a6510e3f4143ecf5259c60b116a9b271b4ca0d54" +checksum = "2e22670e8eb757cff11d6c199ca7b987f352f0346e0be4dd23869ec72cb53c77" dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.39", + "syn 2.0.42", ] [[package]] @@ -788,9 +788,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" [[package]] name = "proc-macro-error" @@ -833,7 +833,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", "version_check", "yansi", ] @@ -904,9 +904,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.26" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags 2.4.1", "errno", @@ -932,14 +932,14 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", ] [[package]] name = "serde_spanned" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -987,9 +987,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" dependencies = [ "proc-macro2", "quote", @@ -998,9 +998,9 @@ dependencies = [ [[package]] name = "tabled" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe9c3632da101aba5131ed63f9eed38665f8b3c68703a6bb18124835c1a5d22" +checksum = "4c998b0c8b921495196a48aabaf1901ff28be0760136e31604f7967b0792050e" dependencies = [ "papergrid", "tabled_derive", @@ -1009,9 +1009,9 @@ dependencies = [ [[package]] name = "tabled_derive" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99f688a08b54f4f02f0a3c382aefdb7884d3d69609f785bd253dc033243e3fe4" +checksum = "4c138f99377e5d653a371cdad263615634cfc8467685dfe8e73e2b8e98f44b17" dependencies = [ "heck", "proc-macro-error", @@ -1041,22 +1041,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", ] [[package]] @@ -1086,9 +1086,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.34.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -1109,7 +1109,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.42", ] [[package]] @@ -1208,9 +1208,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" @@ -1512,9 +1512,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.19" +version = "0.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index e630cfbb50..e8c026b319 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,9 +94,9 @@ built = { version = "0.7.1", features = ["git2"] } xshell = "0.2.5" [dependencies] -async-trait = "0.1.74" +async-trait = "0.1.75" bytes = "1.5.0" -clap = { version = "4.4.10", features = ["cargo", "derive"] } +clap = { version = "4.4.11", features = ["cargo", "derive"] } console = "0.15.7" ctrlc = { version = "3.4.1", features = ["termination"] } dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } @@ -106,7 +106,7 @@ futures = { version = "0.3.29", default-features = false, features = ["std"] } indoc = "2.0.4" itertools = "0.12.0" macro_rules_attribute = "0.2.0" -once_cell = "1.18.0" +once_cell = "1.19.0" pacaptr-macros = { path = "crates/pacaptr-macros", version = "0.20.1" } paste = "1.0.14" regex = { version = "1.10.2", default-features = false, features = [ @@ -117,8 +117,8 @@ regex = { version = "1.10.2", default-features = false, features = [ ] } serde = { version = "1.0.193", features = ["derive"] } tap = "1.0.1" -thiserror = "1.0.50" -tokio = { version = "1.34.0", features = [ +thiserror = "1.0.51" +tokio = { version = "1.35.1", features = [ "io-std", "io-util", "macros", diff --git a/crates/pacaptr-macros/Cargo.toml b/crates/pacaptr-macros/Cargo.toml index 09a65d9727..0ec042bb06 100644 --- a/crates/pacaptr-macros/Cargo.toml +++ b/crates/pacaptr-macros/Cargo.toml @@ -12,15 +12,15 @@ description = "Implementation of several macros used in pacaptr." proc-macro = true [dependencies] -anyhow = "1.0.75" +anyhow = "1.0.76" itertools = "0.12.0" litrs = "0.4.1" -once_cell = "1.18.0" +once_cell = "1.19.0" proc-macro2 = "1.0.70" quote = "1.0.33" regex = "1.10.2" -syn = "2.0.39" -tabled = "0.14.0" +syn = "2.0.42" +tabled = "0.15.0" [lints] workspace = true