diff --git a/.github/workflows/master.yaml b/.github/workflows/main.yaml similarity index 91% rename from .github/workflows/master.yaml rename to .github/workflows/main.yaml index f24e2b3..b0119d1 100644 --- a/.github/workflows/master.yaml +++ b/.github/workflows/main.yaml @@ -1,8 +1,8 @@ -name: master +name: main on: push: branches: - - master + - main schedule: - cron: '0 0 * * 0' # 00:00 Sunday diff --git a/Cargo.toml b/Cargo.toml index 2c6ac84..9c23b8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,10 @@ exclude = ["bors.toml", ".github/*"] proc-macro = true [dependencies] -proc-macro-crate = "0.1" +proc-macro-crate = "1.2.1" proc-macro2 = "1" quote = "1" -syn = { version = "1", features = ["fold", "full"] } +syn = { version = "2", features = ["fold", "full"] } [dev-dependencies] rayon = "1.3" diff --git a/README.md b/README.md index fa88427..6a1cd29 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![rayon-macro crate](https://img.shields.io/crates/v/rayon-macro.svg)](https://crates.io/crates/rayon-macro) [![rayon-macro documentation](https://docs.rs/rayon-macro/badge.svg)](https://docs.rs/rayon-macro) ![minimum rustc 1.45](https://img.shields.io/badge/rustc-1.45+-red.svg) -![build status](https://github.com/rayon-rs/rayon-macro/workflows/master/badge.svg) +![build status](https://github.com/rayon-rs/rayon-macro/workflows/main/badge.svg) The `rayon-macro` crate provides procedural macros to make it easier to transform serial code into `rayon`-enabled parallel code. For example, diff --git a/src/lib.rs b/src/lib.rs index 04a4008..c2bba2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; -use proc_macro_crate::crate_name; +use proc_macro_crate::{crate_name, FoundCrate}; use quote::quote; use syn::fold::{self, Fold}; use syn::parse_macro_input; @@ -34,7 +34,10 @@ pub fn parallel(input: TokenStream) -> TokenStream { let body = transform.fold_block(body); let rayon_crate = crate_name("rayon").expect("rayon is present in `Cargo.toml`"); - let rayon = Ident::new(&rayon_crate, Span::call_site()); + let rayon = match rayon_crate { + FoundCrate::Name(name) => Ident::new(&name, Span::call_site()), + FoundCrate::Itself => panic!("expected a crate name"), + }; TokenStream::from(quote! { ::#rayon::iter::ParallelIterator::for_each(