From eb710b497ffd05f8d7458e18ededbae6b318208d Mon Sep 17 00:00:00 2001 From: Vincent Lafeychine <vincent.lafeychine@proton.me> Date: Thu, 25 Apr 2024 22:37:35 +0200 Subject: [PATCH] clippy: Fix manual_while_let_some --- rr_frontend/.cargo/config.toml | 1 - rr_frontend/translation/src/checked_op_analysis.rs | 3 +-- rr_frontend/translation/src/environment/loops.rs | 5 +++-- rr_frontend/translation/src/environment/procedure.rs | 4 +--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml index b3a1f851..f139a0f3 100644 --- a/rr_frontend/.cargo/config.toml +++ b/rr_frontend/.cargo/config.toml @@ -80,7 +80,6 @@ rustflags = [ "-Aclippy::unwrap_in_result", # clippy::style - "-Aclippy::manual_while_let_some", "-Aclippy::map_clone", "-Aclippy::match_like_matches_macro", "-Aclippy::needless_borrow", diff --git a/rr_frontend/translation/src/checked_op_analysis.rs b/rr_frontend/translation/src/checked_op_analysis.rs index 9009d925..b7295099 100644 --- a/rr_frontend/translation/src/checked_op_analysis.rs +++ b/rr_frontend/translation/src/checked_op_analysis.rs @@ -115,8 +115,7 @@ impl<'def, 'tcx> CheckedOpLocalAnalysis<'def, 'tcx> { self.bb_queue.push(BasicBlock::from_u32(0)); } - while !self.bb_queue.is_empty() { - let next_bb = self.bb_queue.pop().unwrap(); + while let Some(next_bb) = self.bb_queue.pop() { if !self.visited_bbs.contains(&next_bb) { self.visited_bbs.insert(next_bb); self.visit_bb(next_bb); diff --git a/rr_frontend/translation/src/environment/loops.rs b/rr_frontend/translation/src/environment/loops.rs index 7ed585e3..75654faf 100644 --- a/rr_frontend/translation/src/environment/loops.rs +++ b/rr_frontend/translation/src/environment/loops.rs @@ -26,8 +26,8 @@ fn collect_loop_body( ) { let mut work_queue = vec![back_edge_source]; body.insert(back_edge_source); - while !work_queue.is_empty() { - let current = work_queue.pop().unwrap(); + + while let Some(current) = work_queue.pop() { for &predecessor in real_edges.predecessors(current) { if body.contains(&predecessor) { continue; @@ -38,6 +38,7 @@ fn collect_loop_body( } } } + debug!("Loop body (head={:?}): {:?}", head, body); } diff --git a/rr_frontend/translation/src/environment/procedure.rs b/rr_frontend/translation/src/environment/procedure.rs index 3180544c..3ab9916a 100644 --- a/rr_frontend/translation/src/environment/procedure.rs +++ b/rr_frontend/translation/src/environment/procedure.rs @@ -215,9 +215,7 @@ fn build_reachable_basic_blocks(mir: &Mir, real_edges: &RealEdges) -> HashSet<Ba let mut visited: HashSet<BasicBlock> = HashSet::new(); let mut to_visit: Vec<BasicBlock> = vec![mir.basic_blocks.indices().next().unwrap()]; - while !to_visit.is_empty() { - let source = to_visit.pop().unwrap(); - + while let Some(source) = to_visit.pop() { if visited.contains(&source) { continue; } -- GitLab