Skip to content

Commit

Permalink
tokio-macros: compat with clippy::unwrap_used (#3926)
Browse files Browse the repository at this point in the history
  • Loading branch information
blasrodri authored and hawkw committed Nov 16, 2021
1 parent ea87e4e commit f49b7fc
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tokio-macros/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,15 @@ 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 msg = "Must have specified ident";
return Err(syn::Error::new_spanned(namevalue, msg));
}
match ident.unwrap().to_string().to_lowercase().as_str() {
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(
namevalue.lit.clone(),
Expand Down Expand Up @@ -239,12 +242,11 @@ 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.unwrap().to_string().to_lowercase();
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() {
"threaded_scheduler" | "multi_thread" => {
format!(
Expand Down Expand Up @@ -326,11 +328,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! {
Expand Down

0 comments on commit f49b7fc

Please sign in to comment.