Skip to content

Commit

Permalink
analyze: rewrite::distribute: refactor a loop to use itertools all_eq…
Browse files Browse the repository at this point in the history
…ual()
  • Loading branch information
spernsteiner committed Jun 9, 2023
1 parent e4c062c commit 2100f0f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions c2rust-analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ indexmap = "1.9.2"
env_logger = "0.10.0"
log = "0.4.17"
backtrace = "0.3.67"
itertools = "0.10"

[build-dependencies]
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.18.0" }
Expand Down
6 changes: 2 additions & 4 deletions c2rust-analyze/src/rewrite/expr/distribute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::rewrite::expr::mir_op::{self, MirRewrite};
use crate::rewrite::expr::unlower::{MirOrigin, MirOriginDesc, PreciseLoc};
use itertools::Itertools;
use log::*;
use rustc_hir::HirId;
use rustc_middle::mir::Location;
Expand Down Expand Up @@ -79,10 +80,7 @@ pub fn distribute(
// need to add rules to resolve it in a particular way, such as prioritizing one `SubLoc` or
// `MirOriginDesc` over another.
for (&hir_id, infos) in &info_map {
let all_same_loc = infos
.iter()
.skip(1)
.all(|i| i.loc == infos[0].loc && i.desc == infos[0].desc);
let all_same_loc = infos.iter().map(|i| (&i.loc, i.desc)).all_equal();
if !all_same_loc {
info!("rewrite info:");
for i in infos {
Expand Down

0 comments on commit 2100f0f

Please sign in to comment.