From 3d7400b9fefc9d8707f4e15ed76d704fd33a6889 Mon Sep 17 00:00:00 2001 From: alecmocatta Date: Fri, 22 May 2020 18:01:50 +0100 Subject: [PATCH 1/3] Remove proc-macro-hack dependency as proc macro expressions are stable now --- Cargo.toml | 1 - azure-pipelines.yml | 2 +- serde_closure_derive/Cargo.toml | 1 - serde_closure_derive/src/lib.rs | 13 ++++++------- src/lib.rs | 5 +---- tests/test.rs | 4 ++-- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ecc0b1d..c042ba4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,6 @@ maintenance = { status = "actively-developed" } [dependencies] serde_closure_derive = { version = "=0.2.11", path = "serde_closure_derive" } serde = { version = "1.0", features = ["derive"] } -proc-macro-hack = "0.5" [dev-dependencies] serde_json = "1.0" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9cffc9f..cef7f3e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,7 +14,7 @@ jobs: endpoint: alecmocatta default: rust_toolchain: nightly - rust_lint_toolchain: nightly-2020-04-23 + rust_lint_toolchain: nightly-2020-05-23 rust_flags: '' rust_features: '' rust_target_check: '' diff --git a/serde_closure_derive/Cargo.toml b/serde_closure_derive/Cargo.toml index d767781..a1a7333 100644 --- a/serde_closure_derive/Cargo.toml +++ b/serde_closure_derive/Cargo.toml @@ -26,6 +26,5 @@ proc-macro = true [dependencies] proc-macro2 = { version = "1.0.1", default-features = false, features = ["span-locations"] } -proc-macro-hack = "0.5" quote = { version = "1.0.2", default-features = false } syn = { version = "1.0.5", default-features = false, features = ["clone-impls", "full", "parsing", "printing", "proc-macro"] } diff --git a/serde_closure_derive/src/lib.rs b/serde_closure_derive/src/lib.rs index 40f8d36..8219c6e 100644 --- a/serde_closure_derive/src/lib.rs +++ b/serde_closure_derive/src/lib.rs @@ -11,33 +11,32 @@ #![doc(html_root_url = "https://docs.rs/serde_closure_derive/0.2.11")] #![feature(proc_macro_diagnostic)] -#![allow(non_snake_case)] // due to proc-macro-hack can't apply this directly - -extern crate proc_macro; use proc_macro2::{Span, TokenStream}; -use proc_macro_hack::proc_macro_hack; use quote::{quote, ToTokens}; use std::{collections::HashSet, iter, iter::successors, mem::take, str}; use syn::{ parse::{Parse, ParseStream}, parse2, spanned::Spanned, token::Bracket, Arm, Block, Error, Expr, ExprArray, ExprAssign, ExprAssignOp, ExprAsync, ExprAwait, ExprBinary, ExprBlock, ExprBox, ExprBreak, ExprCall, ExprCast, ExprClosure, ExprField, ExprForLoop, ExprGroup, ExprIf, ExprIndex, ExprLet, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall, ExprParen, ExprPath, ExprRange, ExprReference, ExprRepeat, ExprReturn, ExprStruct, ExprTry, ExprTryBlock, ExprTuple, ExprType, ExprUnary, ExprUnsafe, ExprWhile, ExprYield, FieldValue, Ident, Local, Member, Pat, PatBox, PatIdent, PatReference, PatSlice, PatTuple, PatTupleStruct, PatType, Path, PathArguments, PathSegment, Stmt, Type, TypeInfer, TypeReference, UnOp }; -#[proc_macro_hack] +#[proc_macro] +#[allow(non_snake_case)] pub fn Fn(input: proc_macro::TokenStream) -> proc_macro::TokenStream { syn::parse::(input) .and_then(|closure| impl_fn_once(closure, Kind::Fn)) .unwrap_or_else(|err| err.to_compile_error()) .into() } -#[proc_macro_hack] +#[proc_macro] +#[allow(non_snake_case)] pub fn FnMut(input: proc_macro::TokenStream) -> proc_macro::TokenStream { syn::parse::(input) .and_then(|closure| impl_fn_once(closure, Kind::FnMut)) .unwrap_or_else(|err| err.to_compile_error()) .into() } -#[proc_macro_hack] +#[proc_macro] +#[allow(non_snake_case)] pub fn FnOnce(input: proc_macro::TokenStream) -> proc_macro::TokenStream { syn::parse::(input) .and_then(|closure| impl_fn_once(closure, Kind::FnOnce)) diff --git a/src/lib.rs b/src/lib.rs index e57dcb2..e76628c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -179,7 +179,7 @@ )] // from https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md #![allow(clippy::inline_always)] -use proc_macro_hack::proc_macro_hack; +// use proc_macro_hack::proc_macro_hack; /// Macro that wraps a closure, evaluating to a [`FnOnce`](structs::FnOnce) /// struct that implements [`std::ops::FnOnce`], [`Debug`](std::fmt::Debug), @@ -187,7 +187,6 @@ use proc_macro_hack::proc_macro_hack; /// various convenience traits. /// /// See the [readme](self) for examples. -#[proc_macro_hack(fake_call_site)] pub use serde_closure_derive::FnOnce; /// Macro that wraps a closure, evaluating to a [`FnMut`](structs::FnMut) struct @@ -196,7 +195,6 @@ pub use serde_closure_derive::FnOnce; /// various convenience traits. /// /// See the [readme](self) for examples. -#[proc_macro_hack(fake_call_site)] pub use serde_closure_derive::FnMut; /// Macro that wraps a closure, evaluating to a [`Fn`](structs::Fn) struct that @@ -205,7 +203,6 @@ pub use serde_closure_derive::FnMut; /// various convenience traits. /// /// See the [readme](self) for examples. -#[proc_macro_hack(fake_call_site)] pub use serde_closure_derive::Fn; #[doc(hidden)] diff --git a/tests/test.rs b/tests/test.rs index 4309d3d..b068f97 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1,10 +1,10 @@ #![deny(unsafe_code)] // TODO: make this forbid when unsafe in a macro doesn't trigger it (def_site?) +#![allow(clippy::no_effect, clippy::double_parens)] use serde::{de::DeserializeOwned, Serialize}; use std::{fmt::Debug, mem::size_of}; -#[macro_use] -extern crate serde_closure; +use serde_closure::{Fn, FnMut, FnOnce}; #[test] fn fn_ptr_size() { From 95e47400ef55e6c88f1c1a4059c74f2e7f27c79e Mon Sep 17 00:00:00 2001 From: alecmocatta Date: Fri, 22 May 2020 18:07:55 +0100 Subject: [PATCH 2/3] v0.2.12 --- Cargo.toml | 8 ++++---- README.md | 10 +++++----- serde_closure_derive/Cargo.toml | 6 +++--- serde_closure_derive/src/lib.rs | 7 ++++--- src/lib.rs | 9 ++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c042ba4..36aa6e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "serde_closure" -version = "0.2.11" +version = "0.2.12" license = "MIT OR Apache-2.0" authors = ["Alec Mocatta "] categories = ["development-tools","encoding","rust-patterns","network-programming"] @@ -14,16 +14,16 @@ This library provides macros that wrap closures to make them serializable and de """ repository = "https://github.com/alecmocatta/serde_closure" homepage = "https://github.com/alecmocatta/serde_closure" -documentation = "https://docs.rs/serde_closure/0.2.11" +documentation = "https://docs.rs/serde_closure/0.2.12" readme = "README.md" edition = "2018" [badges] -azure-devops = { project = "alecmocatta/serde_closure", pipeline = "tests" } +azure-devops = { project = "alecmocatta/serde_closure", pipeline = "tests", build = "10" } maintenance = { status = "actively-developed" } [dependencies] -serde_closure_derive = { version = "=0.2.11", path = "serde_closure_derive" } +serde_closure_derive = { version = "=0.2.12", path = "serde_closure_derive" } serde = { version = "1.0", features = ["derive"] } [dev-dependencies] diff --git a/README.md b/README.md index fed5d1b..17d07a1 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![Crates.io](https://img.shields.io/crates/v/serde_closure.svg?maxAge=86400)](https://crates.io/crates/serde_closure) [![MIT / Apache 2.0 licensed](https://img.shields.io/crates/l/serde_closure.svg?maxAge=2592000)](#License) -[![Build Status](https://dev.azure.com/alecmocatta/serde_closure/_apis/build/status/tests?branchName=master)](https://dev.azure.com/alecmocatta/serde_closure/_build/latest?definitionId=10&branchName=master) +[![Build Status](https://dev.azure.com/alecmocatta/serde_closure/_apis/build/status/tests?branchName=master)](https://dev.azure.com/alecmocatta/serde_closure/_build?definitionId=10) -[Docs](https://docs.rs/serde_closure/0.2.11) +[📖 Docs](https://docs.rs/serde_closure/0.2.12) | [💬 Chat](https://constellation.zulipchat.com/#narrow/stream/213236-subprojects) Serializable and debuggable closures. @@ -30,9 +30,9 @@ requires nightly Rust for the `unboxed_closures` and `fn_traits` features (rust issue [#29625](https://github.com/rust-lang/rust/issues/29625)). * There are three macros, - [`FnOnce`](https://docs.rs/serde_closure/0.2.11/serde_closure/macro.FnOnce.html), - [`FnMut`](https://docs.rs/serde_closure/0.2.11/serde_closure/macro.FnMut.html) - and [`Fn`](https://docs.rs/serde_closure/0.2.11/serde_closure/macro.Fn.html), + [`FnOnce`](https://docs.rs/serde_closure/0.2.12/serde_closure/macro.FnOnce.html), + [`FnMut`](https://docs.rs/serde_closure/0.2.12/serde_closure/macro.FnMut.html) + and [`Fn`](https://docs.rs/serde_closure/0.2.12/serde_closure/macro.Fn.html), corresponding to the three types of Rust closure. * Wrap your closure with one of the macros and it will now implement `Copy`, `Clone`, `PartialEq`, `Eq`, `Hash`, `PartialOrd`, `Ord`, `Serialize`, diff --git a/serde_closure_derive/Cargo.toml b/serde_closure_derive/Cargo.toml index a1a7333..db14aa2 100644 --- a/serde_closure_derive/Cargo.toml +++ b/serde_closure_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_closure_derive" -version = "0.2.11" +version = "0.2.12" license = "MIT OR Apache-2.0" authors = ["Alec Mocatta "] categories = ["development-tools","encoding","rust-patterns","network-programming"] @@ -14,11 +14,11 @@ See https://crates.io/crates/serde_closure for documentation. """ repository = "https://github.com/alecmocatta/serde_closure" homepage = "https://github.com/alecmocatta/serde_closure" -documentation = "https://docs.rs/serde_closure/0.2.11" +documentation = "https://docs.rs/serde_closure/0.2.12" edition = "2018" [badges] -azure-devops = { project = "alecmocatta/serde_closure", pipeline = "tests" } +azure-devops = { project = "alecmocatta/serde_closure", pipeline = "tests", build = "10" } maintenance = { status = "actively-developed" } [lib] diff --git a/serde_closure_derive/src/lib.rs b/serde_closure_derive/src/lib.rs index 8219c6e..d7dd9f6 100644 --- a/serde_closure_derive/src/lib.rs +++ b/serde_closure_derive/src/lib.rs @@ -1,7 +1,8 @@ //! Serializable and debuggable closures. //! -//! **[Crates.io](https://crates.io/crates/serde_closure) │ -//! [Repo](https://github.com/alecmocatta/serde_closure)** +//!

