Skip to content

Commit 98ced04

Browse files
authored
Do not warn about large stack arrays without having a valid span (#16347)
The libtest harness generates an array with all the tests on the stack. However, it is generated with no location information, so we cannot tell the user anything useful. This commit is not accompanied by a test, as it would require running Clippy on the result of libtest harness with a lot of tests, which would take a very long time. A note has been added to the source to indicate not to remove the check. changelog: [`large_stack_arrays`]: do not warn for code auto-generated by libtest harness Fixes #13774
2 parents 3e80a8c + a5a44b8 commit 98ced04

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

clippy_lints/src/large_stack_arrays.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
9494
})
9595
&& u128::from(self.maximum_allowed_size) < u128::from(element_count) * u128::from(element_size)
9696
{
97+
// libtest might generate a large array containing the test cases, and no span will be associated
98+
// to it. In this case it is better not to complain.
99+
//
100+
// Note that this condition is not checked explicitly by a unit test. Do not remove it without
101+
// ensuring that <https://github.com/rust-lang/rust-clippy/issues/13774> stays fixed.
102+
if expr.span.is_dummy() {
103+
return;
104+
}
105+
97106
span_lint_and_then(
98107
cx,
99108
LARGE_STACK_ARRAYS,

0 commit comments

Comments
 (0)