From a36d09a5e43ebd4d515bce90dfe1b6fb6a70839b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Dec 2020 06:49:29 +0000 Subject: [PATCH 1/7] Bump Tamschi/git-auto-commit-action from v4.7.2 to v4.8.0 Bumps [Tamschi/git-auto-commit-action](https://github.com/Tamschi/git-auto-commit-action) from v4.7.2 to v4.8.0. - [Release notes](https://github.com/Tamschi/git-auto-commit-action/releases) - [Changelog](https://github.com/Tamschi/git-auto-commit-action/blob/master/CHANGELOG.md) - [Commits](https://github.com/Tamschi/git-auto-commit-action/compare/v4.7.2...75802d269e7721b5146d08f6063ba3097c55ad2b) Signed-off-by: dependabot[bot] --- .github/workflows/rust_auto_format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust_auto_format.yml b/.github/workflows/rust_auto_format.yml index 7758429..f9cf193 100644 --- a/.github/workflows/rust_auto_format.yml +++ b/.github/workflows/rust_auto_format.yml @@ -28,7 +28,7 @@ jobs: - run: cat CI.toml >> Cargo.toml - run: cargo +nightly fmt --all - - uses: Tamschi/git-auto-commit-action@v4.7.2 + - uses: Tamschi/git-auto-commit-action@v4.8.0 with: commit_message: Automatic formatting commit (cargo +nightly fmt) file_pattern: '**/*.rs' From a5942c428e7bcb2b5b8ae533916cd964c41390c2 Mon Sep 17 00:00:00 2001 From: Rust Format Action Date: Wed, 16 Dec 2020 06:51:55 +0000 Subject: [PATCH 2/7] Automatic formatting commit (cargo +nightly fmt) --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index eb9edc8..e4e312a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,7 @@ macro_rules! grammar_todo { return Err(Error::new_spanned( $token, format_args!("Not yet implemented: {}", $name), - )); + )); }; } From d32dc94934e7bf25a5d5695386b92d8bfd66391c Mon Sep 17 00:00:00 2001 From: Tamme Schichler Date: Sat, 3 Apr 2021 13:42:19 +0200 Subject: [PATCH 3/7] Removed Span ranges --- CHANGELOG.md | 8 +++++++ README.md | 4 ++-- src/lib.rs | 54 ++---------------------------------------- tests/quote_unquote.rs | 15 ------------ 4 files changed, 12 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 819bebc..f6d9057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ +## next + +TODO: Date + +* **Breaking changes** + * Removed [`Span`] for the time being. + > The previous implementation caused more issues than it solved, since it retrieved [`Span`]s of previously parsed tokens. + ## 0.0.6 2020-12-05 diff --git a/README.md b/README.md index 07f1f7e..655ca1e 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,8 @@ fn main() -> Result<(), Box> { | Span Captures | | |-|-| | `#'span`⁴ | ✔ | -| `#^'span`⁴ | ✔ | -| `#$'span`⁴ | ✔ | +| `#^'span`⁴ | | +| `#$'span`⁴ | | | Positional Bindings...?⁵ | | |-|-| diff --git a/src/lib.rs b/src/lib.rs index e4e312a..993a8ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,6 @@ fn unquote_outer(input: ParseStream) -> Result { let declare_up_front = declare_up_front.into_iter(); Ok(quote_spanned!(Span::mixed_site()=> let #input_ident = #parse_stream; - let mut prev_span = #input_ident.cursor().span(); #(let #declare_up_front;)* #output )) @@ -116,7 +115,6 @@ fn unquote_inner( .unwrap_or_else(|| r#do.span()) => #placeholder = #input_ident.call(#parser_function)?; - prev_span = syn::spanned::Spanned::span(&#placeholder); } } TokenTree::Ident(r#let) if r#let == "let" => { @@ -124,18 +122,16 @@ fn unquote_inner( declare_up_front.insert(placeholder.clone()); hygienic_spanned! {punct.span().join(r#let.span()).and_then(|s| s.join(placeholder.span())).unwrap_or_else(|| r#let.span())=> #placeholder = #input_ident.parse()?; - prev_span = syn::spanned::Spanned::span(&#placeholder); } } TokenTree::Ident(placeholder) => { hygienic_spanned! {punct.span().join(placeholder.span()).unwrap_or_else(|| placeholder.span())=> #placeholder = #input_ident.parse()?; - prev_span = syn::spanned::Spanned::span(&#placeholder); } } TokenTree::Punct(number_sign) if punct.spacing() == Spacing::Joint && number_sign.as_char() == '#' => { hygienic_spanned! {punct.span().join(number_sign.span()).unwrap_or_else(||number_sign.span())=> - prev_span = #input_ident.parse::()?.span; + #input_ident.parse::()?; } } TokenTree::Punct(apostrophe) @@ -148,50 +144,6 @@ fn unquote_inner( #placeholder = #input_ident.span(); } } - TokenTree::Punct(caret) - if punct.spacing() == Spacing::Joint - && caret.as_char() == '^' => - { - let apostrophe: TokenTree= input.parse()?; - match apostrophe { - TokenTree::Punct(apostrophe) - if apostrophe.as_char() == '\'' - &&apostrophe.spacing() == Spacing::Joint => - { - let identifier = input.parse::()?; - let hygienic_identifier = Ident::new(&identifier.to_string(), identifier.span().resolved_at(Span::mixed_site())); - if !declare_up_front.insert(hygienic_identifier.clone()) { - return Err(Error::new(identifier.span(), format_args!("Duplicate Span start: `{}`", identifier))); - } - hygienic_spanned!(punct.span().join(identifier.span()).unwrap_or_else(|| identifier.span())=> - #hygienic_identifier = #input_ident.cursor().span(); - ) - } - other => { - return Err(Error::new_spanned(other, "Expected span identifier written as lifetime.")); - } - } - } - TokenTree::Punct(dollar) - if punct.spacing() == Spacing::Joint && dollar.as_char() == '$' => - { - let apostrophe: TokenTree = input.parse()?; - match apostrophe { - TokenTree::Punct(apostrophe) - if apostrophe.as_char() == '\'' - && apostrophe.spacing() == Spacing::Joint => - { - let identifier = input.parse::()?; - let hygienic_identifier = Ident::new(&identifier.to_string(), identifier.span().resolved_at(Span::mixed_site())); - hygienic_spanned!(punct.span().join(identifier.span()).unwrap_or_else(|| identifier.span())=> - #identifier = #hygienic_identifier.join(prev_span).unwrap_or(#hygienic_identifier); - ) - } - other => { - return Err(Error::new_spanned(other, "Expected span identifier written as lifetime.")); - } - } - } other => { return Err(Error::new_spanned( other, @@ -202,7 +154,7 @@ fn unquote_inner( } _char => hygienic_spanned! {punct.span()=> //TODO: Spacing - prev_span = #input_ident.parse::()?.span; + #input_ident.parse::()?; }, }, TokenTree::Literal(literal) => { @@ -211,8 +163,6 @@ fn unquote_inner( let parsed = #input_ident.parse::()?; if parsed != syn::parse2(quote!(#literal)).unwrap() { return Err(syn::Error::new(#input_ident.cursor().span(), #message)); - } else { - prev_span = parsed.span(); } } } diff --git a/tests/quote_unquote.rs b/tests/quote_unquote.rs index 0cde48d..dd58d19 100644 --- a/tests/quote_unquote.rs +++ b/tests/quote_unquote.rs @@ -107,21 +107,6 @@ fn number_sign_escape() -> Result<()> { .unwrap() } -//TODO: Test more thoroughly which spans are captured! -#[test] -fn span_range() -> Result<()> { - let tokens = quote!(.); - - let _: Span = call2_strict(tokens, |input| { - let span; - unquote!(input, #^'span . #$'span); - Result::Ok(span) - }) - .unwrap()?; - - Ok(()) -} - #[derive(Debug)] struct Attributes(Vec); impl Attributes { From 5b3a256d114036366ca66051980ec82a207e2aad Mon Sep 17 00:00:00 2001 From: Tamme Schichler Date: Sat, 3 Apr 2021 14:08:36 +0200 Subject: [PATCH 4/7] `quote` now doesn't have to be in scope to unquote literal identifiers --- CHANGELOG.md | 5 +++++ src/lib.rs | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6d9057..b185299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ TODO: Date * **Breaking changes** * Removed [`Span`] for the time being. > The previous implementation caused more issues than it solved, since it retrieved [`Span`]s of previously parsed tokens. +* Features + * [`quote`] now doesn't have to be in scope to unquote literal identifiers. + +[`Span`]: https://docs.rs/proc-macro2/1/proc_macro2/struct.Span.html +[`quote`]: https://docs.rs/quote/1.0.9/quote/macro.quote.html ## 0.0.6 diff --git a/src/lib.rs b/src/lib.rs index 993a8ae..a3c498e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,9 +83,7 @@ fn unquote_inner( TokenTree::Ident(ident) => { let message = Literal::string(&format!("Expected `{}`", ident.to_string())); hygienic_spanned! {ident.span()=> - if #input_ident.call(::parse_any)? - != syn::parse::Parser::parse2(::parse_any, quote!(#ident)).unwrap() - { + if #input_ident.call(::parse_any)? != stringify!(#ident) { return Err(syn::Error::new(#input_ident.cursor().span(), #message)); } } From 8f0951b0bb4b85eb7dae12d57d6cab4cd33cc5bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 May 2021 05:22:25 +0000 Subject: [PATCH 5/7] Bump actions-rs/audit-check from 1 to 1.2.0 Bumps [actions-rs/audit-check](https://github.com/actions-rs/audit-check) from 1 to 1.2.0. - [Release notes](https://github.com/actions-rs/audit-check/releases) - [Changelog](https://github.com/actions-rs/audit-check/blob/master/CHANGELOG.md) - [Commits](https://github.com/actions-rs/audit-check/compare/v1...v1.2.0) Signed-off-by: dependabot[bot] --- .github/workflows/audit_at_midnight.yml | 2 +- .github/workflows/audit_on_push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/audit_at_midnight.yml b/.github/workflows/audit_at_midnight.yml index ec830df..3098d5d 100644 --- a/.github/workflows/audit_at_midnight.yml +++ b/.github/workflows/audit_at_midnight.yml @@ -7,6 +7,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2.3.4 - - uses: actions-rs/audit-check@v1 + - uses: actions-rs/audit-check@v1.2.0 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/audit_on_push.yml b/.github/workflows/audit_on_push.yml index 8f3802e..1b92e9d 100644 --- a/.github/workflows/audit_on_push.yml +++ b/.github/workflows/audit_on_push.yml @@ -9,6 +9,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2.3.4 - - uses: actions-rs/audit-check@v1 + - uses: actions-rs/audit-check@v1.2.0 with: token: ${{ secrets.GITHUB_TOKEN }} From a5fe2d7ee3de84c6876523ad6d23f89a9a50a8a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 May 2021 05:22:29 +0000 Subject: [PATCH 6/7] Bump actions-rs/toolchain from 1 to 1.0.7 Bumps [actions-rs/toolchain](https://github.com/actions-rs/toolchain) from 1 to 1.0.7. - [Release notes](https://github.com/actions-rs/toolchain/releases) - [Changelog](https://github.com/actions-rs/toolchain/blob/master/CHANGELOG.md) - [Commits](https://github.com/actions-rs/toolchain/compare/v1...v1.0.7) Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 10 +++++----- .github/workflows/deny_warnings.yml | 2 +- .github/workflows/rust_auto_format.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5d7b6e..d742f0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.7 - run: cat CI.toml >> Cargo.toml - run: cargo test --workspace --all-features @@ -31,7 +31,7 @@ jobs: workspace: ${{matrix.no-workspace || '--workspace'}} steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.7 with: toolchain: ${{matrix.rust}} profile: minimal @@ -46,7 +46,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.7 with: toolchain: nightly - run: cat CI.toml >> Cargo.toml @@ -58,7 +58,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.7 with: toolchain: nightly profile: minimal @@ -71,7 +71,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.7 with: toolchain: nightly profile: minimal diff --git a/.github/workflows/deny_warnings.yml b/.github/workflows/deny_warnings.yml index 30c049f..09f6053 100644 --- a/.github/workflows/deny_warnings.yml +++ b/.github/workflows/deny_warnings.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.7 with: toolchain: nightly profile: minimal diff --git a/.github/workflows/rust_auto_format.yml b/.github/workflows/rust_auto_format.yml index f9cf193..c937c42 100644 --- a/.github/workflows/rust_auto_format.yml +++ b/.github/workflows/rust_auto_format.yml @@ -20,7 +20,7 @@ jobs: # github.head_ref only exists on pull requests. ref: ${{ github.head_ref || github.ref }} - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1.0.7 with: toolchain: nightly profile: minimal From 1bde1df53ac079db879e73a3051176ae119b54a4 Mon Sep 17 00:00:00 2001 From: Tamme Schichler Date: Sat, 26 Aug 2023 13:04:46 +0200 Subject: [PATCH 7/7] Updated to Syn 2 and fixed some issues --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .vscode/extensions.json | 2 +- CHANGELOG.md | 9 +++++++-- Cargo.toml | 10 +++++----- README.md | 2 +- src/lib.rs | 8 ++++---- tests/quote_unquote.rs | 2 ++ 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 947935b..3387b52 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -27,7 +27,7 @@ If applicable, add screenshots to help explain your problem. **please complete the following information:** - `rustc --version`: [e.g. 1.45.0] -- Crate version (if applicable): [e.g. 0.0.6] +- Crate version (if applicable): [e.g. 0.0.7] **Additional context** Add any other context about the problem here. diff --git a/.vscode/extensions.json b/.vscode/extensions.json index dec8c3c..e05328f 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ - "bungcip.better-toml", + "tamasfe.even-better-toml", "serayuzgur.crates", "editorconfig.editorconfig", "matklad.rust-analyzer", diff --git a/CHANGELOG.md b/CHANGELOG.md index b185299..8253fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,20 @@ -## next +## 0.0.7 -TODO: Date +2023-08-26 * **Breaking changes** * Removed [`Span`] for the time being. > The previous implementation caused more issues than it solved, since it retrieved [`Span`]s of previously parsed tokens. * Features * [`quote`] now doesn't have to be in scope to unquote literal identifiers. +* Fixed + * Missing `syn/printing` dependency feature. +* Revisions + * Updated Syn dependency to version `2.0.29`. + * Fixed a few warnings. [`Span`]: https://docs.rs/proc-macro2/1/proc_macro2/struct.Span.html [`quote`]: https://docs.rs/quote/1.0.9/quote/macro.quote.html diff --git a/Cargo.toml b/Cargo.toml index c272505..c605be6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "unquote" -version = "0.0.6" +version = "0.0.7" authors = ["Tamme Schichler "] edition = "2018" description = "A reverse quote macro... that is: A macro to parse input from a ParseStream according to a given pattern." license = "MIT OR Apache-2.0" repository = "https://github.com/Tamschi/unquote" -homepage = "https://github.com/Tamschi/unquote/tree/v0.0.6" -documentation = "https://docs.rs/unquote/0.0.6" +homepage = "https://github.com/Tamschi/unquote/tree/v0.0.7" +documentation = "https://docs.rs/unquote/0.0.7" keywords = ["syn"] categories = ["development-tools::procedural-macro-helpers"] readme = "README.md" @@ -32,10 +32,10 @@ proc-macro = true # TODO: Re-export libraries! [dependencies] -call2-for-syn = "2.0.3" +call2-for-syn = "3.0.4" proc-macro2 = "1.0.24" quote = "1.0.7" -syn = { version = "1.0.48", features = ["extra-traits", "parsing"], default-features = false } +syn = { version = "2.0.29", features = ["extra-traits", "parsing", "printing"], default-features = false } [dev-dependencies] diff --git a/README.md b/README.md index 655ca1e..f25826f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ![Rust 1.45.0](https://img.shields.io/static/v1?logo=Rust&label=&message=1.45.0&color=grey) [![CI](https://github.com/Tamschi/unquote/workflows/CI/badge.svg?branch=develop)](https://github.com/Tamschi/unquote/actions?query=workflow%3ACI+branch%3Adevelop) -![Crates.io - License](https://img.shields.io/crates/l/unquote/0.0.6) +![Crates.io - License](https://img.shields.io/crates/l/unquote/0.0.7) [![GitHub](https://img.shields.io/static/v1?logo=GitHub&label=&message=%20&color=grey)](https://github.com/Tamschi/unquote) [![open issues](https://img.shields.io/github/issues-raw/Tamschi/unquote)](https://github.com/Tamschi/unquote/issues) diff --git a/src/lib.rs b/src/lib.rs index a3c498e..8644230 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/unquote/0.0.6")] +#![doc(html_root_url = "https://docs.rs/unquote/0.0.7")] #![warn(clippy::pedantic)] #[cfg(doctest)] @@ -40,7 +40,7 @@ macro_rules! grammar_todo { return Err(Error::new_spanned( $token, format_args!("Not yet implemented: {}", $name), - )); + )) }; } @@ -81,7 +81,7 @@ fn unquote_inner( .unwrap_or_else(|_| Err(Error::new(group.span_close(), "Unexpected end of undelimited group")))?, }, TokenTree::Ident(ident) => { - let message = Literal::string(&format!("Expected `{}`", ident.to_string())); + let message = Literal::string(&format!("Expected `{ident}`")); hygienic_spanned! {ident.span()=> if #input_ident.call(::parse_any)? != stringify!(#ident) { return Err(syn::Error::new(#input_ident.cursor().span(), #message)); @@ -156,7 +156,7 @@ fn unquote_inner( }, }, TokenTree::Literal(literal) => { - let message = Literal::string(&format!("Expected `{}`", literal.to_string())); + let message = Literal::string(&format!("Expected `{literal}`")); hygienic_spanned! {literal.span()=> let parsed = #input_ident.parse::()?; if parsed != syn::parse2(quote!(#literal)).unwrap() { diff --git a/tests/quote_unquote.rs b/tests/quote_unquote.rs index dd58d19..e9dcbec 100644 --- a/tests/quote_unquote.rs +++ b/tests/quote_unquote.rs @@ -1,3 +1,5 @@ +#![allow(clippy::needless_late_init)] + use call2_for_syn::{call2_allow_incomplete, call2_strict}; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens};