Skip to content

Commit 2410b0d

Browse files
Alexendoocuviper
authored andcommitted
Fix array-size-threshold config deserialization error
1 parent 005892a commit 2410b0d

File tree

9 files changed

+52
-16
lines changed

9 files changed

+52
-16
lines changed

src/tools/clippy/clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
768768
store.register_late_pass(|_| Box::new(mutable_debug_assertion::DebugAssertWithMutCall));
769769
store.register_late_pass(|_| Box::new(exit::Exit));
770770
store.register_late_pass(|_| Box::new(to_digit_is_some::ToDigitIsSome));
771-
let array_size_threshold = conf.array_size_threshold;
771+
let array_size_threshold = u128::from(conf.array_size_threshold);
772772
store.register_late_pass(move |_| Box::new(large_stack_arrays::LargeStackArrays::new(array_size_threshold)));
773773
store.register_late_pass(move |_| Box::new(large_const_arrays::LargeConstArrays::new(array_size_threshold)));
774774
store.register_late_pass(|_| Box::new(floating_point_arithmetic::FloatingPointArithmetic));

src/tools/clippy/clippy_lints/src/utils/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ define_Conf! {
333333
/// Lint: LARGE_STACK_ARRAYS, LARGE_CONST_ARRAYS.
334334
///
335335
/// The maximum allowed size for arrays on the stack
336-
(array_size_threshold: u128 = 512_000),
336+
(array_size_threshold: u64 = 512_000),
337337
/// Lint: VEC_BOX.
338338
///
339339
/// The size of the boxed type in bytes, where boxing in a `Vec` is allowed

src/tools/clippy/tests/ui/crashes/ice-10044.rs

-3
This file was deleted.

src/tools/clippy/tests/ui/crashes/ice-10044.stderr

-10
This file was deleted.

src/tools/clippy/tests/ui/large_stack_arrays.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn main() {
2424
[S { data: [0; 32] }; 5000],
2525
[Some(""); 20_000_000],
2626
[E::T(0); 5000],
27+
[0u8; usize::MAX],
2728
);
2829

2930
let good = (

src/tools/clippy/tests/ui/large_stack_arrays.stderr

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,13 @@ LL | [E::T(0); 5000],
3131
|
3232
= help: consider allocating on the heap with `vec![E::T(0); 5000].into_boxed_slice()`
3333

34-
error: aborting due to 4 previous errors
34+
error: allocating a local array larger than 512000 bytes
35+
--> $DIR/large_stack_arrays.rs:27:9
36+
|
37+
LL | [0u8; usize::MAX],
38+
| ^^^^^^^^^^^^^^^^^
39+
|
40+
= help: consider allocating on the heap with `vec![0u8; usize::MAX].into_boxed_slice()`
41+
42+
error: aborting due to 5 previous errors
3543

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![allow(unused)]
2+
#![warn(clippy::large_const_arrays, clippy::large_stack_arrays)]
3+
4+
const ABOVE: [u8; 11] = [0; 11];
5+
const BELOW: [u8; 10] = [0; 10];
6+
7+
fn main() {
8+
let above = [0u8; 11];
9+
let below = [0u8; 10];
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error: large array defined as const
2+
--> $DIR/array_size_threshold.rs:4:1
3+
|
4+
LL | const ABOVE: [u8; 11] = [0; 11];
5+
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| help: make this a static item: `static`
8+
|
9+
= note: `-D clippy::large-const-arrays` implied by `-D warnings`
10+
11+
error: allocating a local array larger than 10 bytes
12+
--> $DIR/array_size_threshold.rs:4:25
13+
|
14+
LL | const ABOVE: [u8; 11] = [0; 11];
15+
| ^^^^^^^
16+
|
17+
= help: consider allocating on the heap with `vec![0; 11].into_boxed_slice()`
18+
= note: `-D clippy::large-stack-arrays` implied by `-D warnings`
19+
20+
error: allocating a local array larger than 10 bytes
21+
--> $DIR/array_size_threshold.rs:8:17
22+
|
23+
LL | let above = [0u8; 11];
24+
| ^^^^^^^^^
25+
|
26+
= help: consider allocating on the heap with `vec![0u8; 11].into_boxed_slice()`
27+
28+
error: aborting due to 3 previous errors
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
array-size-threshold = 10

0 commit comments

Comments
 (0)