+//! 📦  Crates.io  â”‚  ðŸ“‘  GitHub  â”‚  ðŸ’¬  Chat +//!

//! //! This library provides macros that wrap closures to make them serializable //! and debuggable. @@ -9,7 +10,7 @@ //! See [`serde_closure`](https://docs.rs/serde_closure/) for //! documentation. -#![doc(html_root_url = "https://docs.rs/serde_closure_derive/0.2.11")] +#![doc(html_root_url = "https://docs.rs/serde_closure_derive/0.2.12")] #![feature(proc_macro_diagnostic)] use proc_macro2::{Span, TokenStream}; diff --git a/src/lib.rs b/src/lib.rs index e76628c..9c05306 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,8 @@ //! Serializable and debuggable closures. //! -//! **[Crates.io](https://crates.io/crates/serde_closure) │ -//! [Repo](https://github.com/alecmocatta/serde_closure)** +//!

+//! 📦  Crates.io  â”‚  ðŸ“‘  GitHub  â”‚  ðŸ’¬  Chat +//!

//! //! This library provides macros that wrap closures to make them serializable //! and debuggable. @@ -164,7 +165,7 @@ //! automatically serializable and deserializable with //! [`serde`](https://github.com/serde-rs/serde). -#![doc(html_root_url = "https://docs.rs/serde_closure/0.2.11")] +#![doc(html_root_url = "https://docs.rs/serde_closure/0.2.12")] #![feature(unboxed_closures, fn_traits)] #![warn( missing_copy_implementations, @@ -179,8 +180,6 @@ )] // from https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md #![allow(clippy::inline_always)] -// use proc_macro_hack::proc_macro_hack; - /// Macro that wraps a closure, evaluating to a [`FnOnce`](structs::FnOnce) /// struct that implements [`std::ops::FnOnce`], [`Debug`](std::fmt::Debug), /// [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize), and From 1dbc144427d12f5473745f553c899c0a49e1223f Mon Sep 17 00:00:00 2001 From: Alec Mocatta Date: Tue, 9 Jun 2020 20:47:39 +0100 Subject: [PATCH 3/3] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cef7f3e..1744b6c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,7 +14,7 @@ jobs: endpoint: alecmocatta default: rust_toolchain: nightly - rust_lint_toolchain: nightly-2020-05-23 + rust_lint_toolchain: nightly-2020-06-09 rust_flags: '' rust_features: '' rust_target_check: ''