Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
- I won't document panics.
- `clippy::tuple-array-conversions` seems to have false positives.
- `clippy::tuple-array-conversions` seems to have false positives and is not very nice yet.
- `clippy::explicit-iter-loop` is currently only partly nice. See rust-lang/rust-clippy#11074
  • Loading branch information
Philippe-Cholet committed Aug 26, 2023
1 parent d881561 commit 2f815ea
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ntrii = "ntr --run-ignored all"

f = "fmt --check"

clip = "clippy -- -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used -W clippy::expect_used -W clippy::disallowed-types -A clippy::missing-errors-doc"
clip = "clippy -- -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used -W clippy::expect_used -W clippy::disallowed-types -A clippy::missing-errors-doc -A clippy::missing-panics-doc -A clippy::needless-collect -A clippy::tuple-array-conversions -A clippy::explicit-iter-loop"

cli = "run --bin cli-runner --profile final"

Expand Down
1 change: 1 addition & 0 deletions aoc2020/day13/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub fn solver(part: Part, input: &str) -> Result<String> {
.map(|(bus_id, time)| bus_id * time)
.context("No bus")?,
Part2 => {
#[allow(clippy::cast_possible_wrap)] // Issue only for VERY LARGE inputs!!!
let modular_equation: Vec<_> = bus_ids
.into_iter()
.enumerate()
Expand Down
4 changes: 2 additions & 2 deletions aoc2022/day20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ pub fn solver(part: Part, input: &str) -> Result<String> {
file.iter_mut().for_each(|elem| *elem *= DECRYPTION_KEY);
}
let mut data: Vec<_> = file.into_iter().enumerate().collect();
let modulus = (nb - 1) as i64;
let modulus = i64::try_from(nb - 1)?;
for _ in 0..part.value(1, 10) {
for idx in 0..nb {
let i0 = data
.iter()
.position(|(i, _)| i == &idx)
.context("Missing index")?;
let i1 = ((i0 as i64 + data[i0].1 - 1).rem_euclid(modulus) + 1).try_into()?;
let i1 = ((i64::try_from(i0)? + data[i0].1 - 1).rem_euclid(modulus) + 1).try_into()?;
data.remove_insert(i0, i1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions aoc2022/day22/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ fn follow_instructions(
grid: &[Vec<Tile>],
) -> Result<(usize, usize, Direction)> {
#[cfg(debug_assertions)]
for row in grid.iter() {
for tile in row.iter() {
for row in grid {
for tile in row {
match tile {
Tile::Open => print!("."),
Tile::Void => print!("+"),
Expand Down

0 comments on commit 2f815ea

Please sign in to comment.