Skip to content

Commit 48c2d88

Browse files
committed
Enable the rust_2018_idioms lint as warning
This should become the default in the future: rust-lang/rust#54910 Reason this is put in lib.rs instead of CI: to ensure local invocations of cargo build and cargo clippy pick up the warning. Reason this is made a warning: so that code builds and runs anyway. On the CI, the `-D warnings` clippy argument will treat it as a hard error.
1 parent a136e53 commit 48c2d88

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

src/algorithms/fiduccia_mattheyses.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct Move {
3434
fn fiduccia_mattheyses<W>(
3535
partition: &mut [usize],
3636
weights: &[W],
37-
adjacency: CsMatView<i64>,
37+
adjacency: CsMatView<'_, i64>,
3838
max_passes: usize,
3939
max_moves_per_pass: usize,
4040
max_imbalance: Option<f64>,
@@ -362,7 +362,7 @@ where
362362
fn partition(
363363
&mut self,
364364
part_ids: &mut [usize],
365-
(adjacency, weights): (CsMatView<i64>, &'a [W]),
365+
(adjacency, weights): (CsMatView<'_, i64>, &'a [W]),
366366
) -> Result<Self::Metadata, Self::Error> {
367367
if part_ids.is_empty() {
368368
return Ok(Metadata::default());

src/algorithms/graph_growth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use sprs::CsMatView;
44
fn graph_growth(
55
initial_ids: &mut [usize],
66
weights: &[f64],
7-
adjacency: CsMatView<f64>,
7+
adjacency: CsMatView<'_, f64>,
88
num_parts: usize,
99
) {
1010
let (shape_x, shape_y) = adjacency.shape();
@@ -126,7 +126,7 @@ where
126126
fn partition(
127127
&mut self,
128128
part_ids: &mut [usize],
129-
(adjacency, weights): (CsMatView<f64>, W),
129+
(adjacency, weights): (CsMatView<'_, f64>, W),
130130
) -> Result<Self::Metadata, Self::Error> {
131131
graph_growth(
132132
part_ids,

src/algorithms/k_means.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ struct AlgorithmState<'a> {
174174
// - checking delta threshold
175175
// - relaxing lower and upper bounds
176176
fn balanced_k_means_iter<const D: usize>(
177-
inputs: Inputs<D>,
177+
inputs: Inputs<'_, D>,
178178
clusters: Clusters<Vec<PointND<D>>, &[ClusterId]>,
179179
permutation: &mut [usize],
180-
state: AlgorithmState,
180+
state: AlgorithmState<'_>,
181181
settings: &BalancedKmeansSettings,
182182
current_iter: usize,
183183
) where
@@ -300,7 +300,7 @@ fn assign_and_balance<const D: usize>(
300300
points: &[PointND<D>],
301301
weights: &[f64],
302302
permutation: &mut [usize],
303-
state: AlgorithmState,
303+
state: AlgorithmState<'_>,
304304
clusters: Clusters<&[PointND<D>], &[ClusterId]>,
305305
settings: &BalancedKmeansSettings,
306306
) where

src/algorithms/kernighan_lin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use sprs::CsMatView;
99
fn kernighan_lin(
1010
part_ids: &mut [usize],
1111
weights: &[f64],
12-
adjacency: CsMatView<f64>,
12+
adjacency: CsMatView<'_, f64>,
1313
max_passes: Option<usize>,
1414
max_flips_per_pass: Option<usize>,
1515
max_imbalance_per_flip: Option<f64>,
@@ -34,7 +34,7 @@ fn kernighan_lin(
3434
fn kernighan_lin_2_impl(
3535
initial_partition: &mut [usize],
3636
weights: &[f64],
37-
adjacency: CsMatView<f64>,
37+
adjacency: CsMatView<'_, f64>,
3838
max_passes: Option<usize>,
3939
max_flips_per_pass: Option<usize>,
4040
_max_imbalance_per_flip: Option<f64>,
@@ -265,7 +265,7 @@ impl<'a> crate::Partition<(CsMatView<'a, f64>, &'a [f64])> for KernighanLin {
265265
fn partition(
266266
&mut self,
267267
part_ids: &mut [usize],
268-
(adjacency, weights): (CsMatView<f64>, &'a [f64]),
268+
(adjacency, weights): (CsMatView<'_, f64>, &'a [f64]),
269269
) -> Result<Self::Metadata, Self::Error> {
270270
kernighan_lin(
271271
part_ids,

src/algorithms/recursive_bisection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ where
151151
}
152152

153153
fn rcb_recurse<const D: usize, W>(
154-
items: &mut [Item<D, W>],
154+
items: &mut [Item<'_, D, W>],
155155
iter_count: usize,
156156
iter_id: usize,
157157
coord: usize,
@@ -576,7 +576,7 @@ mod tests {
576576
let sum: u32 = weights.iter().sum();
577577

578578
let part = &AtomicUsize::new(0);
579-
let mut items: Vec<Item<2, u32>> = points
579+
let mut items: Vec<Item<'_, 2, u32>> = points
580580
.into_iter()
581581
.zip(weights)
582582
.map(|(point, weight)| Item {

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
//! - [Fiduccia-Mattheyses][FiducciaMattheyses]
3030
//! - [Kernighan-Lin][KernighanLin]
3131
32+
#![warn(rust_2018_idioms)]
33+
3234
mod algorithms;
3335
mod geometry;
3436
pub mod imbalance;

src/topology.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use std::iter::Sum;
2727
/// 1* ┆╲ ╱
2828
/// * 0
2929
/// ```
30-
pub fn edge_cut<T>(adjacency: CsMatView<T>, partition: &[usize]) -> T
30+
pub fn edge_cut<T>(adjacency: CsMatView<'_, T>, partition: &[usize]) -> T
3131
where
3232
T: Copy + Sum + Send + Sync + PartialEq,
3333
{
@@ -53,7 +53,7 @@ where
5353
.sum()
5454
}
5555

56-
pub fn lambda_cut<T>(adjacency: CsMatView<T>, partition: &[usize]) -> usize {
56+
pub fn lambda_cut<T>(adjacency: CsMatView<'_, T>, partition: &[usize]) -> usize {
5757
let indptr = adjacency.indptr().into_raw_storage();
5858
let indices = adjacency.indices();
5959
indptr
@@ -92,7 +92,7 @@ pub fn lambda_cut<T>(adjacency: CsMatView<T>, partition: &[usize]) -> usize {
9292
///
9393
/// If the entry `(i, j)` is non-zero, then its value is the weight of the edge between `i`
9494
/// and `j` (default to `1.0`).
95-
pub fn adjacency_matrix(conn: CsMatView<u32>, num_common_nodes: u32) -> CsMat<f64> {
95+
pub fn adjacency_matrix(conn: CsMatView<'_, u32>, num_common_nodes: u32) -> CsMat<f64> {
9696
// currently this matmul operation is very slow
9797
let graph = &conn * &conn.transpose_view();
9898

0 commit comments

Comments
 (0)