Skip to content

Commit 2cc4bfb

Browse files
committed
More clippy lint fixes which should be uncontroversial
Signed-off-by: Daniel Egger <[email protected]>
1 parent 77ce4d5 commit 2cc4bfb

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/generate/interrupt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ pub fn render(
308308
}
309309
}
310310

311-
if interrupts.len() > 0 {
311+
if !interrupts.is_empty() {
312312
root.push(quote! {
313313
#[doc(hidden)]
314314
pub mod interrupt {

src/generate/peripheral.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Region {
143143
// Sort by length and then content
144144
match a.len().cmp(&b.len()) {
145145
Ordering::Equal => a.cmp(b),
146-
cmp @ _ => cmp
146+
cmp => cmp
147147
}
148148
});
149149
Some(idents[0].to_owned())
@@ -188,12 +188,12 @@ impl Region {
188188
.map(|i| split_keep(i))
189189
.collect();
190190
let mut index = 0;
191-
let first = x.get(0).unwrap();
191+
let first = &x[0];
192192
// Get first elem, check against all other, break on mismatch
193193
'outer: while index < first.len() {
194194
for ident_match in x.iter().skip(1) {
195195
if let Some(match_) = ident_match.get(index) {
196-
if match_ != first.get(index).unwrap() {
196+
if match_ != &first[index] {
197197
break 'outer;
198198
}
199199
} else {
@@ -205,7 +205,7 @@ impl Region {
205205
if index <= 1 {
206206
None
207207
} else {
208-
if first.get(index).is_some() && first.get(index).unwrap().chars().all(|c| c.is_numeric()) {
208+
if first.get(index).is_some() && first[index].chars().all(|c| c.is_numeric()) {
209209
Some(first.iter().take(index).cloned().collect())
210210
} else {
211211
Some(first.iter().take(index - 1).cloned().collect())
@@ -231,7 +231,7 @@ impl Region {
231231
// This isn't a foolproof way of emitting the most
232232
// reasonable short description, but it's good enough.
233233
if f.description != result {
234-
if result.len() > 0 {
234+
if !result.is_empty() {
235235
result.push(' ');
236236
}
237237
result.push_str(&f.description);
@@ -553,8 +553,8 @@ fn expand(
553553

554554
for erc in ercs {
555555
ercs_expanded.extend(match erc {
556-
&Either::Left(ref register) => expand_register(register, defs, name)?,
557-
&Either::Right(ref cluster) => expand_cluster(cluster, defs)?,
556+
Either::Left(ref register) => expand_register(register, defs, name)?,
557+
Either::Right(ref cluster) => expand_cluster(cluster, defs)?,
558558
});
559559
}
560560

@@ -806,9 +806,9 @@ fn expand_svd_register(register: &Register, name: Option<&str>) -> Vec<syn::Fiel
806806

807807
for (idx, _i) in indices.iter().zip(0..) {
808808
let nb_name = if has_brackets {
809-
info.name.replace("[%s]", format!("{}", idx).as_str())
809+
info.name.replace("[%s]", idx)
810810
} else {
811-
info.name.replace("%s", format!("{}", idx).as_str())
811+
info.name.replace("%s", idx)
812812
};
813813

814814
let ty_name = if has_brackets {
@@ -930,9 +930,9 @@ fn expand_svd_cluster(cluster: &Cluster) -> Vec<syn::Field> {
930930

931931
for (idx, _i) in indices.iter().zip(0..) {
932932
let name = if has_brackets {
933-
info.name.replace("[%s]", format!("{}", idx).as_str())
933+
info.name.replace("[%s]", idx)
934934
} else {
935-
info.name.replace("%s", format!("{}", idx).as_str())
935+
info.name.replace("%s", idx)
936936
};
937937

938938
let ty_name = if has_brackets {

src/generate/register.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn render(
106106
let rv = register
107107
.reset_value
108108
.or(defs.reset_value)
109-
.map(|rv| util::hex(rv))
109+
.map(util::hex)
110110
.ok_or_else(|| format!("Register {} has no reset value", register.name))?;
111111

112112
w_impl_items.push(quote! {
@@ -494,7 +494,7 @@ pub fn fields(
494494
let pc = &v.pc;
495495
let sc = &v.sc;
496496

497-
let is_variant = if sc.as_ref().starts_with("_") {
497+
let is_variant = if sc.as_ref().starts_with('_') {
498498
Ident::new(&*format!("is{}", sc))
499499
} else {
500500
Ident::new(&*format!("is_{}", sc))
@@ -981,14 +981,14 @@ fn lookup_in_register<'r>(
981981
base_evs, register.name
982982
))?,
983983
Some(&(evs, field)) => if matches.len() == 1 {
984-
return Ok((
984+
Ok((
985985
evs,
986986
Some(Base {
987987
field: field,
988988
register: None,
989989
peripheral: None,
990990
}),
991-
));
991+
))
992992
} else {
993993
let fields = matches
994994
.iter()
@@ -1049,7 +1049,7 @@ fn periph_all_registers<'a>(p: &'a Peripheral) -> Vec<&'a Register> {
10491049
Either::Left(ref reg) => {
10501050
par.push(reg);
10511051
}
1052-
Either::Right(ref cluster) => for ref c in cluster.children.iter() {
1052+
Either::Right(ref cluster) => for c in cluster.children.iter() {
10531053
rem.push(c);
10541054
},
10551055
}

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub const BITS_PER_BYTE: u32 = 8;
1212

1313
/// List of chars that some vendors use in their peripheral/field names but
1414
/// that are not valid in Rust ident
15-
const BLACKLIST_CHARS: &'static [char] = &['(', ')', '[', ']', '/', ' '];
15+
const BLACKLIST_CHARS : &[char] = &['(', ')', '[', ']', '/', ' '];
1616

1717
pub trait ToSanitizedPascalCase {
1818
fn to_sanitized_pascal_case(&self) -> Cow<str>;

0 commit comments

Comments
 (0)