Skip to content

Commit d543e0d

Browse files
authored
Fix Clippy Lints for Rust 1.88 (#1472)
* Add ignore for files temporarily * Address lint in test target as well * Revert "Add ignore for files temporarily" This reverts commit f8a8d03. * Add first part of automated fixes * Add second part of automated fixes * Add third part of automated fixes * Manual fix for missing line * cargo fmt * Undo the lint allows from merge
1 parent 34ffae4 commit d543e0d

File tree

21 files changed

+56
-99
lines changed

21 files changed

+56
-99
lines changed

rustworkx-core/fuzz/fuzz_targets/test_fuzz_contraction.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![no_main]
2-
#![allow(clippy::uninlined_format_args)]
32

43
use arbitrary::{Arbitrary, Unstructured};
54
use libfuzzer_sys::fuzz_target;
@@ -66,7 +65,7 @@ fn fuzz_contract_nodes(input: ContractFuzzInput) {
6665
// Expected error — no-op
6766
}
6867
Err(err) => {
69-
panic!("Unexpected error during node contraction: {:?}", err);
68+
panic!("Unexpected error during node contraction: {err:?}");
7069
}
7170
}
7271
}

rustworkx-core/src/bipartite_coloring.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ mod test_bipartite_coloring {
666666
.map(|edge| *colors.get(&edge.id()).unwrap())
667667
.collect();
668668
if node_colors.len() != node_degree {
669-
panic!("Node {:?} does not have correct number of colors.", node);
669+
panic!("Node {node:?} does not have correct number of colors.");
670670
}
671671
}
672672

@@ -708,7 +708,7 @@ mod test_bipartite_coloring {
708708
.map(|edge| *colors.get(&edge.id()).unwrap())
709709
.collect();
710710
if node_colors.len() != node_degree {
711-
panic!("Node {:?} does not have correct number of colors.", node);
711+
panic!("Node {node:?} does not have correct number of colors.");
712712
}
713713
}
714714

rustworkx-core/src/dag_algo.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<E: Error> Display for TopologicalSortError<E> {
5959
write!(f, "At least one initial node is reachable from another")
6060
}
6161
TopologicalSortError::KeyError(ref e) => {
62-
write!(f, "The key callback failed with: {:?}", e)
62+
write!(f, "The key callback failed with: {e:?}")
6363
}
6464
}
6565
}
@@ -420,12 +420,11 @@ where
420420
self.first_iter = false;
421421
for node in &self.cur_layer {
422422
if self.graph.to_index(*node) >= self.graph.node_bound() {
423-
panic!("Node {:#?} is not present in the graph.", node);
423+
panic!("Node {node:#?} is not present in the graph.");
424424
}
425425
if self.cycle_check.contains(node) {
426426
return Some(Err(LayersError(format!(
427-
"An invalid first layer was provided: {:#?} appears more than once.",
428-
node
427+
"An invalid first layer was provided: {node:#?} appears more than once."
429428
))));
430429
}
431430
self.cycle_check.insert(*node);
@@ -436,7 +435,7 @@ where
436435
} else {
437436
for node in &self.cur_layer {
438437
if self.graph.to_index(*node) >= self.graph.node_bound() {
439-
panic!("Node {:#?} is not present in the graph.", node);
438+
panic!("Node {node:#?} is not present in the graph.");
440439
}
441440
let children = self
442441
.graph

rustworkx-core/src/err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn fmt_dag_would_cycle(f: &mut Formatter<'_>) -> std::fmt::Result {
5252
}
5353

5454
fn fmt_merge_error<E: Error>(f: &mut Formatter<'_>, inner: &E) -> std::fmt::Result {
55-
write!(f, "The merge callback failed with: {:?}", inner)
55+
write!(f, "The merge callback failed with: {inner:?}")
5656
}
5757

5858
/// Error returned by Layers function when an index is not part of the graph.

rustworkx-core/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282
//!
8383
//! <https://www.rustworkx.org/release_notes.html>
8484
85-
#![allow(clippy::uninlined_format_args)]
86-
8785
use std::convert::Infallible;
8886

8987
/// A convenient type alias that by default assumes no error can happen.

rustworkx-core/src/shortest_path/dijkstra.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ mod tests {
191191
g.add_edge(b, f, 15);
192192
g.add_edge(c, f, 11);
193193
g.add_edge(e, f, 6);
194-
println!("{:?}", g);
194+
println!("{g:?}");
195195
let scores: Result<DictMap<NodeIndex, usize>> =
196196
dijkstra(&g, a, None, |e| Ok(*e.weight()), None);
197197
let exp_scores: DictMap<NodeIndex, usize> =
@@ -220,7 +220,7 @@ mod tests {
220220
g.add_edge(b, f, 15);
221221
g.add_edge(c, f, 11);
222222
g.add_edge(e, f, 6);
223-
println!("{:?}", g);
223+
println!("{g:?}");
224224

225225
let scores: Result<DictMap<NodeIndex, usize>> =
226226
dijkstra(&g, a, Some(c), |e| Ok(*e.weight()), None);

rustworkx-core/src/shortest_path/single_source_all_shortest_paths.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,7 @@ mod tests {
367367
// Check no repeated nodes
368368
let mut seen = HashSet::new();
369369
for &n in path {
370-
assert!(
371-
seen.insert(n),
372-
"Path {:?} contains repeated node {:?}",
373-
path,
374-
n
375-
);
370+
assert!(seen.insert(n), "Path {path:?} contains repeated node {n:?}");
376371
}
377372
}
378373
}

src/centrality.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,7 @@ pub fn graph_eigenvector_centrality(
748748
.collect(),
749749
}),
750750
None => Err(FailedToConverge::new_err(format!(
751-
"Function failed to converge on a solution in {} iterations",
752-
max_iter
751+
"Function failed to converge on a solution in {max_iter} iterations"
753752
))),
754753
}
755754
}
@@ -836,8 +835,7 @@ pub fn digraph_eigenvector_centrality(
836835
.collect(),
837836
}),
838837
None => Err(FailedToConverge::new_err(format!(
839-
"Function failed to converge on a solution in {} iterations",
840-
max_iter
838+
"Function failed to converge on a solution in {max_iter} iterations"
841839
))),
842840
}
843841
}
@@ -966,8 +964,7 @@ pub fn graph_katz_centrality(
966964
.collect(),
967965
}),
968966
None => Err(FailedToConverge::new_err(format!(
969-
"Function failed to converge on a solution in {} iterations",
970-
max_iter
967+
"Function failed to converge on a solution in {max_iter} iterations"
971968
))),
972969
}
973970
}
@@ -1097,8 +1094,7 @@ pub fn digraph_katz_centrality(
10971094
.collect(),
10981095
}),
10991096
None => Err(FailedToConverge::new_err(format!(
1100-
"Function failed to converge on a solution in {} iterations",
1101-
max_iter
1097+
"Function failed to converge on a solution in {max_iter} iterations"
11021098
))),
11031099
}
11041100
}

