Skip to content

Commit a74dd56

Browse files
author
Henrik Tjäder
committed
Implement clippy suggestions
1 parent c356cea commit a74dd56

File tree

5 files changed

+14
-23
lines changed

5 files changed

+14
-23
lines changed

src/accessors.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ impl App {
3232
}
3333

3434
fn is_external(task_local: &TaskLocal) -> bool {
35-
match task_local {
36-
TaskLocal::External => true,
37-
_ => false,
38-
}
35+
matches!(task_local, TaskLocal::External)
3936
}
4037

4138
pub(crate) fn local_resource_accesses(&self) -> impl Iterator<Item = &Ident> {

src/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
172172

173173
// Collect errors if any and return/halt
174174
if !error.is_empty() {
175-
let mut err = error.iter().next().unwrap().clone();
175+
let mut err = error.get(0).unwrap().clone();
176176
error.iter().for_each(|e| err.combine(e.clone()));
177177
return Err(err);
178178
}

src/parse.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,16 @@ fn init_args(tokens: TokenStream2) -> parse::Result<InitArgs> {
107107
break;
108108
}
109109

110-
// ,
111110
let _: Token![,] = content.parse()?;
112111
}
113112

114113
if let Some(locals) = &local_resources {
115114
for (ident, task_local) in locals {
116-
match task_local {
117-
TaskLocal::External => {
118-
return Err(parse::Error::new(
119-
ident.span(),
120-
"only declared local resources are allowed in init",
121-
));
122-
}
123-
_ => {}
115+
if let TaskLocal::External = task_local {
116+
return Err(parse::Error::new(
117+
ident.span(),
118+
"only declared local resources are allowed in init",
119+
));
124120
}
125121
}
126122
}

src/parse/monotonic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Monotonic {
2424

2525
let (cfgs, attrs) = util::extract_cfgs(item.attrs.clone());
2626

27-
if attrs.len() > 0 {
27+
if !attrs.is_empty() {
2828
return Err(parse::Error::new(
2929
attrs[0].path.span(),
3030
"Monotonic does not support attributes other than `#[cfg]`",

src/parse/util.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn extract_init_resource_name_ident(ty: Type) -> Result<Ident, ()> {
270270
}
271271
}
272272

273-
/// Checks Init's return type and returns the user provided types for use in the analysis
273+
/// Checks Init's return type, return the user provided types for analysis
274274
pub fn type_is_init_return(ty: &ReturnType, name: &str) -> Result<(Ident, Ident), ()> {
275275
match ty {
276276
ReturnType::Default => Err(()),
@@ -282,13 +282,11 @@ pub fn type_is_init_return(ty: &ReturnType, name: &str) -> Result<(Ident, Ident)
282282
//
283283
// We check the length and the last one here, analysis checks that the user
284284
// provided structs are correct.
285-
if t.elems.len() == 3 {
286-
if type_is_path(&t.elems[2], &[name, "Monotonics"]) {
287-
return Ok((
288-
extract_init_resource_name_ident(t.elems[0].clone())?,
289-
extract_init_resource_name_ident(t.elems[1].clone())?,
290-
));
291-
}
285+
if t.elems.len() == 3 && type_is_path(&t.elems[2], &[name, "Monotonics"]) {
286+
return Ok((
287+
extract_init_resource_name_ident(t.elems[0].clone())?,
288+
extract_init_resource_name_ident(t.elems[1].clone())?,
289+
));
292290
}
293291

294292
Err(())

0 commit comments

Comments
 (0)