Skip to content

Commit a5a44b8

Browse files
committed
Do not warn about large stack arrays without having a valid span
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.
1 parent d227bf4 commit a5a44b8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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)