diff --git a/Cargo.toml b/Cargo.toml index ecc0b1d..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,18 +14,17 @@ 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"] } -proc-macro-hack = "0.5" [dev-dependencies] serde_json = "1.0" 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/azure-pipelines.yml b/azure-pipelines.yml index 9cffc9f..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-04-23 + rust_lint_toolchain: nightly-2020-06-09 rust_flags: '' rust_features: '' rust_target_check: '' diff --git a/serde_closure_derive/Cargo.toml b/serde_closure_derive/Cargo.toml index d767781..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] @@ -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..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,35 +10,34 @@ //! 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)] -#![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..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,15 +180,12 @@ )] // 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 /// 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 +194,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 +202,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() {