mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
macros: upgrade syn/quote (#1432)
This commit is contained in:
parent
fe90d61446
commit
517162792f
@ -25,9 +25,8 @@ proc-macro = true
|
|||||||
[features]
|
[features]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "0.4.27"
|
quote = "1"
|
||||||
quote = "0.6.11"
|
syn = { version = "1", features = ["full"] }
|
||||||
syn = { version = "0.15.27", features = ["full", "extra-traits", "visit-mut"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "=0.2.0-alpha.1", path = "../tokio", default-features = false, features = ["rt-full"] }
|
tokio = { version = "=0.2.0-alpha.1", path = "../tokio", default-features = false, features = ["rt-full"] }
|
||||||
|
@ -54,19 +54,19 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
let input = syn::parse_macro_input!(item as syn::ItemFn);
|
let input = syn::parse_macro_input!(item as syn::ItemFn);
|
||||||
let args = syn::parse_macro_input!(args as syn::AttributeArgs);
|
let args = syn::parse_macro_input!(args as syn::AttributeArgs);
|
||||||
|
|
||||||
let ret = &input.decl.output;
|
let ret = &input.sig.output;
|
||||||
let name = &input.ident;
|
let name = &input.sig.ident;
|
||||||
let body = &input.block;
|
let body = &input.block;
|
||||||
let attrs = &input.attrs;
|
let attrs = &input.attrs;
|
||||||
|
|
||||||
if input.asyncness.is_none() {
|
if input.sig.asyncness.is_none() {
|
||||||
let msg = "the async keyword is missing from the function declaration";
|
let msg = "the async keyword is missing from the function declaration";
|
||||||
return syn::Error::new_spanned(input.decl.fn_token, msg)
|
return syn::Error::new_spanned(input.sig.fn_token, msg)
|
||||||
.to_compile_error()
|
.to_compile_error()
|
||||||
.into();
|
.into();
|
||||||
} else if !input.decl.inputs.is_empty() {
|
} else if !input.sig.inputs.is_empty() {
|
||||||
let msg = "the main function cannot accept arguments";
|
let msg = "the main function cannot accept arguments";
|
||||||
return syn::Error::new_spanned(&input.decl.inputs, msg)
|
return syn::Error::new_spanned(&input.sig.inputs, msg)
|
||||||
.to_compile_error()
|
.to_compile_error()
|
||||||
.into();
|
.into();
|
||||||
}
|
}
|
||||||
@ -74,8 +74,9 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
let mut runtime = RuntimeType::Multi;
|
let mut runtime = RuntimeType::Multi;
|
||||||
|
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if let syn::NestedMeta::Meta(syn::Meta::Word(ident)) = arg {
|
if let syn::NestedMeta::Meta(syn::Meta::Path(ident)) = arg {
|
||||||
match ident.to_string().to_lowercase().as_str() {
|
let seg = ident.segments.first().expect("Must have specified ident");
|
||||||
|
match seg.ident.to_string().to_lowercase().as_str() {
|
||||||
"multi_thread" => runtime = RuntimeType::Multi,
|
"multi_thread" => runtime = RuntimeType::Multi,
|
||||||
"single_thread" => runtime = RuntimeType::Single,
|
"single_thread" => runtime = RuntimeType::Single,
|
||||||
name => {
|
name => {
|
||||||
@ -126,8 +127,8 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
let input = syn::parse_macro_input!(item as syn::ItemFn);
|
let input = syn::parse_macro_input!(item as syn::ItemFn);
|
||||||
|
|
||||||
let ret = &input.decl.output;
|
let ret = &input.sig.output;
|
||||||
let name = &input.ident;
|
let name = &input.sig.ident;
|
||||||
let body = &input.block;
|
let body = &input.block;
|
||||||
let attrs = &input.attrs;
|
let attrs = &input.attrs;
|
||||||
|
|
||||||
@ -140,14 +141,14 @@ pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.asyncness.is_none() {
|
if input.sig.asyncness.is_none() {
|
||||||
let msg = "the async keyword is missing from the function declaration";
|
let msg = "the async keyword is missing from the function declaration";
|
||||||
return syn::Error::new_spanned(&input, msg)
|
return syn::Error::new_spanned(&input, msg)
|
||||||
.to_compile_error()
|
.to_compile_error()
|
||||||
.into();
|
.into();
|
||||||
} else if !input.decl.inputs.is_empty() {
|
} else if !input.sig.inputs.is_empty() {
|
||||||
let msg = "the test function cannot accept arguments";
|
let msg = "the test function cannot accept arguments";
|
||||||
return syn::Error::new_spanned(&input.decl.inputs, msg)
|
return syn::Error::new_spanned(&input.sig.inputs, msg)
|
||||||
.to_compile_error()
|
.to_compile_error()
|
||||||
.into();
|
.into();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user