-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
large_assignments: Lint on specific large args passed to functions
- Loading branch information
Showing
5 changed files
with
134 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// build-fail | ||
|
||
#![feature(large_assignments)] | ||
#![move_size_limit = "1000"] | ||
#![deny(large_assignments)] | ||
#![allow(unused)] | ||
|
||
// We want copy semantics, because moving data into functions generally do not | ||
// translate to actual `memcpy`s. | ||
#[derive(Copy, Clone)] | ||
struct Data([u8; 9999]); | ||
|
||
fn main() { | ||
one_arg(Data([0; 9999])); //~ ERROR large_assignments | ||
|
||
// each individual large arg shall have its own span | ||
many_args(Data([0; 9999]), true, Data([0; 9999])); | ||
//~^ ERROR large_assignments | ||
//~| ERROR large_assignments | ||
} | ||
|
||
fn one_arg(a: Data) {} | ||
|
||
fn many_args(a: Data, b: bool, c: Data) {} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
error: moving 9999 bytes | ||
--> $DIR/copy_into_fn.rs:14:13 | ||
| | ||
LL | one_arg(Data([0; 9999])); | ||
| ^^^^^^^^^^^^^^^ value moved from here | ||
| | ||
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` | ||
note: the lint level is defined here | ||
--> $DIR/copy_into_fn.rs:5:9 | ||
| | ||
LL | #![deny(large_assignments)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: moving 9999 bytes | ||
--> $DIR/copy_into_fn.rs:17:15 | ||
| | ||
LL | many_args(Data([0; 9999]), true, Data([0; 9999])); | ||
| ^^^^^^^^^^^^^^^ value moved from here | ||
| | ||
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` | ||
|
||
error: moving 9999 bytes | ||
--> $DIR/copy_into_fn.rs:17:38 | ||
| | ||
LL | many_args(Data([0; 9999]), true, Data([0; 9999])); | ||
| ^^^^^^^^^^^^^^^ value moved from here | ||
| | ||
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` | ||
|
||
error: aborting due to 3 previous errors | ||
|