Skip to content

Commit

Permalink
Fix clippy issues related to appending format!-ed strings. (FuelLabs#…
Browse files Browse the repository at this point in the history
…3231)

This replaces appending the output of format! calls to a string with a
writeln! call, as suggested by clippy.

This started showing up locally, dunno why it does not show up on CI...
  • Loading branch information
tritao authored Nov 1, 2022
1 parent bdc3160 commit 04a61e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions sway-ir/src/analysis/dominator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{block::Block, BranchToWithArgs, Context, Function};
/// The algorithms implemented here are from the paper
// "A Simple, Fast Dominance Algorithm" -- Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy.
use rustc_hash::{FxHashMap, FxHashSet};
use std::fmt::Write;

/// Represents a node in the dominator tree.
pub struct DomTreeNode {
Expand Down Expand Up @@ -186,11 +187,12 @@ pub fn print_dot(context: &Context, func_name: &str, dom_tree: &DomTree) -> Stri
let mut res = format!("digraph {} {{\n", func_name);
for (b, idom) in dom_tree.iter() {
if let Some(idom) = idom.parent {
res += &(format!(
"\t{} -> {}\n",
let _ = writeln!(
res,
"\t{} -> {}",
idom.get_label(context),
b.get_label(context)
))
);
}
}
res += "}\n";
Expand Down
6 changes: 4 additions & 2 deletions sway-ir/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! existing in the function scope.
use std::collections::{BTreeMap, HashMap};
use std::fmt::Write;

use rustc_hash::{FxHashMap, FxHashSet};

Expand Down Expand Up @@ -473,11 +474,12 @@ impl Function {
let n = worklist.pop().unwrap();
visited.insert(n);
for BranchToWithArgs { block: n_succ, .. } in n.successors(context) {
res += &(format!(
let _ = writeln!(
res,
"\t{} -> {}\n",
n.get_label(context),
n_succ.get_label(context)
));
);
if !visited.contains(&n_succ) {
worklist.push(n_succ);
}
Expand Down

0 comments on commit 04a61e1

Please sign in to comment.