Skip to content

Commit 1a44035

Browse files
committed
fix lints and update dep
1 parent f303fe1 commit 1a44035

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ graphviz = ["dep:graphviz-rust"]
1717
[dependencies]
1818
indexmap = "2.0.0"
1919
once_cell = "1.18.0"
20-
ordered-float = "3.7.0"
20+
ordered-float = "5.0"
2121

2222
[dependencies.serde]
2323
default-features = false

src/algorithms.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ impl EGraph {
157157
.partition(|node_id| should_split(node_id, &self.nodes[node_id]));
158158
if unique_nodes.len() > 1 {
159159
panic!(
160-
"Multiple nodes in one e-class should be split. E-class: {:?} Nodes: {:?}",
161-
id, unique_nodes
160+
"Multiple nodes in one e-class should be split. E-class: {id:?} Nodes: {unique_nodes:?}"
162161
);
163162
}
164163
let unique_node = unique_nodes.into_iter().next();
@@ -175,7 +174,7 @@ impl EGraph {
175174
for other_node_id in other_nodes.into_iter().skip(1) {
176175
changed = true;
177176
// use same ID for new class and new node added to that class
178-
let new_id = format!("split-{}-{}", offset, unique_node_id);
177+
let new_id = format!("split-{offset}-{unique_node_id}");
179178
offset += 1;
180179
let new_class_id: ClassId = new_id.clone().into();
181180
// Copy the class data if it exists
@@ -196,7 +195,7 @@ impl EGraph {
196195
continue;
197196
}
198197
changed = true;
199-
let new_id = format!("split-{}-{}", offset, unique_node_id);
198+
let new_id = format!("split-{offset}-{unique_node_id}");
200199
let new_class_id: ClassId = new_id.clone().into();
201200
// Copy the class data if it exists
202201
if let Some(class_data) = &class_data {

src/graphviz.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl EGraph {
9090
// Add nodes
9191
for (node_id, node) in nodes {
9292
let label = node.op.as_ref();
93-
let tooltip = format!("{}: {}", class_id, node_id);
93+
let tooltip = format!("{class_id}: {node_id}");
9494
let html_label = html_label(label, node.children.len());
9595
let quoted_tooltip = quote(&tooltip);
9696
let quoted_node_id = quote(node_id.as_ref());
@@ -99,7 +99,7 @@ impl EGraph {
9999
let source = node_id!(quoted_node_id, port!(id!(i), "s"));
100100
let target = node_id!(quote(child.as_ref()));
101101
let child_eclass = node_to_class.get(child).unwrap();
102-
let child_subgraph_id = format!("cluster_{}", child_eclass);
102+
let child_subgraph_id = format!("cluster_{child_eclass}");
103103
let edge = edge!(source => target; EdgeAttributes::lhead(quote(&child_subgraph_id)));
104104
// Make sure edge is part of outer statements so it doesn't add nodes to the subgraph which
105105
// don't belong there
@@ -109,8 +109,8 @@ impl EGraph {
109109
inner_stmts.push(stmt!(node));
110110
}
111111

112-
let subgraph_id = format!("cluster_{}", class_id);
113-
let outer_subgraph_id = quote(&format!("outer_{}", subgraph_id));
112+
let subgraph_id = format!("cluster_{class_id}");
113+
let outer_subgraph_id = quote(&format!("outer_{subgraph_id}"));
114114
let quoted_subgraph_id = quote(&subgraph_id);
115115

116116
let subgraph = subgraph!(outer_subgraph_id;
@@ -150,15 +150,15 @@ const INITIAL_COLOR: usize = 2;
150150
fn html_label(label: &str, n_args: usize) -> String {
151151
format!(
152152
"<<TABLE BGCOLOR=\"white\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" style=\"rounded\"><tr><td BALIGN=\"left\" CELLPADDING=\"4\" WIDTH=\"30\" HEIGHT=\"30\"{}>{}</td></tr>{}</TABLE>>",
153-
(if n_args == 0 {"".to_string()} else {format!(" colspan=\"{}\"", n_args)}),
153+
(if n_args == 0 {"".to_string()} else {format!(" colspan=\"{n_args}\"")}),
154154
Escape(label),
155155
(if n_args == 0 {
156156
"".to_string()
157157
} else {
158158
format!(
159159
"<TR>{}</TR>",
160160
(0..n_args)
161-
.map(|i| format!("<TD PORT=\"{}\"></TD>", i))
161+
.map(|i| format!("<TD PORT=\"{i}\"></TD>"))
162162
.collect::<Vec<String>>()
163163
.join("")
164164
)
@@ -168,7 +168,7 @@ fn html_label(label: &str, n_args: usize) -> String {
168168

169169
/// Adds double quotes and escapes the quotes in the string
170170
fn quote(s: &str) -> String {
171-
format!("{:?}", s)
171+
format!("{s:?}")
172172
}
173173

174174
// Copied from https://doc.rust-lang.org/stable/nightly-rustc/src/rustdoc/html/escape.rs.html#10

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl std::ops::Index<&NodeId> for EGraph {
148148
fn index(&self, index: &NodeId) -> &Self::Output {
149149
self.nodes
150150
.get(index)
151-
.unwrap_or_else(|| panic!("No node with id {:?}", index))
151+
.unwrap_or_else(|| panic!("No node with id {index:?}"))
152152
}
153153
}
154154

@@ -158,7 +158,7 @@ impl std::ops::Index<&ClassId> for EGraph {
158158
fn index(&self, index: &ClassId) -> &Self::Output {
159159
self.classes()
160160
.get(index)
161-
.unwrap_or_else(|| panic!("No class with id {:?}", index))
161+
.unwrap_or_else(|| panic!("No class with id {index:?}"))
162162
}
163163
}
164164

tests/round_trip.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
use std::path::Path;
2-
use std::path::PathBuf;
1+
use std::path::{Path, PathBuf};
32

43
use egraph_serialize::*;
54

65
#[test]
76
fn test_round_trip() {
87
let mut n_tested = 0;
98
for entry in test_files() {
10-
println!("Testing {:?}", entry);
9+
println!("Testing {entry:?}");
1110
let egraph = EGraph::from_json_file(entry.as_path()).unwrap();
1211
egraph.test_round_trip();
1312
n_tested += 1;
@@ -26,7 +25,7 @@ fn test_graphviz() {
2625

2726
let mut names = Vec::new();
2827
for entry in test_files() {
29-
println!("Testing graphviz {:?}", entry);
28+
println!("Testing graphviz {entry:?}");
3029
let mut egraph = EGraph::from_json_file(entry.as_path()).unwrap();
3130
names.push(entry.file_stem().unwrap().to_str().unwrap().to_string());
3231

@@ -38,9 +37,9 @@ fn test_graphviz() {
3837
.join(entry.file_name().unwrap())
3938
.with_extension("svg");
4039
if path.exists() {
41-
println!("Skipping {:?}", path);
40+
println!("Skipping {path:?}");
4241
} else {
43-
println!("Writing to {:?}", path);
42+
println!("Writing to {path:?}");
4443
egraph.to_svg_file(path).unwrap();
4544
}
4645
}
@@ -55,9 +54,9 @@ fn test_graphviz() {
5554
entry.file_stem().unwrap().to_str().unwrap()
5655
));
5756
if path.exists() {
58-
println!("Skipping {:?}", path);
57+
println!("Skipping {path:?}");
5958
} else {
60-
println!("Writing to {:?}", path);
59+
println!("Writing to {path:?}");
6160
egraph.to_svg_file(path).unwrap();
6261
}
6362
}
@@ -72,9 +71,9 @@ fn test_graphviz() {
7271
entry.file_stem().unwrap().to_str().unwrap()
7372
));
7473
if path.exists() {
75-
println!("Skipping {:?}", path);
74+
println!("Skipping {path:?}");
7675
} else {
77-
println!("Writing to {:?}", path);
76+
println!("Writing to {path:?}");
7877
egraph.to_svg_file(path).unwrap();
7978
}
8079
}
@@ -93,8 +92,7 @@ This is a list of all the tests in the `tests` directory. Each test is a JSON fi
9392
.iter()
9493
.map(|name| {
9594
format!(
96-
"| [`{}`](../tests/{}.json) | ![svg file](./{}.svg) | ![inlined leaves svg file](./{}-inlined.svg) | ![inlined leaves saturated svg file](./{}-inlined-saturated.svg) |",
97-
name, name, name, name, name
95+
"| [`{name}`](../tests/{name}.json) | ![svg file](./{name}.svg) | ![inlined leaves svg file](./{name}-inlined.svg) | ![inlined leaves saturated svg file](./{name}-inlined-saturated.svg) |"
9896
)
9997
})
10098
.collect::<Vec<_>>()

0 commit comments

Comments
 (0)