Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f49b7fc

Browse filesBrowse files
blasrodrihawkw
authored andcommitted
tokio-macros: compat with clippy::unwrap_used (#3926)
1 parent ea87e4e commit f49b7fc
Copy full SHA for f49b7fc

File tree

Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed

‎tokio-macros/src/entry.rs

Copy file name to clipboardExpand all lines: tokio-macros/src/entry.rs
+16-14Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,15 @@ fn parse_knobs(
201201
for arg in args {
202202
match arg {
203203
syn::NestedMeta::Meta(syn::Meta::NameValue(namevalue)) => {
204-
let ident = namevalue.path.get_ident();
205-
if ident.is_none() {
206-
let msg = "Must have specified ident";
207-
return Err(syn::Error::new_spanned(namevalue, msg));
208-
}
209-
match ident.unwrap().to_string().to_lowercase().as_str() {
204+
let ident = namevalue
205+
.path
206+
.get_ident()
207+
.ok_or_else(|| {
208+
syn::Error::new_spanned(&namevalue, "Must have specified ident")
209+
})?
210+
.to_string()
211+
.to_lowercase();
212+
match ident.as_str() {
210213
"worker_threads" => {
211214
config.set_worker_threads(
212215
namevalue.lit.clone(),
@@ -239,12 +242,11 @@ fn parse_knobs(
239242
}
240243
}
241244
syn::NestedMeta::Meta(syn::Meta::Path(path)) => {
242-
let ident = path.get_ident();
243-
if ident.is_none() {
244-
let msg = "Must have specified ident";
245-
return Err(syn::Error::new_spanned(path, msg));
246-
}
247-
let name = ident.unwrap().to_string().to_lowercase();
245+
let name = path
246+
.get_ident()
247+
.ok_or_else(|| syn::Error::new_spanned(&path, "Must have specified ident"))?
248+
.to_string()
249+
.to_lowercase();
248250
let msg = match name.as_str() {
249251
"threaded_scheduler" | "multi_thread" => {
250252
format!(
@@ -326,11 +328,11 @@ fn parse_knobs(
326328
#rt
327329
.enable_all()
328330
.build()
329-
.unwrap()
331+
.expect("Failed building the Runtime")
330332
.block_on(async #body)
331333
}
332334
})
333-
.unwrap();
335+
.expect("Parsing failure");
334336
input.block.brace_token = brace_token;
335337

336338
let result = quote! {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.