summaryrefslogtreecommitdiffstats
path: root/tokio-macros
diff options
context:
space:
mode:
authorTaiki Endo <te316e89@gmail.com>2019-09-23 03:05:04 +0900
committerGitHub <noreply@github.com>2019-09-23 03:05:04 +0900
commitddbb0c38368bdb67d2d1b18e2281da286a540e90 (patch)
tree05fbd58cd117084994352d29b2fd9542ee22905c /tokio-macros
parent376d63867a850568991f01c742938612c0179e40 (diff)
macros: fix handling of arguments of #[tokio::main] attribute (#1578)
Diffstat (limited to 'tokio-macros')
-rw-r--r--tokio-macros/Cargo.toml2
-rw-r--r--tokio-macros/src/lib.rs14
2 files changed, 9 insertions, 7 deletions
diff --git a/tokio-macros/Cargo.toml b/tokio-macros/Cargo.toml
index 1d36e8c8..1c0e40cc 100644
--- a/tokio-macros/Cargo.toml
+++ b/tokio-macros/Cargo.toml
@@ -26,7 +26,7 @@ proc-macro = true
[dependencies]
quote = "1"
-syn = { version = "1", features = ["full"] }
+syn = { version = "1.0.3", features = ["full"] }
[dev-dependencies]
tokio = { version = "=0.2.0-alpha.5", path = "../tokio", default-features = false, features = ["rt-full"] }
diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs
index a4aede29..cabfd8be 100644
--- a/tokio-macros/src/lib.rs
+++ b/tokio-macros/src/lib.rs
@@ -74,16 +74,18 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
let mut runtime = RuntimeType::Multi;
for arg in args {
- if let syn::NestedMeta::Meta(syn::Meta::Path(ident)) = arg {
- let seg = ident.segments.first().expect("Must have specified ident");
- match seg.ident.to_string().to_lowercase().as_str() {
+ if let syn::NestedMeta::Meta(syn::Meta::Path(path)) = arg {
+ let ident = path.get_ident();
+ 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,
"single_thread" => runtime = RuntimeType::Single,
name => {
let msg = format!("Unknown attribute {} is specified", name);
- return syn::Error::new_spanned(ident, msg)
- .to_compile_error()
- .into();
+ return syn::Error::new_spanned(path, msg).to_compile_error().into();
}
}
}