Skip to content

Commit d150a6b

Browse files
bors[bot]Henrik Tjäder
andauthored
Merge #59
59: Implement clippy suggestions r=korken89 a=AfoHT Co-authored-by: Henrik Tjäder <henrik@grepit.se>
2 parents c333b05 + a74dd56 commit d150a6b

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
@@ -25,7 +25,7 @@ impl Monotonic {
2525

2626
let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs.clone());
2727

28-
if attrs.len() > 0 {
28+
if !attrs.is_empty() {
2929
return Err(parse::Error::new(
3030
attrs[0].path.span(),
3131
"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
@@ -279,7 +279,7 @@ fn extract_init_resource_name_ident(ty: Type) -> Result<Ident, ()> {
279279
}
280280
}
281281

282-
/// Checks Init's return type and returns the user provided types for use in the analysis
282+
/// Checks Init's return type, return the user provided types for analysis
283283
pub fn type_is_init_return(ty: &ReturnType, name: &str) -> Result<(Ident, Ident), ()> {
284284
match ty {
285285
ReturnType::Default => Err(()),
@@ -291,13 +291,11 @@ pub fn type_is_init_return(ty: &ReturnType, name: &str) -> Result<(Ident, Ident)
291291
//
292292
// We check the length and the last one here, analysis checks that the user
293293
// provided structs are correct.
294-
if t.elems.len() == 3 {
295-
if type_is_path(&t.elems[2], &[name, "Monotonics"]) {
296-
return Ok((
297-
extract_init_resource_name_ident(t.elems[0].clone())?,
298-
extract_init_resource_name_ident(t.elems[1].clone())?,
299-
));
300-
}
294+
if t.elems.len() == 3 && type_is_path(&t.elems[2], &[name, "Monotonics"]) {
295+
return Ok((
296+
extract_init_resource_name_ident(t.elems[0].clone())?,
297+
extract_init_resource_name_ident(t.elems[1].clone())?,
298+
));
301299
}
302300

303301
Err(())

0 commit comments

Comments
 (0)