Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy Fix array-size-threshold config deserialization error #108674

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ The maximum number of lines a function or method can have
### array-size-threshold
The maximum allowed size for arrays on the stack

**Default Value:** `512000` (`u128`)
**Default Value:** `512000` (`u64`)

* [large_stack_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays)
* [large_const_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(|_| Box::new(mutable_debug_assertion::DebugAssertWithMutCall));
store.register_late_pass(|_| Box::new(exit::Exit));
store.register_late_pass(|_| Box::new(to_digit_is_some::ToDigitIsSome));
let array_size_threshold = conf.array_size_threshold;
let array_size_threshold = u128::from(conf.array_size_threshold);
store.register_late_pass(move |_| Box::new(large_stack_arrays::LargeStackArrays::new(array_size_threshold)));
store.register_late_pass(move |_| Box::new(large_const_arrays::LargeConstArrays::new(array_size_threshold)));
store.register_late_pass(|_| Box::new(floating_point_arithmetic::FloatingPointArithmetic));
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/utils/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ define_Conf! {
/// Lint: LARGE_STACK_ARRAYS, LARGE_CONST_ARRAYS.
///
/// The maximum allowed size for arrays on the stack
(array_size_threshold: u128 = 512_000),
(array_size_threshold: u64 = 512_000),
/// Lint: VEC_BOX.
///
/// The size of the boxed type in bytes, where boxing in a `Vec` is allowed
Expand Down
3 changes: 0 additions & 3 deletions src/tools/clippy/tests/ui/crashes/ice-10044.rs

This file was deleted.

10 changes: 0 additions & 10 deletions src/tools/clippy/tests/ui/crashes/ice-10044.stderr

This file was deleted.

1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/large_stack_arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fn main() {
[S { data: [0; 32] }; 5000],
[Some(""); 20_000_000],
[E::T(0); 5000],
[0u8; usize::MAX],
);

let good = (
Expand Down
10 changes: 9 additions & 1 deletion src/tools/clippy/tests/ui/large_stack_arrays.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,13 @@ LL | [E::T(0); 5000],
|
= help: consider allocating on the heap with `vec![E::T(0); 5000].into_boxed_slice()`

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

error: aborting due to 5 previous errors

10 changes: 10 additions & 0 deletions tests/ui-toml/array_size_threshold/array_size_threshold.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![allow(unused)]
#![warn(clippy::large_const_arrays, clippy::large_stack_arrays)]

const ABOVE: [u8; 11] = [0; 11];
const BELOW: [u8; 10] = [0; 10];

fn main() {
let above = [0u8; 11];
let below = [0u8; 10];
}
29 changes: 29 additions & 0 deletions tests/ui-toml/array_size_threshold/array_size_threshold.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error: large array defined as const
--> $DIR/array_size_threshold.rs:4:1
|
LL | const ABOVE: [u8; 11] = [0; 11];
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| help: make this a static item: `static`
|
= note: `-D clippy::large-const-arrays` implied by `-D warnings`

error: allocating a local array larger than 10 bytes
--> $DIR/array_size_threshold.rs:4:25
|
LL | const ABOVE: [u8; 11] = [0; 11];
| ^^^^^^^
|
= help: consider allocating on the heap with `vec![0; 11].into_boxed_slice()`
= note: `-D clippy::large-stack-arrays` implied by `-D warnings`

error: allocating a local array larger than 10 bytes
--> $DIR/array_size_threshold.rs:8:17
|
LL | let above = [0u8; 11];
| ^^^^^^^^^
|
= help: consider allocating on the heap with `vec![0u8; 11].into_boxed_slice()`

error: aborting due to 3 previous errors

1 change: 1 addition & 0 deletions tests/ui-toml/array_size_threshold/clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
array-size-threshold = 10