From: Ian Jackson Date: Fri, 10 May 2024 13:47:07 +0000 (+0100) Subject: try to make it work with 1.31 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=de7fb5b8fee7feb9105ce948ac9d9a94df224b42;p=rust-experiments.git try to make it work with 1.31 --- diff --git a/Cargo.lock b/Cargo.lock index 27ce9ac..9609159 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,14 +1,11 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - [[package]] name = "foo" version = "0.1.0" dependencies = [ - "foo-macros", + "foo-macros 0.1.0", ] [[package]] name = "foo-macros" version = "0.1.0" + diff --git a/Cargo.toml b/Cargo.toml index 2c2586a..902c769 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,6 @@ [package] name = "foo" version = "0.1.0" -edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/macros/Cargo.toml b/macros/Cargo.toml index d36e210..9abfcfb 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -2,7 +2,6 @@ name = "foo-macros" version = "0.1.0" -edition = "2021" [dependencies] #syn = "2" diff --git a/macros/macros.rs b/macros/macros.rs index 0f66a6b..7a456f2 100644 --- a/macros/macros.rs +++ b/macros/macros.rs @@ -1,9 +1,10 @@ +extern crate proc_macro; use proc_macro::{Group, TokenStream, TokenTree}; #[proc_macro] pub fn dbg_dump(input: TokenStream) -> TokenStream { - dbg!(&input); - dbg!(input.to_string()); +// dbg!(&input); +// dbg!(input.to_string()); input } @@ -18,20 +19,20 @@ pub fn reconstruct_groups(input: TokenStream) -> TokenStream { let tt = match tt { TokenTree::Group(g) => { let delim = g.delimiter(); - dbg!(&delim); +// dbg!(&delim); let stream = recurse(g.stream()); TokenTree::Group(Group::new(delim, stream)) }, other => other, }; - output.extend([tt]); + output.extend(std::iter::once(tt)); } output } - dbg!(&input); +// dbg!(&input); let output = recurse(input); - dbg!(&output); - dbg!(&output.to_string()); +// dbg!(&output); +// dbg!(&output.to_string()); output } diff --git a/src/main.rs b/src/main.rs index bdf2b1d..76e65a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +extern crate foo_macros; use foo_macros::*; macro_rules! one_plus { { $v:expr } => {