From 847d6898f17ffba73210bab16c9832f6ebdf897e Mon Sep 17 00:00:00 2001 From: Adam Spofford <93943719+adamspofford-dfinity@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:23:47 -0700 Subject: [PATCH] fix: Remove global state from `ic-cdk-macros` (#430) * Remove global state from ic-cdk-macros * Update version and changelog --- Cargo.lock | 6 +++--- src/ic-cdk-macros/CHANGELOG.md | 6 ++++++ src/ic-cdk-macros/Cargo.toml | 2 +- src/ic-cdk-macros/src/export.rs | 8 ++++---- src/ic-cdk-macros/src/lib.rs | 7 ------- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd5768168..bfa39101c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -919,7 +919,7 @@ dependencies = [ [[package]] name = "ic-cdk-macros" -version = "0.8.0" +version = "0.8.1" dependencies = [ "candid", "ic-cdk", @@ -1475,9 +1475,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5907a1b7c277254a8b15170f6e7c97cfa60ee7872a3217663bb81151e48184bb" dependencies = [ "proc-macro2", ] diff --git a/src/ic-cdk-macros/CHANGELOG.md b/src/ic-cdk-macros/CHANGELOG.md index 2d9f47ec7..82a803bdf 100644 --- a/src/ic-cdk-macros/CHANGELOG.md +++ b/src/ic-cdk-macros/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [0.8.1] - 2023-10-02 + +### Fixed + +- Macros no longer use global state in the names of functions. JetBrains IDEs should no longer produce spurious errors. (#430) + ## [0.8.0] - 2023-09-18 ### Changed diff --git a/src/ic-cdk-macros/Cargo.toml b/src/ic-cdk-macros/Cargo.toml index 8e85ee76f..d127d4495 100644 --- a/src/ic-cdk-macros/Cargo.toml +++ b/src/ic-cdk-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ic-cdk-macros" -version = "0.8.0" # no need to sync with ic-cdk +version = "0.8.1" # no need to sync with ic-cdk authors.workspace = true edition.workspace = true license.workspace = true diff --git a/src/ic-cdk-macros/src/export.rs b/src/ic-cdk-macros/src/export.rs index 38c432d7b..f6b2440e5 100644 --- a/src/ic-cdk-macros/src/export.rs +++ b/src/ic-cdk-macros/src/export.rs @@ -1,5 +1,5 @@ use proc_macro2::{Ident, Span, TokenStream}; -use quote::quote; +use quote::{format_ident, quote}; use serde::Deserialize; use serde_tokenstream::from_tokenstream; use std::fmt::Formatter; @@ -57,7 +57,7 @@ impl std::fmt::Display for MethodType { fn get_args(method: MethodType, signature: &Signature) -> Result)>, Error> { // We only need the tuple of arguments, not their types. Magic of type inference. let mut args = vec![]; - for ref arg in &signature.inputs { + for (i, arg) in signature.inputs.iter().enumerate() { let (ident, ty) = match arg { FnArg::Receiver(r) => { return Err(Error::new( @@ -73,7 +73,7 @@ fn get_args(method: MethodType, signature: &Signature) -> Result u32 { - NEXT_ID.fetch_add(1, Ordering::SeqCst) -} - fn handle_debug_and_errors( cb: F, name: &str,