Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2e256a4

Browse files
authoredMar 3, 2023
Rollup merge of rust-lang#108674 - flip1995:clippy_backport, r=Manishearth
Clippy Fix array-size-threshold config deserialization error Complementary PR to rust-lang#108673 in order to also get this into the **next** beta. r? `@Mark-Simulacrum`
2 parents 843a062 + 23d4757 commit 2e256a4

File tree

10 files changed

+53
-17
lines changed

10 files changed

+53
-17
lines changed
 

‎src/tools/clippy/book/src/lint_configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ The maximum number of lines a function or method can have
306306
### array-size-threshold
307307
The maximum allowed size for arrays on the stack
308308

309-
**Default Value:** `512000` (`u128`)
309+
**Default Value:** `512000` (`u64`)
310310

311311
* [large_stack_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays)
312312
* [large_const_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
777777
store.register_late_pass(|_| Box::new(mutable_debug_assertion::DebugAssertWithMutCall));
778778
store.register_late_pass(|_| Box::new(exit::Exit));
779779
store.register_late_pass(|_| Box::new(to_digit_is_some::ToDigitIsSome));
780-
let array_size_threshold = conf.array_size_threshold;
780+
let array_size_threshold = u128::from(conf.array_size_threshold);
781781
store.register_late_pass(move |_| Box::new(large_stack_arrays::LargeStackArrays::new(array_size_threshold)));
782782
store.register_late_pass(move |_| Box::new(large_const_arrays::LargeConstArrays::new(array_size_threshold)));
783783
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
@@ -334,7 +334,7 @@ define_Conf! {
334334
/// Lint: LARGE_STACK_ARRAYS, LARGE_CONST_ARRAYS.
335335
///
336336
/// The maximum allowed size for arrays on the stack
337-
(array_size_threshold: u128 = 512_000),
337+
(array_size_threshold: u64 = 512_000),
338338
/// Lint: VEC_BOX.
339339
///
340340
/// 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)
Please sign in to comment.