-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix large_stack_frames FP on compiler generated targets
#15101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
profetia
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
profetia:issue15099
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| stack-size-threshold = 0 |
41 changes: 41 additions & 0 deletions
41
tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| //@ normalize-stderr-test: "\b10000(08|16|32)\b" -> "100$$PTR" | ||
| //@ normalize-stderr-test: "\b2500(060|120)\b" -> "250$$PTR" | ||
|
|
||
| #![warn(clippy::large_stack_frames)] | ||
|
|
||
| extern crate serde; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| struct ArrayDefault<const N: usize>([u8; N]); | ||
|
|
||
| macro_rules! mac { | ||
| ($name:ident) => { | ||
| fn foo() { | ||
| let $name = 1; | ||
| println!("macro_name called"); | ||
| } | ||
|
|
||
| fn bar() { | ||
| let $name = ArrayDefault([0; 1000]); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| mac!(something); | ||
| //~^ large_stack_frames | ||
| //~| large_stack_frames | ||
|
|
||
| #[derive(Deserialize, Serialize)] | ||
| //~^ large_stack_frames | ||
| //~| large_stack_frames | ||
| //~| large_stack_frames | ||
| //~| large_stack_frames | ||
| //~| large_stack_frames | ||
| //~| large_stack_frames | ||
| //~| large_stack_frames | ||
| //~| large_stack_frames | ||
| struct S { | ||
| a: [u128; 31], | ||
| } | ||
|
|
||
| fn main() {} | ||
89 changes: 89 additions & 0 deletions
89
tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.stderr
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| error: function `foo` generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:24:1 | ||
| | | ||
| LL | fn foo() { | ||
| | --- this function has a stack frame size of 92 bytes | ||
| ... | ||
| LL | mac!(something); | ||
| | ^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: 92 bytes is larger than Clippy's configured `stack-size-threshold` of 0 | ||
| = 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: function `bar` generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:24:1 | ||
| | | ||
| LL | fn bar() { | ||
| | --- this function has a stack frame size of 2000 bytes | ||
| LL | let $name = ArrayDefault([0; 1000]); | ||
| | --------- this is the largest part, at 1000 bytes for type `[u8; 1000]` | ||
| ... | ||
| LL | mac!(something); | ||
| | ^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: 2000 bytes is larger than Clippy's configured `stack-size-threshold` of 0 | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:10 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^^^ | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:10 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:10 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:10 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:10 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:10 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:10 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: method generated by this macro may allocate a lot of stack space | ||
| --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:28:23 | ||
| | | ||
| LL | #[derive(Deserialize, Serialize)] | ||
| | ^^^^^^^^^ | ||
|
|
||
| error: aborting due to 10 previous errors | ||
|
|
2 changes: 2 additions & 0 deletions
2
tests/ui-toml/large_stack_frames_for_special_targets/clippy.toml
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| stack-size-threshold = 0 | ||
| allow-large-stack-frames-in-tests = false |
13 changes: 13 additions & 0 deletions
13
tests/ui-toml/large_stack_frames_for_special_targets/large_stack_frames.rs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // This test checks if `clippy::large_stack_frames` is working correctly when encountering functions | ||
| // generated by special compiling targets like `--test`. | ||
| //@compile-flags: --test | ||
| //@check-pass | ||
|
|
||
| #![warn(clippy::large_stack_frames)] | ||
|
|
||
| #[cfg(test)] | ||
| #[expect(clippy::large_stack_frames)] | ||
| mod test { | ||
| #[test] | ||
| fn main_test() {} | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.