Skip to content

Commit 1369367

Browse files
committed
fix: large_stack_frames FP on compiler generated targets
1 parent 62fd159 commit 1369367

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

clippy_lints/src/large_stack_frames.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames {
170170
FnKind::Closure => entire_fn_span,
171171
};
172172

173+
// Don't lint compiler-generated targets
174+
if fn_span.is_dummy() {
175+
return;
176+
}
177+
173178
span_lint_and_then(
174179
cx,
175180
LARGE_STACK_FRAMES,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stack-size-threshold = 0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@compile-flags: --test
2+
#![allow(unused)]
3+
#![warn(clippy::large_stack_frames)]
4+
5+
fn main() {
6+
//~^ large_stack_frames
7+
println!("Hello, world!");
8+
}
9+
10+
#[cfg(test)]
11+
#[allow(clippy::large_stack_frames)]
12+
mod test {
13+
#[test]
14+
fn main_test() {}
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: this function may allocate 88 bytes on the stack
2+
--> tests/ui-toml/large_stack_frames_for_generated_fn/large_stack_frames.rs:5:4
3+
|
4+
LL | fn main() {
5+
| ^^^^
6+
LL |
7+
LL | println!("Hello, world!");
8+
| ------------------------- this is the largest part, at 48 bytes for type `std::fmt::Arguments<'_>`
9+
|
10+
= note: 88 bytes is larger than Clippy's configured `stack-size-threshold` of 0
11+
= note: allocating large amounts of stack space can overflow the stack and cause the program to abort
12+
= note: `-D clippy::large-stack-frames` implied by `-D warnings`
13+
= help: to override `-D warnings` add `#[allow(clippy::large_stack_frames)]`
14+
15+
error: aborting due to 1 previous error
16+

0 commit comments

Comments
 (0)