forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#83519 - oli-obk:assign_shrink_your_normal_c…
…ode, r=pnkfelix Implement a lint that highlights all moves larger than a configured limit Tracking issue: rust-lang#83518 [MCP 420](rust-lang/compiler-team#420) still ~blazing~ in progress r? ``@pnkfelix`` The main open issue I see with this minimal impl of the feature is that the lint is immediately "stable" (so it can be named on stable), even if it is never executed on stable. I don't think we have the concept of unstable lint names or hiding lint names without an active feature gate, so that would be a bigger change.
- Loading branch information
Showing
13 changed files
with
218 additions
and
21 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![deny(large_assignments)] | ||
#![feature(large_assignments)] | ||
#![move_size_limit = "1000"] | ||
// build-fail | ||
// only-x86_64 | ||
|
||
// edition:2018 | ||
|
||
fn main() { | ||
let x = async { //~ ERROR large_assignments | ||
let y = [0; 9999]; | ||
dbg!(y); | ||
thing(&y).await; | ||
dbg!(y); | ||
}; | ||
let z = (x, 42); //~ ERROR large_assignments | ||
//~^ ERROR large_assignments | ||
let a = z.0; //~ ERROR large_assignments | ||
let b = z.1; | ||
} | ||
|
||
async fn thing(y: &[u8]) { | ||
dbg!(y); | ||
} |
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,38 @@ | ||
error: moving 10024 bytes | ||
--> $DIR/large_moves.rs:10:13 | ||
| | ||
LL | let x = async { | ||
| _____________^ | ||
LL | | let y = [0; 9999]; | ||
LL | | dbg!(y); | ||
LL | | thing(&y).await; | ||
LL | | dbg!(y); | ||
LL | | }; | ||
| |_____^ value moved from here | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/large_moves.rs:1:9 | ||
| | ||
LL | #![deny(large_assignments)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: moving 10024 bytes | ||
--> $DIR/large_moves.rs:16:14 | ||
| | ||
LL | let z = (x, 42); | ||
| ^ value moved from here | ||
|
||
error: moving 10024 bytes | ||
--> $DIR/large_moves.rs:16:13 | ||
| | ||
LL | let z = (x, 42); | ||
| ^^^^^^^ value moved from here | ||
|
||
error: moving 10024 bytes | ||
--> $DIR/large_moves.rs:18:13 | ||
| | ||
LL | let a = z.0; | ||
| ^^^ value moved from here | ||
|
||
error: aborting due to 4 previous errors | ||
|
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,5 @@ | ||
// check that `move_size_limit is feature-gated | ||
|
||
#![move_size_limit = "42"] //~ ERROR the `#[move_size_limit]` attribute is an experimental feature | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/feature-gates/feature-gate-large-assignments.stderr
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,12 @@ | ||
error[E0658]: the `#[move_size_limit]` attribute is an experimental feature | ||
--> $DIR/feature-gate-large-assignments.rs:3:1 | ||
| | ||
LL | #![move_size_limit = "42"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #83518 <https://github.com/rust-lang/rust/issues/83518> for more information | ||
= help: add `#![feature(large_assignments)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |