Skip to content

Commit

Permalink
new clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
EclecticGriffin committed Dec 10, 2024
1 parent cd84c17 commit 7e27bfc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
16 changes: 8 additions & 8 deletions calyx-ir/src/guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Printer;

use super::{NumAttr, Port, RRC};
use calyx_utils::Error;
use std::fmt::Debug;
use std::fmt::{Debug, Display};
use std::mem;
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not};
use std::{cmp::Ordering, hash::Hash, rc::Rc};
Expand All @@ -11,9 +11,9 @@ use std::{cmp::Ordering, hash::Hash, rc::Rc};
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct Nothing;

impl ToString for Nothing {
fn to_string(&self) -> String {
"".to_string()
impl std::fmt::Display for Nothing {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "")
}
}

Expand Down Expand Up @@ -62,12 +62,12 @@ pub struct StaticTiming {
interval: (u64, u64),
}

impl ToString for StaticTiming {
fn to_string(&self) -> String {
impl Display for StaticTiming {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.interval.0 + 1 == self.interval.1 {
format!("%{}", self.interval.0)
write!(f, "%{}", self.interval.0)
} else {
format!("%[{}:{}]", self.interval.0, self.interval.1)
write!(f, "%[{}:{}]", self.interval.0, self.interval.1)
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions calyx-utils/src/weight_graph.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use itertools::Itertools;
use petgraph::matrix_graph::{MatrixGraph, NodeIndex, UnMatrix, Zero};
use petgraph::visit::IntoEdgeReferences;
use std::{collections::HashMap, hash::Hash};
use std::{collections::HashMap, fmt::Display, hash::Hash};

/// Index into a [WeightGraph]
pub type Idx = NodeIndex;
Expand Down Expand Up @@ -126,14 +126,13 @@ where
}
}

impl<T: Eq + Hash + ToString + Clone + Ord> ToString for WeightGraph<T> {
fn to_string(&self) -> String {
impl<T: Eq + Hash + ToString + Clone + Ord> Display for WeightGraph<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let rev_map = self.reverse_index();
let keys: Vec<_> = self.index_map.keys().collect();
let nodes = keys
.iter()
.enumerate()
.map(|(_idx, key)| {
.map(|key| {
format!(
" {} [label=\"{}\"];",
key.to_string(),
Expand All @@ -154,6 +153,6 @@ impl<T: Eq + Hash + ToString + Clone + Ord> ToString for WeightGraph<T> {
})
.collect::<Vec<_>>()
.join("\n");
format!("graph {{ \n{}\n{}\n }}", nodes, edges)
write!(f, "graph {{ \n{}\n{}\n }}", nodes, edges)
}
}

0 comments on commit 7e27bfc

Please sign in to comment.