diff --git a/benches/movingai.rs b/benches/movingai.rs index 69284b88..5d841aa4 100644 --- a/benches/movingai.rs +++ b/benches/movingai.rs @@ -1,7 +1,5 @@ // Test with files from https://movingai.com/benchmarks/ -#![allow(clippy::cast_precision_loss)] - use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion}; use movingai::parser::{parse_map_file, parse_scen_file}; use movingai::{Coords2D, Map2D}; @@ -9,6 +7,7 @@ use noisy_float::prelude::*; use pathfinding::directed::astar::astar; use std::path::Path; +#[allow(clippy::cast_precision_loss)] fn distance(a: &Coords2D, b: &Coords2D) -> R64 { r64((a.0 as f64 - b.0 as f64).hypot(a.1 as f64 - b.1 as f64)) } diff --git a/examples/sliding-puzzle.rs b/examples/sliding-puzzle.rs index 3193a559..79ee9921 100644 --- a/examples/sliding-puzzle.rs +++ b/examples/sliding-puzzle.rs @@ -1,5 +1,3 @@ -#![allow(clippy::cast_possible_truncation)] - use itertools::Itertools; use lazy_static::lazy_static; use pathfinding::prelude::{astar, idastar}; @@ -37,7 +35,7 @@ lazy_static! { positions: { let mut p = [0u8; LIMIT]; for (i, e) in p.iter_mut().enumerate() { - *e = i as u8; + *e = u8::try_from(i).unwrap(); } p }, @@ -125,7 +123,8 @@ impl Game { } fn from_array(positions: [u8; LIMIT]) -> Game { - let hole_idx = positions.iter().find_position(|&&n| n == 0).unwrap().0 as u8; + let hole_idx = + u8::try_from(positions.iter().find_position(|&&n| n == 0).unwrap().0).unwrap(); let mut game = Game { positions, hole_idx, diff --git a/src/directed/edmonds_karp.rs b/src/directed/edmonds_karp.rs index 0aa1e828..4156f25b 100644 --- a/src/directed/edmonds_karp.rs +++ b/src/directed/edmonds_karp.rs @@ -14,7 +14,6 @@ use std::collections::{BTreeMap, BTreeSet, VecDeque}; use std::hash::Hash; /// Type alias for Edmonds-Karp maximum flow result. -#[allow(clippy::upper_case_acronyms)] pub type EKFlows = (Vec>, C, Vec>); /// Type alias for representing an edge in a graph diff --git a/src/matrix.rs b/src/matrix.rs index 0a1c20e4..0b71c1ef 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -86,7 +86,6 @@ impl Matrix { /// /// [`MatrixFormatError::WrongIndex`] if the ranges /// are outside the original matrix. - #[allow(clippy::needless_pass_by_value)] pub fn slice( &self, rows: Range, diff --git a/src/utils.rs b/src/utils.rs index 3358a3dc..0d3fd803 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -13,11 +13,6 @@ use num_traits::{PrimInt, Unsigned}; /// assert_eq!(uint_sqrt(100usize), Some(10)); /// assert_eq!(uint_sqrt(10usize), None); /// ``` -#[allow( - clippy::cast_possible_truncation, - clippy::cast_precision_loss, - clippy::cast_sign_loss -)] pub fn uint_sqrt(n: T) -> Option where T: PrimInt + Unsigned, diff --git a/tests/codejam-2017-a.rs b/tests/codejam-2017-a.rs index 17e79dae..f3bdcb64 100644 --- a/tests/codejam-2017-a.rs +++ b/tests/codejam-2017-a.rs @@ -1,8 +1,6 @@ // Problem A from the Google Code Jam finals 2017. // https://code.google.com/codejam/contest/dashboard?c=6314486#s=p0&a=0 -#![allow(clippy::cast_sign_loss)] - use pathfinding::prelude::*; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::io::prelude::*; @@ -101,6 +99,7 @@ fn test>(n: usize, file: &mut dyn BufRead) -> Result= 0); + #[allow(clippy::cast_sign_loss)] let n = n as usize; if n > max { max = n; diff --git a/tests/gps.rs b/tests/gps.rs index 51a80459..4b8d2285 100644 --- a/tests/gps.rs +++ b/tests/gps.rs @@ -1,5 +1,4 @@ #![cfg(test)] -#![allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] use pathfinding::prelude::*; use std::collections::HashMap; @@ -16,6 +15,7 @@ impl Coords { self.1.to_radians() } + #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] fn distance_in_meters(&self, other: &Coords) -> u64 { let x = (other.lon_rad() - self.lon_rad()) * ((other.lat_rad() + self.lat_rad()) / 2.0).cos();