mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
macros: fix handling of arguments of #[tokio::main] attribute (#1578)
This commit is contained in:
@@ -26,7 +26,7 @@ proc-macro = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quote = "1"
|
quote = "1"
|
||||||
syn = { version = "1", features = ["full"] }
|
syn = { version = "1.0.3", features = ["full"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "=0.2.0-alpha.5", path = "../tokio", default-features = false, features = ["rt-full"] }
|
tokio = { version = "=0.2.0-alpha.5", path = "../tokio", default-features = false, features = ["rt-full"] }
|
||||||
|
|||||||
@@ -74,16 +74,18 @@ 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::Path(ident)) = arg {
|
if let syn::NestedMeta::Meta(syn::Meta::Path(path)) = arg {
|
||||||
let seg = ident.segments.first().expect("Must have specified ident");
|
let ident = path.get_ident();
|
||||||
match seg.ident.to_string().to_lowercase().as_str() {
|
if ident.is_none() {
|
||||||
|
let msg = "Must have specified ident";
|
||||||
|
return syn::Error::new_spanned(path, msg).to_compile_error().into();
|
||||||
|
}
|
||||||
|
match ident.unwrap().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 => {
|
||||||
let msg = format!("Unknown attribute {} is specified", name);
|
let msg = format!("Unknown attribute {} is specified", name);
|
||||||
return syn::Error::new_spanned(ident, msg)
|
return syn::Error::new_spanned(path, msg).to_compile_error().into();
|
||||||
.to_compile_error()
|
|
||||||
.into();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user