src/dag_algo/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ pub fn layers(
301301
for layer_node in &first_layer {
302302
if !dag.graph.contains_node(NodeIndex::new(*layer_node)) {
303303
return Err(InvalidNode::new_err(format!(
304-
"An index input in 'first_layer' {} is not a valid node index in the graph",
305-
layer_node
304+
"An index input in 'first_layer' {layer_node} is not a valid node index in the graph"
306305
)));
307306
}
308307
}

src/digraph.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,7 @@ impl PyDiGraph {
895895
Some(data) => data,
896896
None => {
897897
return Err(PyIndexError::new_err(format!(
898-
"Provided edge index {} is not present in the graph",
899-
edge_index
898+
"Provided edge index {edge_index} is not present in the graph"
900899
)));
901900
}
902901
};
@@ -917,8 +916,7 @@ impl PyDiGraph {
917916
Some(endpoints) => (endpoints.0.index(), endpoints.1.index()),
918917
None => {
919918
return Err(PyIndexError::new_err(format!(
920-
"Provided edge index {} is not present in the graph",
921-
edge_index
919+
"Provided edge index {edge_index} is not present in the graph"
922920
)));
923921
}
924922
};
@@ -2622,7 +2620,7 @@ impl PyDiGraph {
26222620
.as_bytes(),
26232621
)?;
26242622
match weight_callable(py, &weight_fn, edge.weight(), None as Option<String>)? {
2625-
Some(weight) => buf_writer.write_all(format!("{}{}\n", delim, weight).as_bytes()),
2623+
Some(weight) => buf_writer.write_all(format!("{delim}{weight}\n").as_bytes()),
26262624
None => buf_writer.write_all(b"\n"),
26272625
}?;
26282626
}
@@ -2875,8 +2873,7 @@ impl PyDiGraph {
28752873
let node_index: NodeIndex = NodeIndex::new(node);
28762874
if self.graph.node_weight(node_index).is_none() {
28772875
return Err(PyIndexError::new_err(format!(
2878-
"Specified node {} is not in this graph",
2879-
node
2876+
"Specified node {node} is not in this graph"
28802877
)));
28812878
}
28822879
// Copy nodes from other to self
@@ -2927,8 +2924,7 @@ impl PyDiGraph {
29272924
Some(new_index) => NodeIndex::new(*new_index),
29282925
None => {
29292926
return Err(PyIndexError::new_err(format!(
2930-
"No mapped index {} found",
2931-
old_index
2927+
"No mapped index {old_index} found"
29322928
)))
29332929
}
29342930
},
@@ -2943,8 +2939,7 @@ impl PyDiGraph {
29432939
Some(new_index) => NodeIndex::new(*new_index),
29442940
None => {
29452941
return Err(PyIndexError::new_err(format!(
2946-
"No mapped index {} found",
2947-
old_index
2942+
"No mapped index {old_index} found"
29482943
)))
29492944
}
29502945
},

0 commit comments

Comments
 (0)