diff --git a/c2rust-analyze/src/analyze.rs b/c2rust-analyze/src/analyze.rs index 8feceea1d8..d52d04cef2 100644 --- a/c2rust-analyze/src/analyze.rs +++ b/c2rust-analyze/src/analyze.rs @@ -1491,7 +1491,7 @@ fn run(tcx: TyCtxt) { ptrs.push(ptr); format!("{{{}}}", ptr) }); - if ptrs.len() == 0 { + if ptrs.is_empty() { continue; } // TODO: emit addr_of when it's nontrivial diff --git a/c2rust-analyze/src/rewrite/apply.rs b/c2rust-analyze/src/rewrite/apply.rs index 72dedd4134..24be2bc614 100644 --- a/c2rust-analyze/src/rewrite/apply.rs +++ b/c2rust-analyze/src/rewrite/apply.rs @@ -607,10 +607,7 @@ impl LineMapBuilder { if i >= self.v.len() { self.v.resize(i + 1, None); } - self.v[i] = match self.v[i] { - None => Some(j), - Some(old_j) => Some(cmp::min(j, old_j)), - }; + self.v[i] = Some(self.v[i].map_or(j, |old_j| cmp::min(j, old_j))); } pub fn finish(self) -> Vec { diff --git a/c2rust-analyze/src/rewrite/mod.rs b/c2rust-analyze/src/rewrite/mod.rs index ce6b2198dc..0ab8422c22 100644 --- a/c2rust-analyze/src/rewrite/mod.rs +++ b/c2rust-analyze/src/rewrite/mod.rs @@ -255,7 +255,7 @@ fn add_annotations( line_map: Option<&[usize]>, mut annotations: Vec<(usize, String)>, ) -> String { - if annotations.len() == 0 { + if annotations.is_empty() { return src; }