Skip to content

Commit 46f17cc

Browse files
test: update dependency syn
1 parent 2e96eba commit 46f17cc

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

tokio-test/macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ edition = "2021"
77
proc-macro = true
88

99
[dependencies]
10-
syn = { version = "*", features = ["full"] }
10+
syn = { version = "2", features = ["full"] }
1111
quote2 = "0.9"

tokio-test/macros/src/expend.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use quote2::{proc_macro2::TokenStream, quote, utils::quote_rep, Quote, ToTokens}
22
use syn::{
33
parse::{Parse, ParseStream, Parser},
44
punctuated::Punctuated,
5-
Attribute, Lit, Meta, MetaNameValue, Signature, Token, Visibility,
5+
Attribute, Meta, MetaNameValue, Signature, Token, Visibility,
66
};
77

88
type AttributeArgs = Punctuated<Meta, Token![,]>;
@@ -34,10 +34,10 @@ pub fn tokio_test(args: TokenStream, item_fn: ItemFn) -> TokenStream {
3434
let has_miri_cfg = metadata.iter().any(|meta| meta.path().is_ident("miri"));
3535
let id_multi_thread = metadata.iter().any(|meta| match meta {
3636
Meta::NameValue(meta) if meta.path.is_ident("flavor") => {
37-
match parse_string(&meta.lit, "flavor").as_str() {
37+
match meta.value.to_token_stream().to_string().as_str() {
3838
"multi_thread" => true,
3939
"current_thread" => false,
40-
_ => panic!("unknown `flavor`, expected: multi_thread | current_thread"),
40+
val => panic!("unknown `flavor = {val}`, expected: multi_thread | current_thread"),
4141
}
4242
}
4343
_ => false,
@@ -48,10 +48,10 @@ pub fn tokio_test(args: TokenStream, item_fn: ItemFn) -> TokenStream {
4848
return;
4949
}
5050
}
51-
if let Meta::NameValue(MetaNameValue { path, lit, .. }) = &meta {
51+
if let Meta::NameValue(MetaNameValue { path, value, .. }) = &meta {
5252
for key in ["worker_threads", "start_paused"] {
5353
if path.is_ident(key) {
54-
quote!(t, { .#path(#lit) });
54+
quote!(t, { .#path(#value) });
5555
return;
5656
}
5757
}
@@ -119,11 +119,3 @@ pub fn tokio_test(args: TokenStream, item_fn: ItemFn) -> TokenStream {
119119
});
120120
out
121121
}
122-
123-
fn parse_string(int: &Lit, field: &str) -> String {
124-
match int {
125-
Lit::Str(s) => s.value(),
126-
Lit::Verbatim(s) => s.to_string(),
127-
_ => panic!("Failed to parse value of `{}` as string.", field),
128-
}
129-
}

0 commit comments

Comments
 (0)