From 1aeaed0b2fb54d682e3a9b6d7e1b7683566405ec Mon Sep 17 00:00:00 2001
From: Blas Rodriguez Irizar <rodrigblas@gmail.com>
Date: Mon, 5 Jul 2021 14:18:34 +0200
Subject: [PATCH 1/3] tokio-macros: compat with clippy::unwrap_used

Up until now there were a few places on the code where
both the macros tokio::test and tokio::main were unwrapping.

This patch changes .unwrap() for .expect(), to be compatible with
clippy::unwrap_used

Ref: #3887
---
 tokio-macros/src/entry.rs | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tokio-macros/src/entry.rs b/tokio-macros/src/entry.rs
index ddc19585d7b..d2d17d09dce 100644
--- a/tokio-macros/src/entry.rs
+++ b/tokio-macros/src/entry.rs
@@ -206,7 +206,12 @@ fn parse_knobs(
                     let msg = "Must have specified ident";
                     return Err(syn::Error::new_spanned(namevalue, msg));
                 }
-                match ident.unwrap().to_string().to_lowercase().as_str() {
+                match ident
+                    .expect("Must have specified ident")
+                    .to_string()
+                    .to_lowercase()
+                    .as_str()
+                {
                     "worker_threads" => {
                         config.set_worker_threads(
                             namevalue.lit.clone(),
@@ -244,7 +249,10 @@ fn parse_knobs(
                     let msg = "Must have specified ident";
                     return Err(syn::Error::new_spanned(path, msg));
                 }
-                let name = ident.unwrap().to_string().to_lowercase();
+                let name = ident
+                    .expect("Must have specified ident")
+                    .to_string()
+                    .to_lowercase();
                 let msg = match name.as_str() {
                     "threaded_scheduler" | "multi_thread" => {
                         format!(
@@ -326,11 +334,11 @@ fn parse_knobs(
             #rt
                 .enable_all()
                 .build()
-                .unwrap()
+                .expect("Failed building the Runtime")
                 .block_on(async #body)
         }
     })
-    .unwrap();
+    .expect("Parsing failure");
     input.block.brace_token = brace_token;
 
     let result = quote! {

From 3f2e31dc4fd87d6b776b413c1c8433e75522abc0 Mon Sep 17 00:00:00 2001
From: Blas Rodriguez Irizar <rodrigblas@gmail.com>
Date: Mon, 5 Jul 2021 15:00:44 +0200
Subject: [PATCH 2/3] rm unwrap

---
 tokio-macros/src/entry.rs | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/tokio-macros/src/entry.rs b/tokio-macros/src/entry.rs
index d2d17d09dce..11aa9928541 100644
--- a/tokio-macros/src/entry.rs
+++ b/tokio-macros/src/entry.rs
@@ -201,17 +201,13 @@ fn parse_knobs(
     for arg in args {
         match arg {
             syn::NestedMeta::Meta(syn::Meta::NameValue(namevalue)) => {
-                let ident = namevalue.path.get_ident();
-                if ident.is_none() {
+                let ident = if let Some(ident) = namevalue.path.get_ident() {
+                    ident.to_string().to_lowercase()
+                } else {
                     let msg = "Must have specified ident";
                     return Err(syn::Error::new_spanned(namevalue, msg));
-                }
-                match ident
-                    .expect("Must have specified ident")
-                    .to_string()
-                    .to_lowercase()
-                    .as_str()
-                {
+                };
+                match ident.as_str() {
                     "worker_threads" => {
                         config.set_worker_threads(
                             namevalue.lit.clone(),

From 089d02a50e5a2bc4f548255e217786df368deb22 Mon Sep 17 00:00:00 2001
From: Blas Rodriguez Irizar <rodrigblas@gmail.com>
Date: Tue, 6 Jul 2021 13:39:52 +0200
Subject: [PATCH 3/3] handle NestedMeta variant

---
 tokio-macros/src/entry.rs | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/tokio-macros/src/entry.rs b/tokio-macros/src/entry.rs
index 11aa9928541..c5db13cc47b 100644
--- a/tokio-macros/src/entry.rs
+++ b/tokio-macros/src/entry.rs
@@ -201,12 +201,14 @@ fn parse_knobs(
     for arg in args {
         match arg {
             syn::NestedMeta::Meta(syn::Meta::NameValue(namevalue)) => {
-                let ident = if let Some(ident) = namevalue.path.get_ident() {
-                    ident.to_string().to_lowercase()
-                } else {
-                    let msg = "Must have specified ident";
-                    return Err(syn::Error::new_spanned(namevalue, msg));
-                };
+                let ident = namevalue
+                    .path
+                    .get_ident()
+                    .ok_or_else(|| {
+                        syn::Error::new_spanned(&namevalue, "Must have specified ident")
+                    })?
+                    .to_string()
+                    .to_lowercase();
                 match ident.as_str() {
                     "worker_threads" => {
                         config.set_worker_threads(
@@ -240,13 +242,9 @@ fn parse_knobs(
                 }
             }
             syn::NestedMeta::Meta(syn::Meta::Path(path)) => {
-                let ident = path.get_ident();
-                if ident.is_none() {
-                    let msg = "Must have specified ident";
-                    return Err(syn::Error::new_spanned(path, msg));
-                }
-                let name = ident
-                    .expect("Must have specified ident")
+                let name = path
+                    .get_ident()
+                    .ok_or_else(|| syn::Error::new_spanned(&path, "Must have specified ident"))?
                     .to_string()
                     .to_lowercase();
                 let msg = match name.as_str() {