Skip to content

Commit cfc44a3

Browse files
authored
Merge pull request #141 from rust-lang-ja/fix/clippy-20250127
Fix clippy
2 parents 42c1384 + e409510 commit cfc44a3

11 files changed

+107
-143
lines changed

.github/workflows/ci.yml

+32-30
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ name: CI
22

33
on:
44
schedule:
5-
- cron: '0 0 * * 6'
5+
- cron: "0 0 * * 6"
66
push:
77
branches:
8-
- '*'
8+
- "*"
99
pull_request:
10+
branches:
11+
- "master"
1012

1113
jobs:
1214
rustfmt:
@@ -18,19 +20,19 @@ jobs:
1820
- stable-x86_64-unknown-linux-gnu
1921

2022
name: Rustfmt (${{ matrix.toolchain }})
21-
runs-on: ubuntu-20.04
23+
runs-on: ubuntu-24.04
2224

2325
steps:
2426
- name: Checkout
25-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2628

27-
- name: 'Setup `${{ matrix.toolchain }}`'
29+
- name: "Setup `${{ matrix.toolchain }}`"
2830
uses: dtolnay/rust-toolchain@master
2931
with:
3032
toolchain: ${{ matrix.toolchain }}
3133
components: rustfmt
3234

33-
- name: 'Override `${{ matrix.toolchain }}'
35+
- name: "Override `${{ matrix.toolchain }}"
3436
run: |
3537
rustup override set ${{ matrix.toolchain }}
3638
@@ -44,37 +46,37 @@ jobs:
4446
matrix:
4547
toolchain:
4648
- 1.70.0-x86_64-pc-windows-msvc
47-
- 1.70.0-x86_64-apple-darwin
49+
- 1.70.0-aarch64-apple-darwin
4850
- 1.70.0-x86_64-unknown-linux-gnu
4951
- stable-x86_64-pc-windows-msvc
50-
- stable-x86_64-apple-darwin
52+
- stable-aarch64-apple-darwin
5153
- stable-x86_64-unknown-linux-gnu
5254
include:
53-
- { toolchain: 1.70.0-x86_64-pc-windows-msvc , os: windows-2019 }
54-
- { toolchain: 1.70.0-x86_64-apple-darwin , os: macos-11 }
55-
- { toolchain: 1.70.0-x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
56-
- { toolchain: stable-x86_64-pc-windows-msvc , os: windows-2019 }
57-
- { toolchain: stable-x86_64-apple-darwin , os: macos-11 }
58-
- { toolchain: stable-x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
55+
- { toolchain: 1.70.0-x86_64-pc-windows-msvc, os: windows-2022 }
56+
- { toolchain: 1.70.0-aarch64-apple-darwin, os: macos-14 }
57+
- { toolchain: 1.70.0-x86_64-unknown-linux-gnu, os: ubuntu-24.04 }
58+
- { toolchain: stable-x86_64-pc-windows-msvc, os: windows-2022 }
59+
- { toolchain: stable-aarch64-apple-darwin, os: macos-14 }
60+
- { toolchain: stable-x86_64-unknown-linux-gnu, os: ubuntu-24.04 }
5961

6062
name: Build (${{ matrix.toolchain }})
6163
runs-on: ${{ matrix.os }}
6264

6365
steps:
6466
- name: Disable `core.autocrlf`
6567
run: git config --global core.autocrlf false
66-
if: matrix.os == 'windows-2019'
68+
if: matrix.os == 'windows-2022'
6769

6870
- name: Checkout
69-
uses: actions/checkout@v3
71+
uses: actions/checkout@v4
7072

71-
- name: 'Setup `${{ matrix.toolchain }}`'
73+
- name: "Setup `${{ matrix.toolchain }}`"
7274
uses: dtolnay/rust-toolchain@master
7375
with:
7476
toolchain: ${{ matrix.toolchain }}
7577
components: clippy
7678

77-
- name: 'Override `${{ matrix.toolchain }}`'
79+
- name: "Override `${{ matrix.toolchain }}`"
7880
run: |
7981
rustup override set ${{ matrix.toolchain }}
8082
@@ -100,28 +102,28 @@ jobs:
100102
- 1.70.0-x86_64-unknown-linux-gnu
101103
- stable-x86_64-unknown-linux-gnu
102104
python-version:
103-
- '3.6' # https://packages.ubuntu.com/bionic/python3
104-
- '3.8' # https://packages.ubuntu.com/focal/python3
105+
- "3.12"
106+
- "3.13"
105107

106108
name: Expand_test (${{ matrix.toolchain }}, ${{ matrix.python-version }})
107-
runs-on: ubuntu-20.04
109+
runs-on: ubuntu-24.04
108110

109111
steps:
110112
- name: Checkout
111-
uses: actions/checkout@v3
113+
uses: actions/checkout@v4
112114

113-
- name: 'Setup `${{ matrix.toolchain }}`'
115+
- name: "Setup `${{ matrix.toolchain }}`"
114116
uses: dtolnay/rust-toolchain@master
115117
with:
116118
toolchain: ${{ matrix.toolchain }}
117119
components: rustfmt
118120

119-
- name: 'Override `${{ matrix.toolchain }}`'
121+
- name: "Override `${{ matrix.toolchain }}`"
120122
run: |
121123
rustup override set ${{ matrix.toolchain }}
122124
123125
- name: Setup Python ${{ matrix.python-version }}
124-
uses: actions/setup-python@v4
126+
uses: actions/setup-python@v5
125127
with:
126128
python-version: ${{ matrix.python-version }}
127129

@@ -130,25 +132,25 @@ jobs:
130132

131133
verify:
132134
name: Verify
133-
runs-on: ubuntu-20.04
135+
runs-on: ubuntu-24.04
134136

135137
steps:
136138
- name: Checkout
137-
uses: actions/checkout@v3
139+
uses: actions/checkout@v4
138140

139141
- name: Setup `1.70.0-x86_64-unknown-linux-gnu`
140142
uses: dtolnay/rust-toolchain@master
141143
with:
142144
toolchain: 1.70.0-x86_64-unknown-linux-gnu
143145

144-
- name: 'Override `1.70.0-x86_64-unknown-linux-gnu'
146+
- name: "Override `1.70.0-x86_64-unknown-linux-gnu"
145147
run: |
146148
rustup override set 1.70.0-x86_64-unknown-linux-gnu
147149
148150
- name: Setup Python 3.9
149-
uses: actions/setup-python@v4
151+
uses: actions/setup-python@v5
150152
with:
151-
python-version: '3.9'
153+
python-version: "3.9"
152154

153155
- name: Install `oj`
154156
run: pip install online-judge-tools

src/convolution.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,13 @@ mod tests {
391391
}
392392

393393
for i in 0..1000 {
394-
let a = vec![i64::min_value() + i];
394+
let a = vec![i64::MIN + i];
395395
let b = vec![1];
396396
assert_eq!(a, super::convolution_i64(&a, &b));
397397
}
398398

399399
for i in 0..1000 {
400-
let a = vec![i64::max_value() - i];
400+
let a = vec![i64::MAX - i];
401401
let b = vec![1];
402402
assert_eq!(a, super::convolution_i64(&a, &b));
403403
}

src/internal_bit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ mod tests {
2525
assert_eq!(30, super::ceil_pow2(1 << 30));
2626
assert_eq!(31, super::ceil_pow2((1 << 30) + 1));
2727

28-
assert_eq!(32, super::ceil_pow2(u32::max_value()));
28+
assert_eq!(32, super::ceil_pow2(u32::MAX));
2929
}
3030
}

src/internal_math.rs

+36-52
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ pub(crate) struct Barrett {
2727
impl Barrett {
2828
/// # Arguments
2929
/// * `m` `1 <= m`
30-
/// (Note: `m <= 2^31` should also hold, which is undocumented in the original library.
31-
/// See the [pull reqeust commment](https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484661007)
32-
/// for more details.)
30+
/// (Note: `m <= 2^31` should also hold, which is undocumented in the original library.
31+
/// See the [pull reqeust commment](https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484661007)
32+
/// for more details.)
3333
pub(crate) fn new(m: u32) -> Barrett {
3434
Barrett {
3535
_m: m,
@@ -208,7 +208,7 @@ pub(crate) fn primitive_root(m: i32) -> i32 {
208208
while x % 2 == 0 {
209209
x /= 2;
210210
}
211-
for i in (3..std::i32::MAX).step_by(2) {
211+
for i in (3..i32::MAX).step_by(2) {
212212
if i as i64 * i as i64 > x as i64 {
213213
break;
214214
}
@@ -328,55 +328,49 @@ mod tests {
328328
assert_eq!(pow_mod(0, 0, 3), 1);
329329
assert_eq!(pow_mod(0, 0, 723), 1);
330330
assert_eq!(pow_mod(0, 0, 998244353), 1);
331-
assert_eq!(pow_mod(0, 0, i32::max_value()), 1);
331+
assert_eq!(pow_mod(0, 0, i32::MAX), 1);
332332

333333
assert_eq!(pow_mod(0, 1, 1), 0);
334334
assert_eq!(pow_mod(0, 1, 3), 0);
335335
assert_eq!(pow_mod(0, 1, 723), 0);
336336
assert_eq!(pow_mod(0, 1, 998244353), 0);
337-
assert_eq!(pow_mod(0, 1, i32::max_value()), 0);
337+
assert_eq!(pow_mod(0, 1, i32::MAX), 0);
338338

339-
assert_eq!(pow_mod(0, i64::max_value(), 1), 0);
340-
assert_eq!(pow_mod(0, i64::max_value(), 3), 0);
341-
assert_eq!(pow_mod(0, i64::max_value(), 723), 0);
342-
assert_eq!(pow_mod(0, i64::max_value(), 998244353), 0);
343-
assert_eq!(pow_mod(0, i64::max_value(), i32::max_value()), 0);
339+
assert_eq!(pow_mod(0, i64::MAX, 1), 0);
340+
assert_eq!(pow_mod(0, i64::MAX, 3), 0);
341+
assert_eq!(pow_mod(0, i64::MAX, 723), 0);
342+
assert_eq!(pow_mod(0, i64::MAX, 998244353), 0);
343+
assert_eq!(pow_mod(0, i64::MAX, i32::MAX), 0);
344344

345345
assert_eq!(pow_mod(1, 0, 1), 0);
346346
assert_eq!(pow_mod(1, 0, 3), 1);
347347
assert_eq!(pow_mod(1, 0, 723), 1);
348348
assert_eq!(pow_mod(1, 0, 998244353), 1);
349-
assert_eq!(pow_mod(1, 0, i32::max_value()), 1);
349+
assert_eq!(pow_mod(1, 0, i32::MAX), 1);
350350

351351
assert_eq!(pow_mod(1, 1, 1), 0);
352352
assert_eq!(pow_mod(1, 1, 3), 1);
353353
assert_eq!(pow_mod(1, 1, 723), 1);
354354
assert_eq!(pow_mod(1, 1, 998244353), 1);
355-
assert_eq!(pow_mod(1, 1, i32::max_value()), 1);
356-
357-
assert_eq!(pow_mod(1, i64::max_value(), 1), 0);
358-
assert_eq!(pow_mod(1, i64::max_value(), 3), 1);
359-
assert_eq!(pow_mod(1, i64::max_value(), 723), 1);
360-
assert_eq!(pow_mod(1, i64::max_value(), 998244353), 1);
361-
assert_eq!(pow_mod(1, i64::max_value(), i32::max_value()), 1);
362-
363-
assert_eq!(pow_mod(i64::max_value(), 0, 1), 0);
364-
assert_eq!(pow_mod(i64::max_value(), 0, 3), 1);
365-
assert_eq!(pow_mod(i64::max_value(), 0, 723), 1);
366-
assert_eq!(pow_mod(i64::max_value(), 0, 998244353), 1);
367-
assert_eq!(pow_mod(i64::max_value(), 0, i32::max_value()), 1);
368-
369-
assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 1), 0);
370-
assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 3), 1);
371-
assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 723), 640);
372-
assert_eq!(
373-
pow_mod(i64::max_value(), i64::max_value(), 998244353),
374-
683296792
375-
);
376-
assert_eq!(
377-
pow_mod(i64::max_value(), i64::max_value(), i32::max_value()),
378-
1
379-
);
355+
assert_eq!(pow_mod(1, 1, i32::MAX), 1);
356+
357+
assert_eq!(pow_mod(1, i64::MAX, 1), 0);
358+
assert_eq!(pow_mod(1, i64::MAX, 3), 1);
359+
assert_eq!(pow_mod(1, i64::MAX, 723), 1);
360+
assert_eq!(pow_mod(1, i64::MAX, 998244353), 1);
361+
assert_eq!(pow_mod(1, i64::MAX, i32::MAX), 1);
362+
363+
assert_eq!(pow_mod(i64::MAX, 0, 1), 0);
364+
assert_eq!(pow_mod(i64::MAX, 0, 3), 1);
365+
assert_eq!(pow_mod(i64::MAX, 0, 723), 1);
366+
assert_eq!(pow_mod(i64::MAX, 0, 998244353), 1);
367+
assert_eq!(pow_mod(i64::MAX, 0, i32::MAX), 1);
368+
369+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 1), 0);
370+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 3), 1);
371+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 723), 640);
372+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 998244353), 683296792);
373+
assert_eq!(pow_mod(i64::MAX, i64::MAX, i32::MAX), 1);
380374

