From cca74a5f6b23742d77dc5db4312dfc40fd4a0fcc Mon Sep 17 00:00:00 2001 From: En-En <39373446+En-En-Code@users.noreply.github.com> Date: Mon, 17 Mar 2025 14:07:46 +0000 Subject: [PATCH] Remove paste dependency https://rustsec.org/advisories/RUSTSEC-2024-0436.html --- Cargo.lock | 7 ------- Cargo.toml | 1 - src/server/mod.rs | 18 +++++++----------- src/server/tests.rs | 31 +++++++++++++------------------ 4 files changed, 20 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cedd742..c753e79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -339,12 +339,6 @@ version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - [[package]] name = "pkg-config" version = "0.3.31" @@ -838,7 +832,6 @@ dependencies = [ "libc", "log", "macros", - "paste", "pretty_env_logger", "rustix", "sd-notify", diff --git a/Cargo.toml b/Cargo.toml index dea75ef..a0d0efa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ crate-type = ["lib"] [dependencies] bitflags = "2.5.0" -paste = "1.0.14" rustix = { workspace = true, features = ["event"] } wayland-client.workspace = true wayland-protocols = { workspace = true, features = ["client", "server", "staging", "unstable"] } diff --git a/src/server/mod.rs b/src/server/mod.rs index b360ee4..c17263c 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -308,7 +308,7 @@ macro_rules! handle_event_enum { $(#[$meta:meta])* $pub:vis enum $name:ident { $( $variant:ident($ty:ty) ),+ - } + } => $name_event:ident ) => { enum_try_from! { $(#[$meta])* @@ -317,19 +317,15 @@ macro_rules! handle_event_enum { } } - paste::paste! { - enum_try_from! { - #[derive(Debug)] - $pub enum [<$name Event>] { - $( $variant(<$ty as HandleEvent>::Event) ),+ - } + enum_try_from! { + #[derive(Debug)] + $pub enum $name_event { + $( $variant(<$ty as HandleEvent>::Event) ),+ } } impl HandleEvent for $name { - paste::paste! { - type Event = [<$name Event>]; - } + type Event = $name_event; fn handle_event(&mut self, event: Self::Event, state: &mut ServerState) { match self { @@ -370,7 +366,7 @@ pub(crate) enum Object { TabletPadGroup(TabletPadGroup), TabletPadRing(TabletPadRing), TabletPadStrip(TabletPadStrip) -} +} => ObjectEvent } diff --git a/src/server/tests.rs b/src/server/tests.rs index 68f5289..e0eaccc 100644 --- a/src/server/tests.rs +++ b/src/server/tests.rs @@ -1,6 +1,5 @@ use super::{ServerState, WindowDims}; use crate::xstate::{SetState, WmName}; -use paste::paste; use rustix::event::{poll, PollFd, PollFlags}; use std::collections::HashMap; use std::io::Write; @@ -71,7 +70,7 @@ macro_rules! with_optional { $( $field:ident: $type:ty ),+$(,)? - } + } => $name_optional:ident ) => { $( #[$attr] )? struct $name$(<$($lifetimes),+>)? { @@ -80,23 +79,19 @@ macro_rules! with_optional { ),+ } - paste! { - #[derive(Default)] - struct [< $name Optional >] { - $( - $field: Option<$type> - ),+ - } + #[derive(Default)] + struct $name_optional { + $( + $field: Option<$type> + ),+ } - paste! { - impl From<[<$name Optional>]> for $name { - fn from(opt: [<$name Optional>]) -> Self { - Self { - $( - $field: opt.$field.expect(concat!("uninitialized field ", stringify!($field))) - ),+ - } + impl From<$name_optional> for $name { + fn from(opt: $name_optional) -> Self { + Self { + $( + $field: opt.$field.expect(concat!("uninitialized field ", stringify!($field))) + ),+ } } } @@ -111,7 +106,7 @@ struct Compositor { shell: TestObject, seat: TestObject, tablet_man: TestObject -} +} => CompositorOptional }