Skip to content

Commit

Permalink
chore(dep): bump the test-deps group across 1 directory with 2 updates (
Browse files Browse the repository at this point in the history
#552)

* chore(dep): bump the test-deps group across 1 directory with 2 updates

Bumps the test-deps group with 2 updates in the /crates/rsonpath-test-codegen directory: [serde](https://github.com/serde-rs/serde) and [proc-macro2](https://github.com/dtolnay/proc-macro2).


Updates `serde` from 1.0.210 to 1.0.213
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](serde-rs/serde@v1.0.210...v1.0.213)

Updates `proc-macro2` from 1.0.86 to 1.0.89
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](dtolnay/proc-macro2@1.0.86...1.0.89)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: test-deps
- dependency-name: proc-macro2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: test-deps
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: fix `Punct` usage of `proc_macro2` in test generation

Apparently using `Punct` for parantheses was always invalid,
and in the latest update it became a hard error. The `Group`
object needs to be used instead to surround a stream of tokens
in delimiters.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mateusz Gienieczko <[email protected]>
  • Loading branch information
dependabot[bot] and V0ldek authored Oct 27, 2024
1 parent 956444f commit b4ae810
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
16 changes: 8 additions & 8 deletions crates/rsonpath-test-codegen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/rsonpath-test-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ rust-version = "1.70.0"
publish = false

[dependencies]
serde = { version = "1.0.210", features = ["derive"] }
serde = { version = "1.0.213", features = ["derive"] }
toml = "0.8.19"
proc-macro2 = "1.0.86"
proc-macro2 = "1.0.89"
quote = "1.0.37"
heck = { version = "0.5.0" }
walkdir = "2.5.0"
Expand Down
41 changes: 20 additions & 21 deletions crates/rsonpath-test-codegen/src/model.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Type definitions and serde support for the TOML configuration files.
use std::{cmp, error::Error, fmt::Display, path::PathBuf};

use quote::TokenStreamExt;
use serde::{Deserialize, Serialize};
use std::{cmp, error::Error, fmt::Display, path::PathBuf};

/// Top-level test configuration.
#[derive(Debug, Deserialize, Serialize, Clone)]
Expand Down Expand Up @@ -128,35 +126,36 @@ impl<'de> Deserialize<'de> for ResultSpan {

impl quote::ToTokens for ResultApproximateSpan {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
use proc_macro2::{Ident, Punct, Spacing, Span};
tokens.append(Punct::new('(', Spacing::Alone));
self.start.to_tokens(tokens);
tokens.append(Punct::new(',', Spacing::Alone));
self.end_lower_bound.to_tokens(tokens);
tokens.append(Punct::new(',', Spacing::Alone));
use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream};
let mut outer_group = TokenStream::new();

self.start.to_tokens(&mut outer_group);
Punct::new(',', Spacing::Alone).to_tokens(&mut outer_group);
self.end_lower_bound.to_tokens(&mut outer_group);
Punct::new(',', Spacing::Alone).to_tokens(&mut outer_group);

match self.end_upper_bound {
Some(x) => {
tokens.append(Ident::new("Some", Span::call_site()));
tokens.append(Punct::new('(', Spacing::Alone));
x.to_tokens(tokens);
tokens.append(Punct::new(')', Spacing::Alone));
Ident::new("Some", Span::call_site()).to_tokens(&mut outer_group);
Group::new(Delimiter::Parenthesis, x.to_token_stream()).to_tokens(&mut outer_group);
}
None => tokens.append(Ident::new("None", Span::call_site())),
None => Ident::new("None", Span::call_site()).to_tokens(&mut outer_group),
}

tokens.append(Punct::new(')', Spacing::Alone));
Group::new(Delimiter::Parenthesis, outer_group).to_tokens(tokens);
}
}

impl quote::ToTokens for ResultSpan {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
use proc_macro2::{Punct, Spacing};
tokens.append(Punct::new('(', Spacing::Alone));
self.start.to_tokens(tokens);
tokens.append(Punct::new(',', Spacing::Alone));
self.end.to_tokens(tokens);
tokens.append(Punct::new(')', Spacing::Alone));
use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream};
let mut group = TokenStream::new();

self.start.to_tokens(&mut group);
Punct::new(',', Spacing::Alone).to_tokens(&mut group);
self.end.to_tokens(&mut group);

Group::new(Delimiter::Parenthesis, group).to_tokens(tokens);
}
}

Expand Down

0 comments on commit b4ae810

Please sign in to comment.