This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +63
-3
lines changed
tests/ui/lint/large_assignments Expand file tree Collapse file tree 4 files changed +63
-3
lines changed Original file line number Diff line number Diff line change 1+ #![ deny( large_assignments) ]
2+ #![ feature( large_assignments) ]
3+ #![ move_size_limit = "1000" ]
4+ // build-fail
5+ // only-x86_64
6+
7+ // edition:2018
8+ // compile-flags: -Zmir-opt-level=1
9+
10+ use std:: { sync:: Arc , rc:: Rc } ;
11+
12+ fn main ( ) {
13+ let data = [ 0 ; 9999 ] ;
14+
15+ // Looking at --emit mir, we can see that all parameters below are passed by
16+ // copy. But it requires at least mir-opt-level=1.
17+ let _ = Arc :: new ( data) ; // OK!
18+ let _ = Box :: new ( data) ; // OK!
19+ let _ = Rc :: new ( data) ; // OK!
20+ let _ = NotBox :: new ( data) ; //~ ERROR large_assignments
21+ }
22+
23+ struct NotBox {
24+ data : [ u8 ; 9999 ] ,
25+ }
26+
27+ impl NotBox {
28+ fn new ( data : [ u8 ; 9999 ] ) -> Self {
29+ Self { //~ ERROR large_assignments
30+ data,
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ error: moving 9999 bytes
2+ --> $DIR/copy_into_box_rc_arc.rs:20:25
3+ |
4+ LL | let _ = NotBox::new(data);
5+ | ^^^^ value moved from here
6+ |
7+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
8+ note: the lint level is defined here
9+ --> $DIR/copy_into_box_rc_arc.rs:1:9
10+ |
11+ LL | #![deny(large_assignments)]
12+ | ^^^^^^^^^^^^^^^^^
13+
14+ error: moving 9999 bytes
15+ --> $DIR/copy_into_box_rc_arc.rs:29:9
16+ |
17+ LL | / Self {
18+ LL | | data,
19+ LL | | }
20+ | |_________^ value moved from here
21+ |
22+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
23+
24+ error: aborting due to 2 previous errors
25+
Original file line number Diff line number Diff line change 1010use std:: { sync:: Arc , rc:: Rc } ;
1111
1212fn main ( ) {
13+ // Looking at --emit mir, we can see that all parameters below are passed
14+ // with by move.
1315 let _ = Arc :: new ( [ 0 ; 9999 ] ) ; // OK!
1416 let _ = Box :: new ( [ 0 ; 9999 ] ) ; // OK!
1517 let _ = Rc :: new ( [ 0 ; 9999 ] ) ; // OK!
Original file line number Diff line number Diff line change 11error: moving 9999 bytes
2- --> $DIR/box_rc_arc_allowed .rs:16 :25
2+ --> $DIR/move_into_box_rc_arc .rs:18 :25
33 |
44LL | let _ = NotBox::new([0; 9999]);
55 | ^^^^^^^^^ value moved from here
66 |
77 = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
88note: the lint level is defined here
9- --> $DIR/box_rc_arc_allowed .rs:1:9
9+ --> $DIR/move_into_box_rc_arc .rs:1:9
1010 |
1111LL | #![deny(large_assignments)]
1212 | ^^^^^^^^^^^^^^^^^
1313
1414error: moving 9999 bytes
15- --> $DIR/box_rc_arc_allowed .rs:26 :13
15+ --> $DIR/move_into_box_rc_arc .rs:28 :13
1616 |
1717LL | data,
1818 | ^^^^ value moved from here
You can’t perform that action at this time.
0 commit comments