Skip to main content

workflow_macro_tools/
lib.rs

1//! Macro utilities used by macros in the [workflow-rs](https://github.com/workflow-rs/workflow-rs) project
2
3/// Parsing helpers for procedural-macro attribute arguments.
4#[cfg(not(target_arch = "wasm32"))]
5pub mod attributes;
6
7use proc_macro2::TokenStream;
8use quote::ToTokens;
9use syn::Error;
10
11/// Produces a `compile_error!` token stream spanned over `tokens`,
12/// reporting `message` at the location of the offending tokens.
13pub fn parse_error<T: ToTokens>(tokens: T, message: &str) -> TokenStream {
14    Error::new_spanned(tokens, message).to_compile_error()
15}