forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#12582 - kpreid:stacksize, r=Manishearth
`large_stack_frames`: print total size and largest component. Instead of just saying “this function's stack frame is big”, report: * the (presumed) size of the frame * the size and type of the largest local contributing to that size * the configurable limit that was exceeded (once) Known issues: * The lint may report an over-estimate because codegen may be able to overlap some of these locals. However, that already affected whether the lint fired at all; I believe this change is still an improvement because it gives the user much more actionable information about _why_ the lint fired. * Please tell me a better way to determine whether a local has a variable name. changelog: [`large_stack_frames`]: print total size and largest component.
- Loading branch information
Showing
5 changed files
with
136 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
error: this function allocates a large amount of stack space | ||
--> tests/ui/large_stack_frames.rs:25:1 | ||
| | ||
LL | / fn many_small_arrays() { | ||
LL | | | ||
LL | | | ||
LL | | let x = [0u8; 500_000]; | ||
... | | ||
LL | | black_box((&x, &x2, &x3, &x4, &x5)); | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: allocating large amounts of stack space can overflow the stack | ||
error: this function may allocate 250$PTR bytes on the stack | ||
--> tests/ui/large_stack_frames.rs:27:4 | ||
| | ||
LL | fn many_small_arrays() { | ||
| ^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | let x5 = [0u8; 500_000]; | ||
| -- `x5` is the largest part, at 500000 bytes for type `[u8; 500000]` | ||
| | ||
= note: 250$PTR bytes is larger than Clippy's configured `stack-size-threshold` of 512000 | ||
= note: allocating large amounts of stack space can overflow the stack and cause the program to abort | ||
= note: `-D clippy::large-stack-frames` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::large_stack_frames)]` | ||
|
||
error: this function allocates a large amount of stack space | ||
--> tests/ui/large_stack_frames.rs:36:1 | ||
error: this function may allocate 1000000 bytes on the stack | ||
--> tests/ui/large_stack_frames.rs:37:4 | ||
| | ||
LL | fn large_return_value() -> ArrayDefault<1_000_000> { | ||
| ^^^^^^^^^^^^^^^^^^ ----------------------- this is the largest part, at 1000000 bytes for type `ArrayDefault<1000000>` | ||
| | ||
= note: 1000000 bytes is larger than Clippy's configured `stack-size-threshold` of 512000 | ||
|
||
error: this function may allocate 100$PTR bytes on the stack | ||
--> tests/ui/large_stack_frames.rs:42:4 | ||
| | ||
LL | / fn large_return_value() -> ArrayDefault<1_000_000> { | ||
LL | | | ||
LL | | | ||
LL | | Default::default() | ||
LL | | } | ||
| |_^ | ||
LL | fn large_fn_arg(x: ArrayDefault<1_000_000>) { | ||
| ^^^^^^^^^^^^ - `x` is the largest part, at 1000000 bytes for type `ArrayDefault<1000000>` | ||
| | ||
= note: allocating large amounts of stack space can overflow the stack | ||
= note: 100$PTR bytes is larger than Clippy's configured `stack-size-threshold` of 512000 | ||
|
||
error: this function allocates a large amount of stack space | ||
--> tests/ui/large_stack_frames.rs:42:1 | ||
error: this function may allocate 100$PTR bytes on the stack | ||
--> tests/ui/large_stack_frames.rs:48:13 | ||
| | ||
LL | / fn large_fn_arg(x: ArrayDefault<1_000_000>) { | ||
LL | | | ||
LL | | | ||
LL | | black_box(&x); | ||
LL | | } | ||
| |_^ | ||
LL | let f = || black_box(&[0u8; 1_000_000]); | ||
| ^^^^^^^^^^^^^^----------------^ | ||
| | | ||
| this is the largest part, at 1000000 bytes for type `[u8; 1000000]` | ||
| | ||
= note: allocating large amounts of stack space can overflow the stack | ||
= note: 100$PTR bytes is larger than Clippy's configured `stack-size-threshold` of 512000 | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 4 previous errors | ||
|