about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Macleod <alex@macleod.io>2023-02-28 12:45:19 +0000
committerflip1995 <hello@philkrones.com>2023-03-02 21:42:11 +0100
commit64b54ef9507b42e0e0758c4fda2258c6753964da (patch)
treeeb36c051425768cf280c738449ac13956fb398ff
parent5cf9c3422c5ab9835775735bf241304103a74f2d (diff)
downloadrust-64b54ef9507b42e0e0758c4fda2258c6753964da.tar.gz
rust-64b54ef9507b42e0e0758c4fda2258c6753964da.zip
Fix array-size-threshold config deserialization error
-rw-r--r--book/src/lint_configuration.md2
-rw-r--r--clippy_lints/src/lib.rs2
-rw-r--r--clippy_lints/src/utils/conf.rs2
-rw-r--r--tests/ui/crashes/ice-10044.rs3
-rw-r--r--tests/ui/crashes/ice-10044.stderr10
-rw-r--r--tests/ui/large_stack_arrays.rs1
-rw-r--r--tests/ui/large_stack_arrays.stderr10
7 files changed, 13 insertions, 17 deletions
diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md
index 33f2b5c1de9..995dd2f04b1 100644
--- a/book/src/lint_configuration.md
+++ b/book/src/lint_configuration.md
@@ -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)
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 145cf524652..c626e0bd998 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -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));
diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs
index 5f74de5a288..1c7f3e96db8 100644
--- a/clippy_lints/src/utils/conf.rs
+++ b/clippy_lints/src/utils/conf.rs
@@ -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
diff --git a/tests/ui/crashes/ice-10044.rs b/tests/ui/crashes/ice-10044.rs
deleted file mode 100644
index 65f38fe7118..00000000000
--- a/tests/ui/crashes/ice-10044.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
-    [0; usize::MAX];
-}
diff --git a/tests/ui/crashes/ice-10044.stderr b/tests/ui/crashes/ice-10044.stderr
deleted file mode 100644
index 731f8265ad6..00000000000
--- a/tests/ui/crashes/ice-10044.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: statement with no effect
-  --> $DIR/ice-10044.rs:2:5
-   |
-LL |     [0; usize::MAX];
-   |     ^^^^^^^^^^^^^^^^
-   |
-   = note: `-D clippy::no-effect` implied by `-D warnings`
-
-error: aborting due to previous error
-
diff --git a/tests/ui/large_stack_arrays.rs b/tests/ui/large_stack_arrays.rs
index 6790765f803..99787ffd3d3 100644
--- a/tests/ui/large_stack_arrays.rs
+++ b/tests/ui/large_stack_arrays.rs
@@ -24,6 +24,7 @@ fn main() {
         [S { data: [0; 32] }; 5000],
         [Some(""); 20_000_000],
         [E::T(0); 5000],
+        [0u8; usize::MAX],
     );
 
     let good = (
diff --git a/tests/ui/large_stack_arrays.stderr b/tests/ui/large_stack_arrays.stderr
index c7bf941ad00..24e90094982 100644
--- a/tests/ui/large_stack_arrays.stderr
+++ b/tests/ui/large_stack_arrays.stderr
@@ -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