381375
assert_eq!(pow_mod(2, 3, 1_000_000_007), 8);
382376
assert_eq!(pow_mod(5, 7, 1_000_000_007), 78125);
@@ -409,7 +403,7 @@ mod tests {
409403
assert!(!is_prime(1_000_000_000));
410404
assert!(is_prime(1_000_000_007));
411405

412-
assert!(is_prime(i32::max_value()));
406+
assert!(is_prime(i32::MAX));
413407
}
414408

415409
#[test]
@@ -442,8 +436,8 @@ mod tests {
442436
(57, 81, 3),
443437
(12345, 67890, 15),
444438
(-3141592 * 6535, 3141592 * 8979, 3141592),
445-
(i64::max_value(), i64::max_value(), i64::max_value()),
446-
(i64::min_value(), i64::max_value(), 1),
439+
(i64::MAX, i64::MAX, i64::MAX),
440+
(i64::MIN, i64::MAX, 1),
447441
] {
448442
let (g_, x) = inv_gcd(a, b);
449443
assert_eq!(g, g_);
@@ -454,25 +448,15 @@ mod tests {
454448

455449
#[test]
456450
fn test_primitive_root() {
457-
for &p in &[
458-
2,
459-
3,
460-
5,
461-
7,
462-
233,
463-
200003,
464-
998244353,
465-
1_000_000_007,
466-
i32::max_value(),
467-
] {
451+
for &p in &[2, 3, 5, 7, 233, 200003, 998244353, 1_000_000_007, i32::MAX] {
468452
assert!(is_prime(p));
469453
let g = primitive_root(p);
470454
if p != 2 {
471455
assert_ne!(g, 1);
472456
}
473457

474458
let q = p - 1;
475-
for i in (2..i32::max_value()).take_while(|i| i * i <= q) {
459+
for i in (2..i32::MAX).take_while(|i| i * i <= q) {
476460
if q % i != 0 {
477461
break;
478462
}

src/internal_type_traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ macro_rules! impl_integral {
9999
impl BoundedBelow for $ty {
100100
#[inline]
101101
fn min_value() -> Self {
102-
Self::min_value()
102+
Self::MIN
103103
}
104104
}
105105

106106
impl BoundedAbove for $ty {
107107
#[inline]
108108
fn max_value() -> Self {
109-
Self::max_value()
109+
Self::MAX
110110
}
111111
}
112112

0 commit comments

Comments
 (0)